diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/BranchedFoldingUtils.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/BranchedFoldingUtils.kt index 44de4d9a3d1..12c72120064 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/BranchedFoldingUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/BranchedFoldingUtils.kt @@ -192,9 +192,10 @@ object BranchedFoldingUtils { lhs = left!!.copy() as KtExpression op = operationReference.text } + val rhs = right!! if (rhs is KtLambdaExpression && this.parent !is KtBlockExpression) { - replace(psiFactory.createExpressionByPattern("{ $0 }", rhs)) + replace(psiFactory.createSingleStatementBlock(rhs)) } else { replace(rhs) } diff --git a/idea/testData/inspectionsLocal/liftOut/ifToAssignment/lambda2.kt.after b/idea/testData/inspectionsLocal/liftOut/ifToAssignment/lambda2.kt.after index d4782a4da56..eeab8fa514f 100644 --- a/idea/testData/inspectionsLocal/liftOut/ifToAssignment/lambda2.kt.after +++ b/idea/testData/inspectionsLocal/liftOut/ifToAssignment/lambda2.kt.after @@ -3,9 +3,11 @@ fun test(i: Int) { fn = if (i == 1) { { "foo" } - } else if (i == 2) { + } + else if (i == 2) { { "bar" } - } else { + } + else { { "baz" } } } \ No newline at end of file