Do not generate suspend markers inside callable reference

#KT-41429
 #KT-25519 Fixed
This commit is contained in:
Ilmir Usmanov
2020-09-01 21:02:02 +02:00
parent ccc5b7afe0
commit 4303e8126f
@@ -2690,7 +2690,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> 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<StackValue, StackValue> impleme
}
}
private boolean insideCallableReference() {
return (parentCodegen instanceof ClosureCodegen) &&
((ClosureCodegen) parentCodegen).superClassAsmType.equals(FUNCTION_REFERENCE_IMPL);
}
private void putReceiverAndInlineMarkerIfNeeded(
@NotNull Callable callableMethod,
@NotNull ResolvedCall<?> resolvedCall,