[FIR2IR] Adapt IrActualizer to HMPP modules
Previously it collected actual declaration only from platform module
This commit is contained in:
committed by
Space Team
parent
d4bb740a62
commit
30ea4b6b53
+6
@@ -33142,6 +33142,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/multiplatform/multiModule/getRidOfDoubleBindingInFir2IrLazyProperty.kt");
|
runTest("compiler/testData/codegen/box/multiplatform/multiModule/getRidOfDoubleBindingInFir2IrLazyProperty.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("hmppSimple.kt")
|
||||||
|
public void testHmppSimple() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/multiplatform/multiModule/hmppSimple.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("independentCommonSourceModules.kt")
|
@TestMetadata("independentCommonSourceModules.kt")
|
||||||
public void testIndependentCommonSourceModules() throws Exception {
|
public void testIndependentCommonSourceModules() throws Exception {
|
||||||
|
|||||||
+5
-2
@@ -33,7 +33,10 @@ internal class ExpectActualCollector(private val mainFragment: IrModuleFragment,
|
|||||||
val allActualDeclarations = mutableSetOf<IrDeclaration>()
|
val allActualDeclarations = mutableSetOf<IrDeclaration>()
|
||||||
val typeAliasMap = mutableMapOf<FqName, FqName>() // It's used to link members from expect class that have typealias actual
|
val typeAliasMap = mutableMapOf<FqName, FqName>() // It's used to link members from expect class that have typealias actual
|
||||||
|
|
||||||
ActualClassifiersCollector(actualClassifiers, allActualDeclarations, typeAliasMap).visitModuleFragment(mainFragment, false)
|
val fragmentsWithActuals = (dependentFragments.drop(1) + mainFragment)
|
||||||
|
for (fragment in fragmentsWithActuals) {
|
||||||
|
ActualClassifiersCollector(actualClassifiers, allActualDeclarations, typeAliasMap).visitModuleFragment(fragment, false)
|
||||||
|
}
|
||||||
|
|
||||||
val linkCollector = ClassifiersLinkCollector(this, actualClassifiers)
|
val linkCollector = ClassifiersLinkCollector(this, actualClassifiers)
|
||||||
dependentFragments.forEach { linkCollector.visitModuleFragment(it) }
|
dependentFragments.forEach { linkCollector.visitModuleFragment(it) }
|
||||||
@@ -187,4 +190,4 @@ internal class ExpectActualCollector(private val mainFragment: IrModuleFragment,
|
|||||||
element.acceptChildrenVoid(this)
|
element.acceptChildrenVoid(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
// TARGET_BACKEND: JVM_IR
|
||||||
|
// !LANGUAGE: +MultiPlatformProjects
|
||||||
|
|
||||||
|
// MODULE: common
|
||||||
|
// TARGET_PLATFORM: Common
|
||||||
|
// FILE: common.kt
|
||||||
|
|
||||||
|
expect class A constructor() {
|
||||||
|
fun foo(): String
|
||||||
|
}
|
||||||
|
|
||||||
|
expect class B constructor() {
|
||||||
|
fun bar(): String
|
||||||
|
}
|
||||||
|
|
||||||
|
expect fun func(): String
|
||||||
|
|
||||||
|
expect var prop: String
|
||||||
|
|
||||||
|
fun test_1(): String {
|
||||||
|
val a = A()
|
||||||
|
val b = B()
|
||||||
|
prop = "Set prop in common."
|
||||||
|
return "${func()} $prop ${a.foo()} ${b.bar()}"
|
||||||
|
}
|
||||||
|
|
||||||
|
// MODULE: intermediate()()(common)
|
||||||
|
// TARGET_PLATFORM: Common
|
||||||
|
// FILE: intermediate.kt
|
||||||
|
|
||||||
|
actual fun func(): String = "Actual func."
|
||||||
|
|
||||||
|
actual class B actual constructor() {
|
||||||
|
actual fun bar(): String = "Actual B."
|
||||||
|
}
|
||||||
|
|
||||||
|
expect class C constructor() {
|
||||||
|
fun baz(): String
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test_2(): String {
|
||||||
|
val a = A()
|
||||||
|
val b = B()
|
||||||
|
val c = C()
|
||||||
|
prop = "Set prop in intermediate."
|
||||||
|
return "${func()} $prop ${a.foo()} ${b.bar()} ${c.baz()}"
|
||||||
|
}
|
||||||
|
|
||||||
|
// MODULE: jvm()()(intermediate)
|
||||||
|
// TARGET_PLATFORM: JVM
|
||||||
|
// FILE: main.kt
|
||||||
|
|
||||||
|
actual var prop: String = "!"
|
||||||
|
|
||||||
|
actual class A actual constructor() {
|
||||||
|
actual fun foo(): String = "Actual A."
|
||||||
|
}
|
||||||
|
|
||||||
|
actual class C actual constructor() {
|
||||||
|
actual fun baz(): String = "Actual C."
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val s1 = test_1()
|
||||||
|
if (s1 != "Actual func. Set prop in common. Actual A. Actual B.") return s1
|
||||||
|
val s2 = test_2()
|
||||||
|
if (s2 != "Actual func. Set prop in intermediate. Actual A. Actual B. Actual C.") return s2
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
+6
@@ -33142,6 +33142,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/multiplatform/multiModule/getRidOfDoubleBindingInFir2IrLazyProperty.kt");
|
runTest("compiler/testData/codegen/box/multiplatform/multiModule/getRidOfDoubleBindingInFir2IrLazyProperty.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("hmppSimple.kt")
|
||||||
|
public void testHmppSimple() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/multiplatform/multiModule/hmppSimple.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("independentCommonSourceModules.kt")
|
@TestMetadata("independentCommonSourceModules.kt")
|
||||||
public void testIndependentCommonSourceModules() throws Exception {
|
public void testIndependentCommonSourceModules() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user