mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inline: try to insert cast when conditional expr is inlined (IDEA-91288)
This commit is contained in:
@@ -55,7 +55,8 @@ public class InlineUtil {
|
||||
PsiExpression expr = (PsiExpression)replaceDiamondWithInferredTypesIfNeeded(initializer, ref);
|
||||
PsiType exprType = expr.getType();
|
||||
if (exprType != null && (!varType.equals(exprType) && varType instanceof PsiPrimitiveType
|
||||
|| !TypeConversionUtil.isAssignable(varType, exprType))) {
|
||||
|| !TypeConversionUtil.isAssignable(varType, exprType)
|
||||
|| expr instanceof PsiConditionalExpression)) {
|
||||
boolean matchedTypes = false;
|
||||
//try explicit type arguments
|
||||
final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory();
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
public class Test2 {
|
||||
{
|
||||
Integer iii = true ? 1 : 2;
|
||||
<caret>iii.byteValue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
public class Test2 {
|
||||
{
|
||||
((Integer) (true ? 1 : 2)).byteValue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,6 +148,10 @@ public class InlineLocalTest extends LightCodeInsightTestCase {
|
||||
"Variable 'x' is accessed for writing.");
|
||||
}
|
||||
|
||||
public void testConditionExpr() throws Exception {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
public void testLambdaExpr() throws Exception {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user