mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Do not qualify this reference with null. if it refers to an anonymous class
Fixes EA-218789 - assert: JavaParserUtil.parseFragment GitOrigin-RevId: 035aaf1efa43dc1f324be0942957bf24de65f50f
This commit is contained in:
committed by
intellij-monorepo-bot
parent
de6bf1c185
commit
b9e6d12fb6
@@ -843,7 +843,12 @@ public class InlineMethodProcessor extends BaseRefactoringProcessor {
|
||||
PsiClass parentClass = (PsiClass)parent;
|
||||
final PsiClass containingClass = myMethod.getContainingClass();
|
||||
if (containingClass != null && parentClass.isInheritor(containingClass, true)) {
|
||||
qualifier = myFactory.createExpressionFromText(parentClass.getName() + ".this", null);
|
||||
String name = parentClass.getName();
|
||||
// We cannot have qualified this reference to an anonymous class, so we leave it unqualified
|
||||
// this might produce incorrect code in extremely rare cases
|
||||
// when we inline a superclass method in an anonymous class,
|
||||
// and the method body contains a nested class that refers to the outer one
|
||||
qualifier = myFactory.createExpressionFromText(name == null ? "this" : name + ".this", null);
|
||||
}
|
||||
else if (containingClass != null && parentClass.equals(containingClass)) {
|
||||
qualifier = myFactory.createExpressionFromText("this", null);
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
public class Test {
|
||||
static class X {
|
||||
void foo() {
|
||||
System.out.println(this);
|
||||
}
|
||||
}
|
||||
|
||||
void test() {
|
||||
new X () {
|
||||
void bar() {
|
||||
<caret>foo();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
public class Test {
|
||||
static class X {
|
||||
}
|
||||
|
||||
void test() {
|
||||
new X () {
|
||||
void bar() {
|
||||
System.out.println(this);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user