mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
check for type param numbers in java 1.6 should not rise error if super methods have type params (IDEA-57338)
This commit is contained in:
+8
-1
@@ -137,7 +137,7 @@ public class GenericsHighlightUtil {
|
||||
if (targetParametersNum == 0) {
|
||||
if (PsiTreeUtil.getParentOfType(referenceParameterList, PsiCall.class) != null &&
|
||||
typeParameterListOwner instanceof PsiMethod &&
|
||||
javaSdkVersion.isAtLeast(JavaSdkVersion.JDK_1_7)) {
|
||||
(javaSdkVersion.isAtLeast(JavaSdkVersion.JDK_1_7) || hasSuperMethodsWithTypeParams((PsiMethod)typeParameterListOwner))) {
|
||||
description = null;
|
||||
}
|
||||
else {
|
||||
@@ -196,6 +196,13 @@ public class GenericsHighlightUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean hasSuperMethodsWithTypeParams(PsiMethod method) {
|
||||
for (PsiMethod superMethod : method.findDeepestSuperMethods()) {
|
||||
if (superMethod.hasTypeParameters()) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static PsiType detectExpectedType(PsiReferenceParameterList referenceParameterList) {
|
||||
final PsiNewExpression newExpression = PsiTreeUtil.getParentOfType(referenceParameterList, PsiNewExpression.class);
|
||||
LOG.assertTrue(newExpression != null);
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
abstract class A {
|
||||
abstract <T> void foo();
|
||||
}
|
||||
|
||||
abstract class B extends A {
|
||||
void foo()
|
||||
{
|
||||
this.<Integer>foo();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class C {
|
||||
void foo()
|
||||
{
|
||||
this.<error descr="Method 'foo()' does not have type parameters"><Integer></error>foo();
|
||||
}
|
||||
}
|
||||
@@ -366,6 +366,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testIDEA57388() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
|
||||
public void testIDEA125800() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
|
||||
public void testIDEA125816() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
|
||||
public void testIDEA57338() { doTest(LanguageLevel.JDK_1_6, JavaSdkVersion.JDK_1_6, false); }
|
||||
//jdk should propagate LL 1.4 but actually it provides LL 1.7?!
|
||||
public void testCastObjectToIntJdk14() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_4, false); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user