Do not generate ACONST_NULL as continuation of crossinline suspend lambda

This commit is contained in:
Ilmir Usmanov
2018-03-01 17:50:18 +03:00
parent 6b7173ba13
commit 81f3e39f29
7 changed files with 76 additions and 2 deletions
@@ -1103,7 +1103,11 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
if (closure.isSuspend()) {
// resultContinuation
if (closure.isSuspendLambda()) {
v.aconst(null);
boolean isCrossinlineLambda = (callGenerator instanceof InlineCodegen<?>) &&
Objects.requireNonNull(((InlineCodegen) callGenerator).getActiveLambda()).isCrossInline;
if (!isCrossinlineLambda) {
v.aconst(null);
}
}
else {
assert context.getFunctionDescriptor().isSuspend() : "Coroutines closure must be created only inside suspend functions";
@@ -87,7 +87,7 @@ abstract class InlineCodegen<out T: BaseExpressionCodegen>(
protected val expressionMap = linkedMapOf<Int, LambdaInfo>()
protected var activeLambda: LambdaInfo? = null
var activeLambda: LambdaInfo? = null; protected set
private val defaultSourceMapper = sourceCompiler.lazySourceMapper