KT-53846 Pass context receivers to secondary constructors

This commit is contained in:
Pavel Mikhailovskii
2022-12-09 15:24:56 +00:00
committed by Space Team
parent bd3a28d04d
commit 57ddb9fddf
5 changed files with 31 additions and 2 deletions
@@ -17498,6 +17498,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/extensionFunctions/contextReceivers/kt52373.kt");
}
@Test
@TestMetadata("kt53846.kt")
public void testKt53846() throws Exception {
runTest("compiler/testData/codegen/box/extensionFunctions/contextReceivers/kt53846.kt");
}
@Test
@TestMetadata("overload.kt")
public void testOverload() throws Exception {
@@ -1605,6 +1605,7 @@ open class RawFirBuilder(
isFromEnumClass = owner.hasModifier(ENUM_KEYWORD)
}
dispatchReceiverType = owner.obtainDispatchReceiverForConstructor()
contextReceivers.addAll(convertContextReceivers(owner.contextReceivers))
symbol = FirConstructorSymbol(callableIdForClassConstructor())
delegatedConstructor = buildOrLazyDelegatedConstructorCall(
isThis = isDelegatedCallToThis(),
@@ -1,7 +1,6 @@
// !LANGUAGE: +ContextReceivers
// TARGET_BACKEND: JVM_IR
// IGNORE_BACKEND_K2: JVM_IR, JS_IR
// FIR status: context receivers aren't yet supported
// IGNORE_BACKEND_K2: JS_IR
// WITH_STDLIB
class A(val ok: String)
@@ -0,0 +1,17 @@
// !LANGUAGE: +ContextReceivers
// TARGET_BACKEND: JVM_IR
fun box(): String {
with(Ctx()) {
Foo()
}
return "OK"
}
context(Ctx)
class Foo private constructor(i: Int) {
constructor() : this(1)
}
class Ctx
@@ -17498,6 +17498,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/extensionFunctions/contextReceivers/kt52373.kt");
}
@Test
@TestMetadata("kt53846.kt")
public void testKt53846() throws Exception {
runTest("compiler/testData/codegen/box/extensionFunctions/contextReceivers/kt53846.kt");
}
@Test
@TestMetadata("overload.kt")
public void testOverload() throws Exception {