Raw FIR: generate Unit at the end of empty lambda
This commit is contained in:
@@ -669,9 +669,14 @@ class RawFirBuilder(val session: FirSession, val stubMode: Boolean) {
|
|||||||
FirLabelImpl(this@RawFirBuilder.session, expression, it.asString())
|
FirLabelImpl(this@RawFirBuilder.session, expression, it.asString())
|
||||||
}
|
}
|
||||||
val bodyExpression = literal.bodyExpression.toFirExpression("Lambda has no body")
|
val bodyExpression = literal.bodyExpression.toFirExpression("Lambda has no body")
|
||||||
if (destructuringBlock is FirBlock && bodyExpression is FirBlockImpl) {
|
if (bodyExpression is FirBlockImpl) {
|
||||||
for ((index, statement) in destructuringBlock.statements.withIndex()) {
|
if (bodyExpression.statements.isEmpty()) {
|
||||||
bodyExpression.statements.add(index, statement)
|
bodyExpression.statements.add(FirUnitExpression(this@RawFirBuilder.session, expression))
|
||||||
|
}
|
||||||
|
if (destructuringBlock is FirBlock) {
|
||||||
|
for ((index, statement) in destructuringBlock.statements.withIndex()) {
|
||||||
|
bodyExpression.statements.add(index, statement)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
body = FirSingleExpressionBlock(this@RawFirBuilder.session, bodyExpression.toReturn())
|
body = FirSingleExpressionBlock(this@RawFirBuilder.session, bodyExpression.toReturn())
|
||||||
|
|||||||
@@ -26,4 +26,8 @@ fun bar(): Int {
|
|||||||
fun test(list: List<Int>) {
|
fun test(list: List<Int>) {
|
||||||
val map = mutableMapOf<Int, String>()
|
val map = mutableMapOf<Int, String>()
|
||||||
list.forEach { map.getOrPut(it, { mutableListOf() }) += "" }
|
list.forEach { map.getOrPut(it, { mutableListOf() }) += "" }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val simple = { }
|
||||||
|
|
||||||
|
val another = { 42 }
|
||||||
@@ -81,3 +81,19 @@ FILE: lambda.kt
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
public? final? val simple: <implicit> = fun <implicit>.<anonymous>(): <implicit> {
|
||||||
|
^ {
|
||||||
|
Unit
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public? get(): <implicit>
|
||||||
|
public? final? val another: <implicit> = fun <implicit>.<anonymous>(): <implicit> {
|
||||||
|
^ {
|
||||||
|
Int(42)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public? get(): <implicit>
|
||||||
|
|||||||
Reference in New Issue
Block a user