mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-inspections] IDEA-374865 ClassCanBeRecord: fix this not being considered a reference to containing class
In response to IJ-CR-167896 GitOrigin-RevId: e1046f37f326ea127d14d27d332001800e46d327
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3c61fc793b
commit
da203f41d0
+6
@@ -252,6 +252,12 @@ final class ConstructorBodyProcessor {
|
||||
if (expression == null) return false;
|
||||
Ref<Boolean> hasReferenceToClassUnderConstruction = new Ref<>(false);
|
||||
expression.accept(new JavaRecursiveElementWalkingVisitor() {
|
||||
@Override
|
||||
public void visitThisExpression(PsiThisExpression expression) {
|
||||
super.visitThisExpression(expression);
|
||||
hasReferenceToClassUnderConstruction.set(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
super.visitReferenceExpression(expression);
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Convert to record class" "false"
|
||||
class Person<caret> {
|
||||
final String name;
|
||||
final int age;
|
||||
|
||||
Person(String name, int age) {
|
||||
this.name = name;
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
Person(Person person) {
|
||||
System.out.println(this); // javac error: "cannot reference this before supertype constructor has been called"
|
||||
this(person.name, person.age);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user