JVM_IR: mark direct uses of inline lambdas as conditionally suspend
They may or may not be inlined later. IDK how the test passes when both modules are compiled with the old backend - perhaps this has something to do with the fact that when `f` is compiled with the IR backend, the call to `x()` is followed by `pop` and `getstatic kotlin/Unit.INSTANCE`? This is probably why the original issue in kotlinx.coroutines reports that everything works fine with kotlinx-coroutines-core:1.4.3. ^KT-46879 Fixed ^KT-48801 Fixed
This commit is contained in:
+5
-3
@@ -109,9 +109,11 @@ class IrInlineCodegen(
|
||||
ValueKind.DEFAULT_INLINE_PARAMETER
|
||||
else
|
||||
ValueKind.DEFAULT_PARAMETER
|
||||
// TODO ValueKind.NON_INLINEABLE_ARGUMENT_FOR_INLINE_PARAMETER_CALLED_IN_SUSPEND?
|
||||
isInlineParameter && irValueParameter.type.isSuspendFunctionTypeOrSubtype() ->
|
||||
ValueKind.NON_INLINEABLE_ARGUMENT_FOR_INLINE_SUSPEND_PARAMETER
|
||||
isInlineParameter && irValueParameter.type.isSuspendFunction() ->
|
||||
if (argumentExpression.isReadOfInlineLambda())
|
||||
ValueKind.NON_INLINEABLE_ARGUMENT_FOR_INLINE_PARAMETER_CALLED_IN_SUSPEND
|
||||
else
|
||||
ValueKind.NON_INLINEABLE_ARGUMENT_FOR_INLINE_SUSPEND_PARAMETER
|
||||
else ->
|
||||
ValueKind.GENERAL
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ fun IrFunction.getJvmVisibilityOfDefaultArgumentStub() =
|
||||
if (DescriptorVisibilities.isPrivate(visibility) || isInlineOnly()) JavaDescriptorVisibilities.PACKAGE_VISIBILITY else DescriptorVisibilities.PUBLIC
|
||||
|
||||
fun IrValueParameter.isInlineParameter() =
|
||||
index >= 0 && !isNoinline && (type.isFunction() || type.isSuspendFunctionTypeOrSubtype()) &&
|
||||
index >= 0 && !isNoinline && (type.isFunction() || type.isSuspendFunction()) &&
|
||||
// Parameters with default values are always nullable, so check the expression too.
|
||||
// Note that the frontend has a diagnostic for nullable inline parameters, so actually
|
||||
// making this return `false` requires using `@Suppress`.
|
||||
|
||||
Reference in New Issue
Block a user