From 4303e8126f0300f3e4c96c5e9ce42e294fb6245f Mon Sep 17 00:00:00 2001 From: Ilmir Usmanov Date: Tue, 1 Sep 2020 21:02:02 +0200 Subject: [PATCH] Do not generate suspend markers inside callable reference #KT-41429 #KT-25519 Fixed --- .../org/jetbrains/kotlin/codegen/ExpressionCodegen.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index a15a41e157d..8e60ed37c61 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -2690,7 +2690,7 @@ public class ExpressionCodegen extends KtVisitor impleme SuspensionPointKind suspensionPointKind = CoroutineCodegenUtilKt.isSuspensionPoint(resolvedCall, this, state.getLanguageVersionSettings()); - boolean maybeSuspensionPoint = suspensionPointKind != SuspensionPointKind.NEVER; + boolean maybeSuspensionPoint = suspensionPointKind != SuspensionPointKind.NEVER && !insideCallableReference(); boolean isConstructor = resolvedCall.getResultingDescriptor() instanceof ConstructorDescriptor; if (!(callableMethod instanceof IntrinsicWithSpecialReceiver)) { putReceiverAndInlineMarkerIfNeeded(callableMethod, resolvedCall, receiver, maybeSuspensionPoint, isConstructor); @@ -2755,6 +2755,11 @@ public class ExpressionCodegen extends KtVisitor impleme } } + private boolean insideCallableReference() { + return (parentCodegen instanceof ClosureCodegen) && + ((ClosureCodegen) parentCodegen).superClassAsmType.equals(FUNCTION_REFERENCE_IMPL); + } + private void putReceiverAndInlineMarkerIfNeeded( @NotNull Callable callableMethod, @NotNull ResolvedCall resolvedCall,