mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
type parameter referenced from static context error (IDEA-104160)
(cherry picked from commit ac98afef2ab67f2b548e6723e63b3b9752bf82f5)
This commit is contained in:
+8
@@ -964,6 +964,14 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
if (PsiTreeUtil.isAncestor(aClass, place, false) && aClass.hasTypeParameters()) {
|
||||
myHolder.add(HighlightClassUtil.checkCreateInnerClassFromStaticContext(ref, place, (PsiClass)resolved));
|
||||
}
|
||||
} else if (resolved instanceof PsiTypeParameter) {
|
||||
final PsiTypeParameterListOwner owner = ((PsiTypeParameter)resolved).getOwner();
|
||||
if (owner instanceof PsiClass) {
|
||||
final PsiClass outerClass = (PsiClass)owner;
|
||||
if (!HighlightClassUtil.hasEnclosingInstanceInScope(outerClass, ref, true, false)) {
|
||||
myHolder.add(HighlightClassUtil.reportIllegalEnclosingUsage(ref, aClass, (PsiClass)owner, ref));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import java.util.*;
|
||||
class Test<T> {
|
||||
public static void foo(<error descr="'Test.this' cannot be referenced from a static context">T</error> t) {}
|
||||
public void bar(T t) {}
|
||||
|
||||
static class A extends ArrayList<<error descr="'Test.this' cannot be referenced from a static context">T</error>> {
|
||||
static void boo(<error descr="'Test.this' cannot be referenced from a static context">T</error> t){}
|
||||
}
|
||||
|
||||
class B extends ArrayList<T> {
|
||||
void foo(T r){}
|
||||
}
|
||||
}
|
||||
@@ -220,6 +220,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
}
|
||||
|
||||
public void testIDEA104100() {doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);}
|
||||
public void testIDEA104160() {doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);}
|
||||
|
||||
public void testJavaUtilCollections_NoVerify() throws Exception {
|
||||
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));
|
||||
|
||||
Reference in New Issue
Block a user