FIR2IR: make the scope of body of do-while loop transparent

This commit is contained in:
Jinseong Jeon
2020-08-09 22:54:33 -07:00
committed by Mikhail Glukhikh
parent 1b6c4329d2
commit e9659d9c8a
7 changed files with 19 additions and 13 deletions
@@ -604,10 +604,17 @@ class Fir2IrVisitor(
val type =
(statements.lastOrNull() as? FirExpression)?.typeRef?.toIrType() ?: irBuiltIns.unitType
return convertWithOffsets { startOffset, endOffset ->
IrBlockImpl(
startOffset, endOffset, type, origin,
mapToIrStatements().filterNotNull()
)
if (origin == IrStatementOrigin.DO_WHILE_LOOP) {
IrCompositeImpl(
startOffset, endOffset, type, origin,
mapToIrStatements().filterNotNull()
)
} else {
IrBlockImpl(
startOffset, endOffset, type, origin,
mapToIrStatements().filterNotNull()
)
}
}
}
@@ -776,7 +783,7 @@ class Fir2IrVisitor(
).apply {
loopMap[doWhileLoop] = this
label = doWhileLoop.label?.name
body = doWhileLoop.block.convertToIrExpressionOrBlock()
body = doWhileLoop.block.convertToIrExpressionOrBlock(origin)
condition = convertToIrExpression(doWhileLoop.condition)
loopMap.remove(doWhileLoop)
}