ReplacementPerformer: always copy statement to insert #KT-17273 Fixed
This commit is contained in:
@@ -69,8 +69,7 @@ internal class ExpressionReplacementPerformer(
|
|||||||
override fun doIt(postProcessing: (PsiChildRange) -> PsiChildRange): KtExpression? {
|
override fun doIt(postProcessing: (PsiChildRange) -> PsiChildRange): KtExpression? {
|
||||||
val insertedStatements = ArrayList<KtExpression>()
|
val insertedStatements = ArrayList<KtExpression>()
|
||||||
for (statement in codeToInline.statementsBefore) {
|
for (statement in codeToInline.statementsBefore) {
|
||||||
// copy the statement if it can get invalidated by findOrCreateBlockToInsertStatement()
|
val statementToUse = statement.copy()
|
||||||
val statementToUse = if (statement.isPhysical) statement.copy() else statement
|
|
||||||
val anchor = findOrCreateBlockToInsertStatement()
|
val anchor = findOrCreateBlockToInsertStatement()
|
||||||
val block = anchor.parent as KtBlockExpression
|
val block = anchor.parent as KtBlockExpression
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
fun sideEffect() {
|
||||||
|
println("qq")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun effect(): String {
|
||||||
|
sideEffect()
|
||||||
|
return "effect"
|
||||||
|
}
|
||||||
|
|
||||||
|
fun manyParams(p1: String, p2: String, p3: String) = println(p1)
|
||||||
|
|
||||||
|
fun callManySimple() = <caret>manyParams(effect(), effect(), effect())
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
fun sideEffect() {
|
||||||
|
println("qq")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun effect(): String {
|
||||||
|
sideEffect()
|
||||||
|
return "effect"
|
||||||
|
}
|
||||||
|
|
||||||
|
fun callManySimple() {
|
||||||
|
effect()
|
||||||
|
effect()
|
||||||
|
println(effect())
|
||||||
|
}
|
||||||
@@ -190,6 +190,12 @@ public class InlineTestGenerated extends AbstractInlineTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ManyParams.kt")
|
||||||
|
public void testManyParams() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/inline/function/expressionBody/ManyParams.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("MultipleInComposition.kt")
|
@TestMetadata("MultipleInComposition.kt")
|
||||||
public void testMultipleInComposition() throws Exception {
|
public void testMultipleInComposition() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/inline/function/expressionBody/MultipleInComposition.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/inline/function/expressionBody/MultipleInComposition.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user