Inline: Fix inlining of if-expressions into qualified expressions
#KT-8008 Fixed
This commit is contained in:
@@ -483,6 +483,8 @@ public class KtPsiUtil {
|
||||
}
|
||||
|
||||
if (innerExpression instanceof KtIfExpression) {
|
||||
if (parentExpression instanceof KtQualifiedExpression) return true;
|
||||
|
||||
PsiElement current = parentExpression;
|
||||
|
||||
while (!(current instanceof KtBlockExpression || current instanceof KtDeclaration || current instanceof KtStatementExpression)) {
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
fun boo() : Pair<Int, String> {
|
||||
val flag = true
|
||||
val <caret>value = if (flag) 0 else 1
|
||||
return value.to("value")
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
fun boo() : Pair<Int, String> {
|
||||
val flag = true
|
||||
return (if (flag) 0 else 1).to("value")
|
||||
}
|
||||
@@ -47,6 +47,12 @@ public class InlineTestGenerated extends AbstractInlineTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ifInQualifiedExpression.kt")
|
||||
public void testIfInQualifiedExpression() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/inline/ifInQualifiedExpression.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("InFunctionLiteral.kt")
|
||||
public void testInFunctionLiteral() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/inline/InFunctionLiteral.kt");
|
||||
|
||||
Reference in New Issue
Block a user