mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
good code is red: allow unchecked conversion when static methods are in the same class
This commit is contained in:
+2
-1
@@ -315,7 +315,8 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
|
||||
private static Specifics checkSubtyping(PsiType type1, PsiType type2, PsiMethod method1, PsiMethod method2) {
|
||||
boolean noBoxing = type1 instanceof PsiPrimitiveType == type2 instanceof PsiPrimitiveType;
|
||||
final boolean allowUncheckedConversion =
|
||||
!method1.hasModifierProperty(PsiModifier.STATIC) && !method2.hasModifierProperty(PsiModifier.STATIC);
|
||||
!method1.hasModifierProperty(PsiModifier.STATIC) && !method2.hasModifierProperty(PsiModifier.STATIC) ||
|
||||
method1.getContainingClass() == method2.getContainingClass();
|
||||
final boolean assignable2From1 = noBoxing && TypeConversionUtil.isAssignable(type2, type1, allowUncheckedConversion);
|
||||
final boolean assignable1From2 = noBoxing && TypeConversionUtil.isAssignable(type1, type2, allowUncheckedConversion);
|
||||
if (assignable1From2 || assignable2From1) {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
class XX {
|
||||
public static String foo(Properties p, String s, boolean b){return null;}
|
||||
public static String foo(Map p, String s, boolean b){return null;}
|
||||
}
|
||||
class UU {
|
||||
void bar() {
|
||||
Properties p = new Properties();
|
||||
XX.fo<ref>o(p, "xxx", false);
|
||||
}
|
||||
}
|
||||
@@ -509,6 +509,12 @@ public class ResolveMethod15Test extends Resolve15TestCase {
|
||||
assertResolvesToMethodInClass(result, "A");
|
||||
}
|
||||
|
||||
public void testRawInheritanceConflict() throws Exception {
|
||||
PsiJavaReference ref = (PsiJavaReference)configureByFile();
|
||||
final JavaResolveResult[] result = ref.multiResolve(false);
|
||||
assertEquals("False ambiguity", 1, result.length);
|
||||
}
|
||||
|
||||
public void testRawVsGenericConflictInCaseOfOverride() throws Exception{
|
||||
PsiJavaReference ref = (PsiJavaReference) configureByFile();
|
||||
final JavaResolveResult result = ref.advancedResolve(true);
|
||||
|
||||
Reference in New Issue
Block a user