fixup! FIR2IR: do coercion to Unit on when expression branches when needed
diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt
index fd65063..aa444c9 100644
--- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt
+++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt
@@ -1251,6 +1251,8 @@
forceBlockUnitType: Boolean,
coerceWhenToUnitIfPossible: Boolean,
): IrContainerExpression {
+ /** Combination of [forceBlockUnitType] = true and [coerceWhenToUnitIfPossible] = false is not allowed */
+ assert(!forceBlockUnitType || coerceWhenToUnitIfPossible)
val type = if (forceBlockUnitType)
builtins.unitType
else
@@ -1353,6 +1355,10 @@
}
}
+ override fun visitWhenExpression(whenExpression: FirWhenExpression, data: Any?): IrElement {
+ return convertToWhenExpression(whenExpression, coerceToUnitIfPossible = false)
+ }
+
private fun convertToWhenExpression(whenExpression: FirWhenExpression, coerceToUnitIfPossible: Boolean): IrExpression {
val subjectVariable = generateWhenSubjectVariable(whenExpression)
val origin = when (whenExpression.source?.elementType) {