KT-52791 Make it possible to pass multiple context receivers to a class

This commit is contained in:
Pavel Mikhailovskii
2022-12-28 11:21:03 +00:00
committed by Space Team
parent 62217b39ec
commit 906c161068
38 changed files with 180 additions and 516 deletions
@@ -133,19 +133,13 @@ internal class ClassMemberGenerator(
val thisParameter =
conversionScope.dispatchReceiverParameter(irClass) ?: error("No found this parameter for $irClass")
val receiver = IrGetValueImpl(
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
thisParameter.type,
thisParameter.symbol,
)
for (index in containingClass.contextReceivers.indices) {
val irValueParameter = valueParameters[index]
body.statements.add(
IrSetFieldImpl(
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
contextReceiverFields[index].symbol,
receiver,
IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, thisParameter.type, thisParameter.symbol),
IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, irValueParameter.type, irValueParameter.symbol),
components.irBuiltIns.unitType,
)
@@ -17215,6 +17215,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/extensionClasses/generics.kt");
}
@Test
@TestMetadata("multiple.kt")
public void testMultiple() throws Exception {
runTest("compiler/testData/codegen/box/extensionClasses/multiple.kt");
}
@Test
@TestMetadata("propertyWithContext.kt")
public void testPropertyWithContext() throws Exception {
@@ -859,6 +859,12 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest {
runTest("compiler/testData/ir/irText/declarations/contextReceivers/iteratorOperator.kt");
}
@Test
@TestMetadata("kt52791.kt")
public void testKt52791() throws Exception {
runTest("compiler/testData/ir/irText/declarations/contextReceivers/kt52791.kt");
}
@Test
@TestMetadata("lazy.kt")
public void testLazy() throws Exception {
@@ -859,6 +859,12 @@ public class LightTreeFir2IrTextTestGenerated extends AbstractLightTreeFir2IrTex
runTest("compiler/testData/ir/irText/declarations/contextReceivers/iteratorOperator.kt");
}
@Test
@TestMetadata("kt52791.kt")
public void testKt52791() throws Exception {
runTest("compiler/testData/ir/irText/declarations/contextReceivers/kt52791.kt");
}
@Test
@TestMetadata("lazy.kt")
public void testLazy() throws Exception {