mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inline local: don't check assignability before decoding (IDEA-152883)
This commit is contained in:
@@ -72,6 +72,10 @@ public class InlineUtil {
|
||||
|
||||
ChangeContextUtil.encodeContextInfo(initializer, false);
|
||||
PsiExpression expr = (PsiExpression)replaceDiamondWithInferredTypesIfNeeded(initializer, ref);
|
||||
|
||||
PsiThisExpression thisAccessExpr = createThisExpression(manager, thisClass, refParent);
|
||||
|
||||
expr = (PsiExpression)ChangeContextUtil.decodeContextInfo(expr, thisClass, thisAccessExpr);
|
||||
PsiType exprType = expr.getType();
|
||||
if (exprType != null && (!varType.equals(exprType) && (varType instanceof PsiPrimitiveType || exprType instanceof PsiPrimitiveType)
|
||||
|| !TypeConversionUtil.isAssignable(varType, exprType)
|
||||
@@ -164,9 +168,7 @@ public class InlineUtil {
|
||||
|
||||
ChangeContextUtil.clearContextInfo(initializer);
|
||||
|
||||
PsiThisExpression thisAccessExpr = createThisExpression(manager, thisClass, refParent);
|
||||
|
||||
return (PsiExpression)ChangeContextUtil.decodeContextInfo(expr, thisClass, thisAccessExpr);
|
||||
return expr;
|
||||
}
|
||||
|
||||
private static PsiExpression surroundWithCast(PsiVariable variable, PsiExpression expr, PsiExpression expression) {
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
class Outer {
|
||||
|
||||
public void bar() {
|
||||
Outer foo = this;
|
||||
|
||||
new Object() {
|
||||
public void run() {
|
||||
f<caret>oo.baz();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void baz() {
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
class Outer {
|
||||
|
||||
public void bar() {
|
||||
|
||||
new Object() {
|
||||
public void run() {
|
||||
Outer.this.baz();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void baz() {
|
||||
}
|
||||
}
|
||||
@@ -256,6 +256,10 @@ public class InlineLocalTest extends LightCodeInsightTestCase {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
public void testDecodeRefsBeforeCheckingOverRedundantCasts() throws Exception {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
public void testLocalVarInsideLambdaBodyWriteUsage() throws Exception {
|
||||
doTest(true, "Cannot perform refactoring.\n" +
|
||||
"Variable 'hello' is accessed for writing");
|
||||
|
||||
Reference in New Issue
Block a user