mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 21:55:01 +07:00
this is inaccessible inside interface (IDEA-94986)
This commit is contained in:
@@ -1305,9 +1305,25 @@ public class HighlightUtil extends HighlightUtilBase {
|
||||
return HighlightClassUtil.reportIllegalEnclosingUsage(expr, null, aClass, expr);
|
||||
}
|
||||
|
||||
if (expr instanceof PsiThisExpression && PsiTreeUtil.getParentOfType(expr, PsiMethod.class) == null) {
|
||||
if (aClass.isInterface()) {
|
||||
return thisNotFoundInInterfaceInfo(expr);
|
||||
}
|
||||
|
||||
if (aClass instanceof PsiAnonymousClass && PsiTreeUtil.isAncestor(((PsiAnonymousClass)aClass).getArgumentList(), expr, true)) {
|
||||
final PsiClass parentClass = PsiTreeUtil.getParentOfType(aClass, PsiClass.class, true);
|
||||
if (parentClass != null && parentClass.isInterface()) {
|
||||
return thisNotFoundInInterfaceInfo(expr);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static HighlightInfo thisNotFoundInInterfaceInfo(PsiExpression expr) {
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, expr, "Cannot find symbol variable this");
|
||||
}
|
||||
|
||||
private static boolean resolvesToImmediateSuperInterface(@NotNull PsiExpression expr,
|
||||
@Nullable PsiJavaCodeReferenceElement qualifier,
|
||||
@NotNull PsiClass aClass) {
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class C implements A {
|
||||
C(A a) {}
|
||||
}
|
||||
|
||||
interface A {
|
||||
A a = new C(<error descr="Cannot find symbol variable this">this</error>);
|
||||
A a1 = new C(<error descr="Cannot find symbol variable this">this</error>){};
|
||||
}
|
||||
@@ -359,4 +359,5 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testUnsupportedFeatures() throws Exception { doTest(false, false); }
|
||||
public void testThisBeforeSuper() throws Exception { doTest(false, false); }
|
||||
public void testExplicitConstructorInvocation() throws Exception { doTest(false, false); }
|
||||
public void testThisInInterface() throws Exception { doTest(false, false); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user