inline super class: fix this qualifier for nested/anonymous classes in constructors (IDEA-194883)

This commit is contained in:
Anna.Kozlova
2018-08-09 11:36:31 +02:00
parent 90dc2fcf2a
commit d9822e4d4f
5 changed files with 26 additions and 6 deletions
@@ -326,12 +326,7 @@ public class ChangeContextUtil {
PsiThisExpression thisExpr = (PsiThisExpression)scope;
if (thisExpr.getQualifier() == null){
if (thisClass instanceof PsiAnonymousClass) return null;
PsiThisExpression qualifiedThis = RefactoringChangeUtil.createThisExpression(thisClass.getManager(), thisClass);
if (thisExpr.getParent() != null) {
return thisExpr.replace(qualifiedThis);
} else {
return qualifiedThis;
}
return RefactoringChangeUtil.createThisExpression(thisClass.getManager(), thisClass);
}
}
else if (!(scope instanceof PsiClass)){
@@ -0,0 +1,10 @@
class Test {
protected final Object myBar;
protected final Object myBizz;
public Test() {
this.myBar = new Object() {
};
this.myBizz = null;
}
}
@@ -0,0 +1,10 @@
class Super {
protected final Object myBar;
protected final Object myBizz;
protected Super() {
myBar = new Object() {
};
myBizz = null;
}
}
@@ -0,0 +1,4 @@
class Test extends Super{
public Test() {
}
}
@@ -80,6 +80,7 @@ public class InlineSuperClassTest extends MultiFileTestCase {
public void testOneAndKeepReferencesInAnotherInheritor() {
doTest(false, true);
}
public void testThisQualificationInsideAnonymous() { doTest(); }
private void doTest() {
doTest(false, false);