Don't wrap return and error expressions into returns

This commit is contained in:
Michael Bogdanov
2016-10-05 16:31:54 +03:00
committed by Dmitry Petrov
parent 72eb317164
commit 6bd27e52bc
@@ -105,7 +105,12 @@ class BodyGenerator(val scopeOwner: DeclarationDescriptor, override val context:
}
}
private fun IrExpression.wrapWithReturn() = generateReturnExpression(startOffset, endOffset, this)
private fun IrExpression.wrapWithReturn() =
if (this is IrReturn || this is IrErrorExpression || this is IrThrow)
this
else {
generateReturnExpression(startOffset, endOffset, this) }
private fun generateReturnExpression(startOffset: Int, endOffset: Int, returnValue: IrExpression): IrReturnImpl {
val returnTarget = (scopeOwner as? CallableDescriptor) ?: