good code is red: allow unchecked conversion when static methods are in the same class

This commit is contained in:
anna
2011-07-13 16:56:37 +04:00
parent 544fd7d9a6
commit 902deda3ac
3 changed files with 18 additions and 1 deletions
@@ -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);