Inliner: don't take into account nonexistent PSI to keep parameter

So #KT-17272 Fixed
This commit is contained in:
Mikhail Glukhikh
2017-04-13 15:23:53 +03:00
parent b8cc7c2ca6
commit 0f6b9473e9
4 changed files with 15 additions and 0 deletions
@@ -305,6 +305,7 @@ class CodeInliner<TCallElement : KtElement>(
is KtBinaryExpression -> if (sideEffectOnly) left.shouldKeepValue(usageCount) || right.shouldKeepValue(usageCount) else true
is KtIfExpression -> if (sideEffectOnly) condition.shouldKeepValue(usageCount) || then.shouldKeepValue(usageCount) || `else`.shouldKeepValue(usageCount) else true
is KtBinaryExpressionWithTypeRHS -> true
null -> false
else -> true
}
}
@@ -0,0 +1,5 @@
fun manyParams(used: String, unused: String) = println(used)
fun callMany() {
<caret>manyParams("op", "qr")
}
@@ -0,0 +1,3 @@
fun callMany() {
println("op")
}
@@ -118,6 +118,12 @@ public class InlineTestGenerated extends AbstractInlineTest {
doTest(fileName);
}
@TestMetadata("DoNotKeepString.kt")
public void testDoNotKeepString() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/inline/function/expressionBody/DoNotKeepString.kt");
doTest(fileName);
}
@TestMetadata("ExplicitReturnType.kt")
public void testExplicitReturnType() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/inline/function/expressionBody/ExplicitReturnType.kt");