[IrActualizer] Don't actualize expect types

This was never semantically correct, but was not important
before KT-63644, as they were immediately dropped after that anyway.

After KT-63644, they were used to compute fake overrides inside them,
which were later matched against actual class, which can
produce false-positive matching errors.

^KT-64835
This commit is contained in:
Pavel Kunyavskiy
2024-01-09 10:23:34 +01:00
committed by Space Team
parent cf3672314a
commit 9374cacdd6
12 changed files with 88 additions and 0 deletions
@@ -35313,6 +35313,12 @@ public class LLFirBlackBoxCodegenBasedTestGenerated extends AbstractLLFirBlackBo
runTest("compiler/testData/codegen/box/multiplatform/k2/anonymousObjectAndSpecificImplementationInDeserializedIr.kt");
}
@Test
@TestMetadata("covariantOverrideInActual.kt")
public void testCovariantOverrideInActual() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/covariantOverrideInActual.kt");
}
@Test
@TestMetadata("dataClassInCommonAndPlatform.kt")
public void testDataClassInCommonAndPlatform() throws Exception {
@@ -35313,6 +35313,12 @@ public class LLFirReversedBlackBoxCodegenBasedTestGenerated extends AbstractLLFi
runTest("compiler/testData/codegen/box/multiplatform/k2/anonymousObjectAndSpecificImplementationInDeserializedIr.kt");
}
@Test
@TestMetadata("covariantOverrideInActual.kt")
public void testCovariantOverrideInActual() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/covariantOverrideInActual.kt");
}
@Test
@TestMetadata("dataClassInCommonAndPlatform.kt")
public void testDataClassInCommonAndPlatform() throws Exception {
@@ -34898,6 +34898,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr
runTest("compiler/testData/codegen/box/multiplatform/k2/anonymousObjectAndSpecificImplementationInDeserializedIr.kt");
}
@Test
@TestMetadata("covariantOverrideInActual.kt")
public void testCovariantOverrideInActual() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/covariantOverrideInActual.kt");
}
@Test
@TestMetadata("dataClassInCommonAndPlatform.kt")
public void testDataClassInCommonAndPlatform() throws Exception {
@@ -34898,6 +34898,12 @@ public class FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated
runTest("compiler/testData/codegen/box/multiplatform/k2/anonymousObjectAndSpecificImplementationInDeserializedIr.kt");
}
@Test
@TestMetadata("covariantOverrideInActual.kt")
public void testCovariantOverrideInActual() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/covariantOverrideInActual.kt");
}
@Test
@TestMetadata("dataClassInCommonAndPlatform.kt")
public void testDataClassInCommonAndPlatform() throws Exception {
@@ -34898,6 +34898,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo
runTest("compiler/testData/codegen/box/multiplatform/k2/anonymousObjectAndSpecificImplementationInDeserializedIr.kt");
}
@Test
@TestMetadata("covariantOverrideInActual.kt")
public void testCovariantOverrideInActual() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/covariantOverrideInActual.kt");
}
@Test
@TestMetadata("dataClassInCommonAndPlatform.kt")
public void testDataClassInCommonAndPlatform() throws Exception {
@@ -95,6 +95,7 @@ internal open class ActualizerVisitor(private val symbolRemapper: SymbolRemapper
override fun visitClass(declaration: IrClass) =
declaration.also {
if (declaration.isExpect) return@also
it.superTypes = it.superTypes.map { superType -> superType.remapType() }
it.transformChildren(this, null)
it.transformAnnotations(declaration)
@@ -104,6 +105,7 @@ internal open class ActualizerVisitor(private val symbolRemapper: SymbolRemapper
}
override fun visitSimpleFunction(declaration: IrSimpleFunction) = (visitFunction(declaration) as IrSimpleFunction).also {
if (declaration.isExpect) return@also
it.overriddenSymbols = it.overriddenSymbols.memoryOptimizedMap { symbol ->
symbolRemapper.getReferencedFunction(symbol) as IrSimpleFunctionSymbol
}
@@ -113,6 +115,7 @@ internal open class ActualizerVisitor(private val symbolRemapper: SymbolRemapper
override fun visitFunction(declaration: IrFunction) =
declaration.also {
if (declaration.isExpect) return@also
it.returnType = it.returnType.remapType()
it.transformChildren(this, null)
it.transformAnnotations(declaration)
@@ -120,6 +123,7 @@ internal open class ActualizerVisitor(private val symbolRemapper: SymbolRemapper
override fun visitProperty(declaration: IrProperty) =
declaration.also {
if (declaration.isExpect) return@also
it.transformChildren(this, null)
it.overriddenSymbols = it.overriddenSymbols.memoryOptimizedMap { symbol ->
symbolRemapper.getReferencedProperty(symbol)
@@ -0,0 +1,24 @@
// LANGUAGE: +MultiPlatformProjects
// MODULE: lib-common
// FILE: common.kt
abstract expect class Base
expect class Child : Base
// MODULE: lib()()(lib-common)
// FILE: platform.kt
actual abstract class Base() {
abstract fun foo(): Any
}
actual class Child: Base() {
override fun foo(): String = "OK"
}
fun box(): String {
return Child().foo()
}
@@ -24464,6 +24464,12 @@ public class FirJsCodegenBoxTestGenerated extends AbstractFirJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/multiplatform/k2/anonymousObjectAndSpecificImplementationInDeserializedIr.kt");
}
@Test
@TestMetadata("covariantOverrideInActual.kt")
public void testCovariantOverrideInActual() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/covariantOverrideInActual.kt");
}
@Test
@TestMetadata("dataClassInCommonAndPlatform.kt")
public void testDataClassInCommonAndPlatform() throws Exception {
@@ -24464,6 +24464,12 @@ public class FirJsES6CodegenBoxTestGenerated extends AbstractFirJsES6CodegenBoxT
runTest("compiler/testData/codegen/box/multiplatform/k2/anonymousObjectAndSpecificImplementationInDeserializedIr.kt");
}
@Test
@TestMetadata("covariantOverrideInActual.kt")
public void testCovariantOverrideInActual() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/covariantOverrideInActual.kt");
}
@Test
@TestMetadata("dataClassInCommonAndPlatform.kt")
public void testDataClassInCommonAndPlatform() throws Exception {
@@ -27829,6 +27829,12 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe
runTest("compiler/testData/codegen/box/multiplatform/k2/anonymousObjectAndSpecificImplementationInDeserializedIr.kt");
}
@Test
@TestMetadata("covariantOverrideInActual.kt")
public void testCovariantOverrideInActual() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/covariantOverrideInActual.kt");
}
@Test
@TestMetadata("dataClassInCommonAndPlatform.kt")
public void testDataClassInCommonAndPlatform() throws Exception {
@@ -28461,6 +28461,12 @@ public class FirNativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenB
runTest("compiler/testData/codegen/box/multiplatform/k2/anonymousObjectAndSpecificImplementationInDeserializedIr.kt");
}
@Test
@TestMetadata("covariantOverrideInActual.kt")
public void testCovariantOverrideInActual() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/covariantOverrideInActual.kt");
}
@Test
@TestMetadata("dataClassInCommonAndPlatform.kt")
public void testDataClassInCommonAndPlatform() throws Exception {
@@ -24434,6 +24434,12 @@ public class FirWasmCodegenBoxTestGenerated extends AbstractFirWasmCodegenBoxTes
runTest("compiler/testData/codegen/box/multiplatform/k2/anonymousObjectAndSpecificImplementationInDeserializedIr.kt");
}
@Test
@TestMetadata("covariantOverrideInActual.kt")
public void testCovariantOverrideInActual() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/covariantOverrideInActual.kt");
}
@Test
@TestMetadata("dataClassInCommonAndPlatform.kt")
public void testDataClassInCommonAndPlatform() throws Exception {