accept raw subtyping when instance method is called on raw type (IDEA-107957)

This commit is contained in:
Anna Kozlova
2013-05-28 18:35:35 +04:00
parent 2f9f136dc8
commit 9661f35dbd
3 changed files with 39 additions and 1 deletions

View File

@@ -467,7 +467,7 @@ public final class PsiUtil extends PsiUtilCore {
if (args.length < parms.length - 1) return ApplicabilityLevel.NOT_APPLICABLE;
final PsiClass containingClass = method.getContainingClass();
final boolean isRaw = containingClass != null && isRawSubstitutor(containingClass, substitutorForMethod);
final boolean isRaw = containingClass != null && isRawSubstitutor(method, substitutorForMethod) && isRawSubstitutor(containingClass, substitutorForMethod);
if (!areFirstArgumentsApplicable(args, parms, languageLevel, substitutorForMethod, isRaw)) return ApplicabilityLevel.NOT_APPLICABLE;
if (args.length == parms.length) {
if (parms.length == 0) return ApplicabilityLevel.FIXED_ARITY;

View File

@@ -0,0 +1,37 @@
class Test1 {
private static final Foo<Boolean> test = new Foo().method(Boolean.TRUE);
public static void main(String[] args) {
System.out.println(test);
}
public static class Foo<T> {
public Foo<Boolean> method(boolean arg) {
return null;
}
public <T extends Enum<T>> Foo<T> method(T arg) {
return null;
}
}
}
class Test2 {
private static final Foo<Boolean> test = Foo.method(Boolean.TRUE);
public static void main(String[] args) {
System.out.println(test);
}
public static class Foo<T> {
public static Foo<Boolean> method(boolean arg) {
return null;
}
public static <T extends Enum<T>> Foo<T> method(T arg) {
return null;
}
}
}

View File

@@ -236,6 +236,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testIDEA20244() throws Exception { doTest5(false);}
public void testIDEA22005() throws Exception { doTest5(false);}
public void testIDEA57259() throws Exception { doTest5(false);}
public void testIDEA107957() throws Exception { doTest6(false);}
public void testIDEA106964() throws Exception { doTest5(false);}
public void testInheritedWithDifferentArgsInTypeParams() throws Exception { doTest5(false);}
public void testIllegalForwardReferenceInTypeParameterDefinition() throws Exception { doTest5(false);}