mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 21:11:28 +07:00
A.super.field should not accept super interface (IDEA-140646)
This commit is contained in:
@@ -1510,9 +1510,21 @@ public class HighlightUtil extends HighlightUtilBase {
|
||||
}
|
||||
if (aClass == null) return null;
|
||||
|
||||
if (!InheritanceUtil.hasEnclosingInstanceInScope(aClass, expr, false, false) &&
|
||||
!resolvesToImmediateSuperInterface(expr, qualifier, aClass, languageLevel)) {
|
||||
return HighlightClassUtil.reportIllegalEnclosingUsage(expr, null, aClass, expr);
|
||||
if (!InheritanceUtil.hasEnclosingInstanceInScope(aClass, expr, false, false)) {
|
||||
if (!resolvesToImmediateSuperInterface(expr, qualifier, aClass, languageLevel)) {
|
||||
return HighlightClassUtil.reportIllegalEnclosingUsage(expr, null, aClass, expr);
|
||||
}
|
||||
|
||||
if (expr instanceof PsiSuperExpression) {
|
||||
final PsiElement resolved = ((PsiReferenceExpression)expr.getParent()).resolve();
|
||||
//15.11.2
|
||||
//The form T.super.Identifier refers to the field named Identifier of the lexically enclosing instance corresponding to T,
|
||||
//but with that instance viewed as an instance of the superclass of T.
|
||||
if (resolved instanceof PsiField) {
|
||||
String description = JavaErrorMessages.message("is.not.an.enclosing.class", formatClass(aClass));
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expr).descriptionAndTooltip(description).create();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (qualifier != null && aClass.isInterface() && languageLevel.isAtLeast(LanguageLevel.JDK_1_8)) {
|
||||
|
||||
@@ -25,7 +25,7 @@ class C {
|
||||
I.super.m();
|
||||
<error descr="Unqualified super reference is not allowed in extension method">super.<error descr="Cannot resolve method 'm()'">m</error></error>();
|
||||
|
||||
System.out.println(I.super.i);
|
||||
System.out.println(<error descr="'C.I' is not an enclosing class">I.super</error>.i);
|
||||
System.out.println(<error descr="Unqualified super reference is not allowed in extension method">super.<error descr="Cannot resolve symbol 'i'">i</error></error>);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user