[java-highlighting] IDEA-304893 allow array init before super

GitOrigin-RevId: 9a20ede1944cfc2d9511753ba9490c5beb94b21e
This commit is contained in:
Mikhail Pyltsin
2023-08-11 21:40:38 +00:00
committed by intellij-monorepo-bot
parent 4fb2e28c3e
commit c83b6fd069
3 changed files with 27 additions and 0 deletions
@@ -2811,6 +2811,12 @@ public final class HighlightUtil {
return null;
}
if (expression instanceof PsiJavaCodeReferenceElement &&
expression.getParent() instanceof PsiNewExpression newExpression &&
newExpression.isArrayCreation() && newExpression.getClassOrAnonymousClassReference() == expression) {
return null;
}
HighlightInfo.Builder builder = createMemberReferencedError(resolvedName, expression.getTextRange());
if (expression instanceof PsiReferenceExpression ref && PsiUtil.isInnerClass(parentClass)) {
String referenceName = ref.getReferenceName();
@@ -0,0 +1,17 @@
public class ArrayInitBeforeSuper {
public static void main(String[] args) {
}
public class Example extends Zuper{
public class Inner{
}
Example() {
super(new Inner[]{}); // <<<< NOT ERROR
}
}
class Zuper {
Zuper(Example.Inner[] inners) {
}
}
}
@@ -442,4 +442,8 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testUninitializedVarComplexTernary() {
doTest(false);
}
public void testArrayInitBeforeSuper() {
doTest(false);
}
}