mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 13:31:28 +07:00
this and super are not available inside anonymous class args
This commit is contained in:
@@ -1521,6 +1521,9 @@ public class HighlightUtil extends HighlightUtilBase {
|
||||
}
|
||||
else {
|
||||
aClass = PsiTreeUtil.getParentOfType(expr, PsiClass.class);
|
||||
if (aClass instanceof PsiAnonymousClass && PsiTreeUtil.isAncestor(((PsiAnonymousClass)aClass).getArgumentList(), expr, false)) {
|
||||
aClass = PsiTreeUtil.getParentOfType(aClass, PsiClass.class, true);
|
||||
}
|
||||
}
|
||||
if (aClass == null) return null;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ class C implements A {
|
||||
|
||||
interface A {
|
||||
A a = new C(<error descr="'A.this' cannot be referenced from a static context">this</error>);
|
||||
A a1 = new C(<error descr="Cannot find symbol variable this">this</error>){};
|
||||
A a1 = new C(<error descr="'A.this' cannot be referenced from a static context">this</error>){};
|
||||
|
||||
class B {
|
||||
A foo() {
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
class A {
|
||||
public A(Object o) {
|
||||
}
|
||||
}
|
||||
|
||||
class B {}
|
||||
|
||||
class C extends B {
|
||||
static {
|
||||
A a = new A(<error descr="'C.this' cannot be referenced from a static context">this</error>) {};
|
||||
A a1 = new A(<error descr="'C.super' cannot be referenced from a static context">super</error>.clone()) {};
|
||||
}
|
||||
|
||||
{
|
||||
A a = new A(this);
|
||||
}
|
||||
}
|
||||
@@ -75,4 +75,7 @@ public class LightAdvHighlightingJdk6Test extends LightDaemonAnalyzerTestCase {
|
||||
public void testVariableUsedBeforeAssignmentWithParenthesis() {
|
||||
doTest(false, false);
|
||||
}
|
||||
public void testThisInArgListOfAnonymous() {
|
||||
doTest(false, false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user