mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Type arguments of a raw method (IDEA-57277)
This commit is contained in:
+21
@@ -1400,6 +1400,27 @@ public class GenericsHighlightUtil {
|
||||
if ((parent instanceof PsiCallExpression || parent instanceof PsiMethodReferenceExpression) && PsiUtil.isLanguageLevel7OrHigher(parent)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (element instanceof PsiMethod) {
|
||||
if (((PsiMethod)element).findSuperMethods().length > 0) return null;
|
||||
if (qualifier instanceof PsiReferenceExpression){
|
||||
final PsiClass typeParameter = PsiUtil.resolveClassInType(((PsiReferenceExpression)qualifier).getType());
|
||||
if (typeParameter instanceof PsiTypeParameter) {
|
||||
if (JavaVersionService.getInstance().isAtLeast(element, JavaSdkVersion.JDK_1_7)) return null;
|
||||
for (PsiClassType classType : typeParameter.getExtendsListTypes()) {
|
||||
final PsiClass resolve = classType.resolve();
|
||||
if (resolve != null) {
|
||||
final PsiMethod[] superMethods = resolve.findMethodsBySignature((PsiMethod)element, true);
|
||||
for (PsiMethod superMethod : superMethods) {
|
||||
if (!PsiUtil.isRawSubstitutor(superMethod, resolveResult.getSubstitutor())) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
final String message = element instanceof PsiClass
|
||||
? JavaErrorMessages.message("generics.type.arguments.on.raw.type")
|
||||
: JavaErrorMessages.message("generics.type.arguments.on.raw.method");
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
interface I{
|
||||
<T extends Iterable<String>> void foo();
|
||||
}
|
||||
|
||||
abstract class A<S> implements I {
|
||||
public abstract <T extends Iterable<String>> void foo();
|
||||
<T extends A> void bar(T x){
|
||||
A a = null;
|
||||
a.<Iterable<String>> foo();
|
||||
x.<Iterable<String>> foo();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class B<S> {
|
||||
public abstract <T extends Iterable<String>> void foo();
|
||||
<T extends B> void bar(T x){
|
||||
B a = null;
|
||||
a.<error descr="Type arguments given on a raw method"><Iterable<String>></error> foo();
|
||||
x.<error descr="Type arguments given on a raw method"><Iterable<String>></error> foo();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class C<S> {
|
||||
public abstract <T extends Iterable<String>> void foo();
|
||||
<T extends C & I> void bar(T x){
|
||||
x.<Iterable<String>> foo();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
interface I1 {
|
||||
void foo();
|
||||
}
|
||||
|
||||
|
||||
abstract class B1<S> {
|
||||
public abstract <T extends Iterable<String>> void foo();
|
||||
<T extends B1 & I1> void bar(T x){
|
||||
B1 a = null;
|
||||
a.<error descr="Type arguments given on a raw method"><Iterable<String>></error> foo();
|
||||
x.<error descr="Type arguments given on a raw method"><Iterable<String>></error> foo();
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
interface I{
|
||||
<T extends Iterable<String>> void foo();
|
||||
}
|
||||
|
||||
abstract class A<S> implements I {
|
||||
public abstract <T extends Iterable<String>> void foo();
|
||||
<T extends A> void bar(T x){
|
||||
A a = null;
|
||||
a.<Iterable<String>> foo();
|
||||
x.<Iterable<String>> foo();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class B<S> {
|
||||
public abstract <T extends Iterable<String>> void foo();
|
||||
<T extends B> void bar(T x){
|
||||
B a = null;
|
||||
a.<error descr="Type arguments given on a raw method"><Iterable<String>></error> foo();
|
||||
x.<Iterable<String>> foo();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class C<S> {
|
||||
public abstract <T extends Iterable<String>> void foo();
|
||||
<T extends C & I> void bar(T x){
|
||||
x.<Iterable<String>> foo();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
interface I1 {
|
||||
void foo();
|
||||
}
|
||||
|
||||
|
||||
abstract class B1<S> {
|
||||
public abstract <T extends Iterable<String>> void foo();
|
||||
<T extends B1 & I1> void bar(T x){
|
||||
B1 a = null;
|
||||
a.<error descr="Type arguments given on a raw method"><Iterable<String>></error> foo();
|
||||
x.<Iterable<String>> foo();
|
||||
}
|
||||
}
|
||||
@@ -243,6 +243,8 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
|
||||
public void testIDEA27185(){ doTest(LanguageLevel.JDK_1_6, JavaSdkVersion.JDK_1_6, false); }
|
||||
public void testIDEA67571(){ doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
|
||||
public void testTypeArgumentsOnRawType(){ doTest(LanguageLevel.JDK_1_6, JavaSdkVersion.JDK_1_6, false); }
|
||||
public void testTypeArgumentsOnRawType17(){ doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
|
||||
|
||||
public void testWildcardsOnRawTypes() { doTest5(false); }
|
||||
public void testDisableWithinBoundsCheckForSuperWildcards() {
|
||||
|
||||
Reference in New Issue
Block a user