IC & Coroutines: Unbox inline class parameter of suspend lambda
inside 'create' if 'create' overrides 'create' from BaseContinuationImpl. In other words, unbox the parameter if 'create' accepts only one parameter. #KT-43249 Fixed #KT-43533 Fixed
This commit is contained in:
@@ -35,6 +35,7 @@ import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
||||
import org.jetbrains.kotlin.resolve.isInlineClassType
|
||||
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin
|
||||
@@ -446,12 +447,24 @@ class CoroutineCodegenForLambda private constructor(
|
||||
)
|
||||
} else {
|
||||
if (generateErasedCreate) {
|
||||
load(index, AsmTypes.OBJECT_TYPE)
|
||||
StackValue.coerce(
|
||||
AsmTypes.OBJECT_TYPE, builtIns.nullableAnyType,
|
||||
fieldInfoForCoroutineLambdaParameter.fieldType, fieldInfoForCoroutineLambdaParameter.fieldKotlinType,
|
||||
this
|
||||
)
|
||||
if (parameter.type.isInlineClassType()) {
|
||||
load(cloneIndex, fieldInfoForCoroutineLambdaParameter.ownerType)
|
||||
load(index, AsmTypes.OBJECT_TYPE)
|
||||
StackValue.unboxInlineClass(AsmTypes.OBJECT_TYPE, parameter.type, this)
|
||||
putfield(
|
||||
fieldInfoForCoroutineLambdaParameter.ownerInternalName,
|
||||
fieldInfoForCoroutineLambdaParameter.fieldName,
|
||||
fieldInfoForCoroutineLambdaParameter.fieldType.descriptor
|
||||
)
|
||||
continue
|
||||
} else {
|
||||
load(index, AsmTypes.OBJECT_TYPE)
|
||||
StackValue.coerce(
|
||||
AsmTypes.OBJECT_TYPE, builtIns.nullableAnyType,
|
||||
fieldInfoForCoroutineLambdaParameter.fieldType, fieldInfoForCoroutineLambdaParameter.fieldKotlinType,
|
||||
this
|
||||
)
|
||||
}
|
||||
} else {
|
||||
load(index, fieldInfoForCoroutineLambdaParameter.fieldType)
|
||||
}
|
||||
|
||||
Generated
+15
@@ -7748,6 +7748,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/createMangling.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("createOverride.kt")
|
||||
public void testCreateOverride() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/createOverride.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericOverrideSuspendFun.kt")
|
||||
public void testGenericOverrideSuspendFun() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/genericOverrideSuspendFun.kt");
|
||||
@@ -7970,6 +7975,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resume/createMangling.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("createOverride.kt")
|
||||
public void testCreateOverride() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resume/createOverride.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericOverrideSuspendFun.kt")
|
||||
public void testGenericOverrideSuspendFun() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resume/genericOverrideSuspendFun.kt");
|
||||
@@ -8187,6 +8197,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resumeWithException/createMangling.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("createOverride.kt")
|
||||
public void testCreateOverride() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resumeWithException/createOverride.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericOverrideSuspendFun.kt")
|
||||
public void testGenericOverrideSuspendFun() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resumeWithException/genericOverrideSuspendFun.kt");
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// WITH_RUNTIME
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
|
||||
import kotlin.coroutines.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(Continuation(EmptyCoroutineContext) {
|
||||
it.getOrThrow()
|
||||
})
|
||||
}
|
||||
|
||||
inline class IC(val s: String)
|
||||
|
||||
suspend fun <T> List<T>.onEach(c: suspend (T) -> Unit) {
|
||||
for (e in this) {
|
||||
c(e)
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var res = ""
|
||||
builder {
|
||||
listOf(IC("O"), IC("K")).onEach { res += it.s }
|
||||
}
|
||||
return res
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
// WITH_RUNTIME
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
|
||||
import kotlin.coroutines.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(Continuation(EmptyCoroutineContext) {
|
||||
it.getOrThrow()
|
||||
})
|
||||
}
|
||||
|
||||
inline class IC(val s: String)
|
||||
|
||||
suspend fun <T> List<T>.onEach(c: suspend (T) -> Unit) {
|
||||
for (e in this) {
|
||||
c(e)
|
||||
}
|
||||
}
|
||||
|
||||
var c: Continuation<Any>? = null
|
||||
|
||||
fun box(): String {
|
||||
var res = ""
|
||||
builder {
|
||||
listOf(IC("O"), IC("K")).onEach { res += suspendCoroutine<String> { cont ->
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
c = cont as Continuation<Any>
|
||||
}}
|
||||
}
|
||||
c?.resume("O")
|
||||
c?.resume("K")
|
||||
return res
|
||||
}
|
||||
Vendored
+35
@@ -0,0 +1,35 @@
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
|
||||
import kotlin.coroutines.*
|
||||
import helpers.*
|
||||
|
||||
var result = "FAIL"
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(handleExceptionContinuation {
|
||||
result = it.message!!
|
||||
})
|
||||
}
|
||||
|
||||
inline class IC(val s: String)
|
||||
|
||||
suspend fun <T> List<T>.onEach(c: suspend (T) -> Unit) {
|
||||
for (e in this) {
|
||||
c(e)
|
||||
}
|
||||
}
|
||||
|
||||
var c: Continuation<Any>? = null
|
||||
|
||||
fun box(): String {
|
||||
builder {
|
||||
listOf(IC("O"), IC("K")).onEach { suspendCoroutine<String> { cont ->
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
c = cont as Continuation<Any>
|
||||
}}
|
||||
}
|
||||
c?.resumeWithException(IllegalStateException("OK"))
|
||||
return result
|
||||
}
|
||||
+15
@@ -8518,6 +8518,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/createMangling.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("createOverride.kt")
|
||||
public void testCreateOverride() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/createOverride.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericOverrideSuspendFun.kt")
|
||||
public void testGenericOverrideSuspendFun() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/genericOverrideSuspendFun.kt");
|
||||
@@ -8825,6 +8830,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resume/createMangling.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("createOverride.kt")
|
||||
public void testCreateOverride() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resume/createOverride.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericOverrideSuspendFun.kt")
|
||||
public void testGenericOverrideSuspendFun() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resume/genericOverrideSuspendFun.kt");
|
||||
@@ -9127,6 +9137,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resumeWithException/createMangling.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("createOverride.kt")
|
||||
public void testCreateOverride() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resumeWithException/createOverride.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericOverrideSuspendFun.kt")
|
||||
public void testGenericOverrideSuspendFun() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resumeWithException/genericOverrideSuspendFun.kt");
|
||||
|
||||
+15
@@ -8518,6 +8518,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/createMangling.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("createOverride.kt")
|
||||
public void testCreateOverride() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/createOverride.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericOverrideSuspendFun.kt")
|
||||
public void testGenericOverrideSuspendFun() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/genericOverrideSuspendFun.kt");
|
||||
@@ -8825,6 +8830,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resume/createMangling.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("createOverride.kt")
|
||||
public void testCreateOverride() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resume/createOverride.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericOverrideSuspendFun.kt")
|
||||
public void testGenericOverrideSuspendFun() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resume/genericOverrideSuspendFun.kt");
|
||||
@@ -9127,6 +9137,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resumeWithException/createMangling.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("createOverride.kt")
|
||||
public void testCreateOverride() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resumeWithException/createOverride.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericOverrideSuspendFun.kt")
|
||||
public void testGenericOverrideSuspendFun() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resumeWithException/genericOverrideSuspendFun.kt");
|
||||
|
||||
+15
@@ -7748,6 +7748,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/createMangling.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("createOverride.kt")
|
||||
public void testCreateOverride() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/createOverride.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericOverrideSuspendFun.kt")
|
||||
public void testGenericOverrideSuspendFun() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/genericOverrideSuspendFun.kt");
|
||||
@@ -7970,6 +7975,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resume/createMangling.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("createOverride.kt")
|
||||
public void testCreateOverride() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resume/createOverride.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericOverrideSuspendFun.kt")
|
||||
public void testGenericOverrideSuspendFun() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resume/genericOverrideSuspendFun.kt");
|
||||
@@ -8187,6 +8197,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resumeWithException/createMangling.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("createOverride.kt")
|
||||
public void testCreateOverride() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resumeWithException/createOverride.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericOverrideSuspendFun.kt")
|
||||
public void testGenericOverrideSuspendFun() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resumeWithException/genericOverrideSuspendFun.kt");
|
||||
|
||||
Generated
+15
@@ -6503,6 +6503,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/createMangling.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("createOverride.kt")
|
||||
public void testCreateOverride() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/createOverride.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericOverrideSuspendFun.kt")
|
||||
public void testGenericOverrideSuspendFun() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/genericOverrideSuspendFun.kt");
|
||||
@@ -6725,6 +6730,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resume/createMangling.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("createOverride.kt")
|
||||
public void testCreateOverride() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resume/createOverride.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericOverrideSuspendFun.kt")
|
||||
public void testGenericOverrideSuspendFun() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resume/genericOverrideSuspendFun.kt");
|
||||
@@ -6942,6 +6952,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resumeWithException/createMangling.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("createOverride.kt")
|
||||
public void testCreateOverride() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resumeWithException/createOverride.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericOverrideSuspendFun.kt")
|
||||
public void testGenericOverrideSuspendFun() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resumeWithException/genericOverrideSuspendFun.kt");
|
||||
|
||||
Generated
+15
@@ -6503,6 +6503,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/createMangling.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("createOverride.kt")
|
||||
public void testCreateOverride() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/createOverride.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericOverrideSuspendFun.kt")
|
||||
public void testGenericOverrideSuspendFun() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/genericOverrideSuspendFun.kt");
|
||||
@@ -6725,6 +6730,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resume/createMangling.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("createOverride.kt")
|
||||
public void testCreateOverride() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resume/createOverride.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericOverrideSuspendFun.kt")
|
||||
public void testGenericOverrideSuspendFun() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resume/genericOverrideSuspendFun.kt");
|
||||
@@ -6942,6 +6952,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resumeWithException/createMangling.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("createOverride.kt")
|
||||
public void testCreateOverride() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resumeWithException/createOverride.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericOverrideSuspendFun.kt")
|
||||
public void testGenericOverrideSuspendFun() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resumeWithException/genericOverrideSuspendFun.kt");
|
||||
|
||||
+15
@@ -6503,6 +6503,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/createMangling.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("createOverride.kt")
|
||||
public void testCreateOverride() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/createOverride.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericOverrideSuspendFun.kt")
|
||||
public void testGenericOverrideSuspendFun() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/genericOverrideSuspendFun.kt");
|
||||
@@ -6725,6 +6730,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resume/createMangling.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("createOverride.kt")
|
||||
public void testCreateOverride() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resume/createOverride.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericOverrideSuspendFun.kt")
|
||||
public void testGenericOverrideSuspendFun() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resume/genericOverrideSuspendFun.kt");
|
||||
@@ -6942,6 +6952,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resumeWithException/createMangling.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("createOverride.kt")
|
||||
public void testCreateOverride() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resumeWithException/createOverride.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericOverrideSuspendFun.kt")
|
||||
public void testGenericOverrideSuspendFun() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/inlineClasses/resumeWithException/genericOverrideSuspendFun.kt");
|
||||
|
||||
Reference in New Issue
Block a user