BranchedFoldingUtils: fix psi tree after tryFoldToAssignment

#KT-38677 Fixed
This commit is contained in:
Dmitry Gridin
2020-04-30 18:06:25 +07:00
parent ee0b7426c4
commit afb15eb7cf
2 changed files with 6 additions and 3 deletions
@@ -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)
}
@@ -3,9 +3,11 @@ fun test(i: Int) {
<caret>fn = if (i == 1) {
{ "foo" }
} else if (i == 2) {
}
else if (i == 2) {
{ "bar" }
} else {
}
else {
{ "baz" }
}
}