diff --git a/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt b/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt index d926135fa8a..19df93df401 100644 --- a/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt +++ b/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt @@ -668,14 +668,14 @@ class RawFirBuilder(val session: FirSession, val stubMode: Boolean) { ) { toFirOrImplicitType() } multiParameter } else { - valueParameter.convert() + valueParameter.toFirValueParameter(FirImplicitTypeRefImpl(session, psi)) } } label = firLabels.pop() ?: firFunctionCalls.lastOrNull()?.calleeReference?.name?.let { FirLabelImpl(this@RawFirBuilder.session, expression, it.asString()) } val bodyExpression = literal.bodyExpression.toFirExpression("Lambda has no body") - if (bodyExpression is FirBlockImpl) { + body = if (bodyExpression is FirBlockImpl) { if (bodyExpression.statements.isEmpty()) { bodyExpression.statements.add(FirUnitExpression(this@RawFirBuilder.session, expression)) } @@ -684,8 +684,10 @@ class RawFirBuilder(val session: FirSession, val stubMode: Boolean) { bodyExpression.statements.add(index, statement) } } + bodyExpression + } else { + FirSingleExpressionBlock(this@RawFirBuilder.session, bodyExpression.toReturn()) } - body = FirSingleExpressionBlock(this@RawFirBuilder.session, bodyExpression.toReturn()) firFunctions.removeLast() } diff --git a/compiler/fir/psi2fir/testData/rawBuilder/expressions/lambda.txt b/compiler/fir/psi2fir/testData/rawBuilder/expressions/lambda.txt index b87676a4d26..f5c9fc3b97e 100644 --- a/compiler/fir/psi2fir/testData/rawBuilder/expressions/lambda.txt +++ b/compiler/fir/psi2fir/testData/rawBuilder/expressions/lambda.txt @@ -16,86 +16,62 @@ FILE: lambda.kt } public? final? fun foo(): Int { lval l1: = fun .(t: Tuple): { - ^ { - lval x: = t#.x# - lval y: = t#.y# - x#.plus#(y#) - } - + lval x: = t#.x# + lval y: = t#.y# + x#.plus#(y#) } use#( = use@fun .(: ): { - ^ { - lval x: = #.component1() - lval y: = #.component2() - x#.plus#(y#) - } - + lval x: = #.component1() + lval y: = #.component2() + x#.plus#(y#) } ) ^foo use#( = use@fun .(): { - ^ { - when () { - ==(it#.x#, Int(0)) -> { - ^foo Int(0) - } - else -> { - } + when () { + ==(it#.x#, Int(0)) -> { + ^foo Int(0) + } + else -> { } - - ^@use it#.y# } + ^@use it#.y# } ) } public? final? fun bar(): Int { ^bar use#( = lambda@fun .(): { - ^ { - when () { - ==(it#.x#, Int(0)) -> { - ^bar Int(0) - } - else -> { - } + when () { + ==(it#.x#, Int(0)) -> { + ^bar Int(0) + } + else -> { } - - ^@lambda it#.y# } + ^@lambda it#.y# } ) } public? final? fun test(list: List): kotlin/Unit { lval map: = mutableMapOf#() list#.forEach#( = forEach@fun .(): { - ^ { - lval : = map#.getOrPut#(it#, getOrPut@fun .(): { - ^ { - mutableListOf#() - } - - } - ) - # += String() + lval : = map#.getOrPut#(it#, getOrPut@fun .(): { + mutableListOf#() } - + ) + # += String() } ) } public? final? val simple: = fun .(): { - ^ { - Unit - } - + Unit } public? get(): public? final? val another: = fun .(): { - ^ { - Int(42) - } - + Int(42) } public? get(): diff --git a/compiler/fir/psi2fir/testData/rawBuilder/expressions/these.txt b/compiler/fir/psi2fir/testData/rawBuilder/expressions/these.txt index 9b9a9fd06f8..09ff96cf3ee 100644 --- a/compiler/fir/psi2fir/testData/rawBuilder/expressions/these.txt +++ b/compiler/fir/psi2fir/testData/rawBuilder/expressions/these.txt @@ -27,10 +27,7 @@ FILE: these.kt } public? final? fun test(some: Some): Int { ^test with#(some#, = with@fun .(): { - ^ { - this#.foo#().plus#(this@with.extension#()) - } - + this#.foo#().plus#(this@with.extension#()) } ) }