[devirtualization] Fixed bug with handling empty IrBlock
This commit is contained in:
+23
-19
@@ -1729,26 +1729,30 @@ internal object Devirtualization {
|
|||||||
|
|
||||||
is IrBlock -> {
|
is IrBlock -> {
|
||||||
val statements = expression.statements
|
val statements = expression.statements
|
||||||
val lastStatement = statements.last() as IrExpression
|
if (statements.isEmpty())
|
||||||
val foldedLastStatement = fold(lastStatement, coercion, cast, transformRecursively)
|
PossiblyFoldedExpression(expression, false)
|
||||||
statements.transform {
|
else {
|
||||||
if (it == lastStatement)
|
val lastStatement = statements.last() as IrExpression
|
||||||
foldedLastStatement.expression
|
val foldedLastStatement = fold(lastStatement, coercion, cast, transformRecursively)
|
||||||
else
|
statements.transform {
|
||||||
it.transformIfAsked()
|
if (it == lastStatement)
|
||||||
|
foldedLastStatement.expression
|
||||||
|
else
|
||||||
|
it.transformIfAsked()
|
||||||
|
}
|
||||||
|
val transformedBlock =
|
||||||
|
if (!foldedLastStatement.folded)
|
||||||
|
expression
|
||||||
|
else with(expression) {
|
||||||
|
IrBlockImpl(
|
||||||
|
startOffset = startOffset,
|
||||||
|
endOffset = endOffset,
|
||||||
|
type = coercion.type,
|
||||||
|
origin = origin,
|
||||||
|
statements = statements)
|
||||||
|
}
|
||||||
|
PossiblyFoldedExpression(transformedBlock, foldedLastStatement.folded)
|
||||||
}
|
}
|
||||||
val transformedBlock =
|
|
||||||
if (!foldedLastStatement.folded)
|
|
||||||
expression
|
|
||||||
else with(expression) {
|
|
||||||
IrBlockImpl(
|
|
||||||
startOffset = startOffset,
|
|
||||||
endOffset = endOffset,
|
|
||||||
type = coercion.type,
|
|
||||||
origin = origin,
|
|
||||||
statements = statements)
|
|
||||||
}
|
|
||||||
PossiblyFoldedExpression(transformedBlock, foldedLastStatement.folded)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
is IrWhen -> {
|
is IrWhen -> {
|
||||||
|
|||||||
Reference in New Issue
Block a user