[BE JVM] KT-51352 Do not mix extension and context receivers in suspends

This commit is contained in:
Anastasia.Shadrina
2022-02-17 21:48:42 +07:00
committed by teamcity
parent 47f0a84c7a
commit 4bc7b0c366
4 changed files with 52 additions and 0 deletions
@@ -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 {
@@ -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)
@@ -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
}
@@ -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 {