no enclosing instance error for top level classes (IDEA-169088)

This commit is contained in:
Anna.Kozlova
2017-03-08 12:37:00 +01:00
parent 0553ccdc97
commit 0fa0b96dc6
3 changed files with 11 additions and 1 deletions
@@ -784,7 +784,8 @@ public class HighlightClassUtil {
if (!PsiUtil.isInnerClass(base)) return;
if (resolve == resolved && baseClass != null && (!PsiTreeUtil.isAncestor(baseClass, extendRef, true) || aClass.hasModifierProperty(PsiModifier.STATIC)) &&
!InheritanceUtil.hasEnclosingInstanceInScope(baseClass, extendRef, !aClass.hasModifierProperty(PsiModifier.STATIC), true) && !qualifiedNewCalledInConstructors(aClass)) {
!InheritanceUtil.hasEnclosingInstanceInScope(baseClass, extendRef, PsiUtil.isInnerClass(aClass) && !aClass.hasModifierProperty(PsiModifier.STATIC), true) &&
!qualifiedNewCalledInConstructors(aClass)) {
String description = JavaErrorMessages.message("no.enclosing.instance.in.scope", HighlightUtil.formatClass(baseClass));
infos[0] = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(extendRef).descriptionAndTooltip(description).create();
}
@@ -0,0 +1,5 @@
class Outer {
class Inner extends Outer {}
}
class Impl extends <error descr="No enclosing instance of type 'Outer' is in scope">Outer.Inner</error> {}
@@ -630,4 +630,8 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testUncheckedWarningWhenCastingFromCapturedWildcard() throws Exception {
doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_8, true);
}
public void testEnclosingRefInTopLevelClassExtendingInnerWhichExtendsItsOuter() throws Exception {
doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_8, true);
}
}