KT-52459 Handle context receivers when generating a bridge
This commit is contained in:
committed by
Space Team
parent
d735fa6567
commit
3704d54101
+6
@@ -17540,6 +17540,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/extensionFunctions/contextReceivers/kt52373.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt52459.kt")
|
||||
public void testKt52459() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/extensionFunctions/contextReceivers/kt52459.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt53846.kt")
|
||||
public void testKt53846() throws Exception {
|
||||
|
||||
+1
@@ -591,6 +591,7 @@ internal class BridgeLowering(val context: JvmBackendContext) : FileLoweringPass
|
||||
} else {
|
||||
from.valueParameters.map { it.copyWithTypeErasure(this, visibleTypeParameters) }
|
||||
}
|
||||
contextReceiverParametersCount = from.contextReceiverParametersCount
|
||||
}
|
||||
|
||||
private fun IrValueParameter.copyWithTypeErasure(
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
// !LANGUAGE: +ContextReceivers
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
|
||||
interface I<T>{
|
||||
context(A)
|
||||
fun T.foo(): String
|
||||
}
|
||||
|
||||
class A(val a: String)
|
||||
class B(val b: String)
|
||||
|
||||
object O: I<B>{
|
||||
context(A)
|
||||
override fun B.foo(): String = this@A.a + this@B.b
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
with(A("O")){
|
||||
with(O as I<B>){
|
||||
return B("K").foo()
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
@@ -17540,6 +17540,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/extensionFunctions/contextReceivers/kt52373.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt52459.kt")
|
||||
public void testKt52459() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/extensionFunctions/contextReceivers/kt52459.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt53846.kt")
|
||||
public void testKt53846() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user