mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Java: detect method call before supertype constructor called in anonymous class argument list (IDEA-375801)
GitOrigin-RevId: 0066baefa439fe1eccf838ffb863c0a0753260d4
This commit is contained in:
committed by
intellij-monorepo-bot
parent
9cc3ddae49
commit
6f36a457d7
+2
-2
@@ -1617,10 +1617,10 @@ final class ExpressionChecker {
|
||||
}
|
||||
if (!(expression instanceof PsiThisExpression) && !(expression instanceof PsiSuperExpression) ||
|
||||
((PsiQualifiedExpression)expression).getQualifier() == null) {
|
||||
PsiClass expressionClass = PsiTreeUtil.getParentOfType(expression, PsiClass.class, true);
|
||||
PsiClass expressionClass = PsiUtil.getContainingClass(expression);
|
||||
while (expressionClass != null && parentClass != expressionClass) {
|
||||
if (InheritanceUtil.isInheritorOrSelf(expressionClass, referencedClass, true)) return;
|
||||
expressionClass = PsiTreeUtil.getParentOfType(expressionClass, PsiClass.class, true);
|
||||
expressionClass = PsiUtil.getContainingClass(expressionClass);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+17
@@ -194,4 +194,21 @@ class InitializeField {
|
||||
<error descr="Cannot assign initialized field 'InitializeField.i' before superclass constructor is called">InitializeField.this.i</error> = 1;
|
||||
super();
|
||||
}
|
||||
}
|
||||
class Person {
|
||||
|
||||
Person(Other other) {
|
||||
}
|
||||
|
||||
Person() {
|
||||
Other o = new Other(<error descr="Cannot call 'Object.hashCode()' before superclass constructor is called">hashCode</error>()) {};
|
||||
this(o);
|
||||
}
|
||||
|
||||
Person(int i) {
|
||||
this(new Other(<error descr="Cannot call 'Object.hashCode()' before superclass constructor is called">hashCode</error>()));
|
||||
}
|
||||
}
|
||||
class Other {
|
||||
Other(int x) {}
|
||||
}
|
||||
Reference in New Issue
Block a user