[BE JVM] KT-51352 Do not mix extension and context receivers in suspends
This commit is contained in:
committed by
teamcity
parent
47f0a84c7a
commit
4bc7b0c366
+6
@@ -16584,6 +16584,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/extensionFunctions/contextReceivers/simpleCall.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suspendContextualWithExtension.kt")
|
||||
public void testSuspendContextualWithExtension() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/extensionFunctions/contextReceivers/suspendContextualWithExtension.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("this.kt")
|
||||
public void testThis() throws Exception {
|
||||
|
||||
+1
@@ -402,6 +402,7 @@ private fun IrSimpleFunction.createSuspendFunctionStub(context: JvmBackendContex
|
||||
|
||||
function.annotations += annotations
|
||||
function.metadata = metadata
|
||||
function.contextReceiverParametersCount = contextReceiverParametersCount
|
||||
|
||||
function.copyAttributes(this)
|
||||
function.copyTypeParametersFrom(this)
|
||||
|
||||
Vendored
+39
@@ -0,0 +1,39 @@
|
||||
// !LANGUAGE: +ContextReceivers
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_COROUTINES
|
||||
// WITH_STDLIB
|
||||
// FIR status: context receivers aren't yet supported
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
import kotlin.coroutines.intrinsics.*
|
||||
|
||||
class Context {
|
||||
fun c() = "O"
|
||||
}
|
||||
|
||||
class Extension {
|
||||
fun e() = "K"
|
||||
}
|
||||
|
||||
context(Context)
|
||||
suspend fun Extension.suspendingTest() = c() + e()
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var result = "fail"
|
||||
|
||||
builder {
|
||||
with(Extension()) {
|
||||
with(Context()) {
|
||||
result = suspendingTest()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
+6
@@ -16584,6 +16584,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/extensionFunctions/contextReceivers/simpleCall.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suspendContextualWithExtension.kt")
|
||||
public void testSuspendContextualWithExtension() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/extensionFunctions/contextReceivers/suspendContextualWithExtension.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("this.kt")
|
||||
public void testThis() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user