diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/FakeOverrideGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/FakeOverrideGenerator.kt index d1c2427109f..87b5f959c46 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/FakeOverrideGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/FakeOverrideGenerator.kt @@ -99,7 +99,10 @@ class FakeOverrideGenerator( if (none { it is IrProperty }) { FirSyntheticPropertiesScope.createIfSyntheticNamesProviderIsDefined(session, firClass.defaultType(), useSiteMemberScope)?.let { generateFakeOverridesForName( - irClass, it, name, firClass, this, + irClass, it, name, firClass, + // We pass result = null so that the IR declaration is not added to the class' list of declarations + // but is still cached in the declaration storage. + result = null, // This parameter is only needed for data-class methods that is irrelevant for lazy library classes realDeclarationSymbols = emptySet() ) @@ -120,7 +123,7 @@ class FakeOverrideGenerator( useSiteOrStaticScope: FirScope, name: Name, firClass: FirClass, - result: MutableList, + result: MutableList?, realDeclarationSymbols: Set> ) { val isLocal = firClass !is FirRegularClass || firClass.isLocal @@ -239,7 +242,7 @@ class FakeOverrideGenerator( createIrDeclaration: (firDeclaration: D, irParent: IrClass, thisReceiverOwner: IrClass?, origin: IrDeclarationOrigin, isLocal: Boolean) -> I, createFakeOverrideSymbol: (firDeclaration: D, baseSymbol: S) -> S, baseSymbols: MutableMap>, - result: MutableList, + result: MutableList?, containsErrorTypes: (I) -> Boolean, realDeclarationSymbols: Set>, computeDirectOverridden: FirTypeScope.(S) -> List, @@ -295,7 +298,8 @@ class FakeOverrideGenerator( return } baseSymbols[irDeclaration] = baseFirSymbolsForFakeOverride - result += irDeclaration + + result?.add(irDeclaration) } private inline fun > createFirFakeOverride( diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java index ffcfb8a5915..3f539bc455a 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java @@ -33429,6 +33429,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr runTest("compiler/testData/codegen/box/multiplatform/kt59613.kt"); } + @Test + @TestMetadata("kt60854.kt") + public void testKt60854() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/kt60854.kt"); + } + @Test @TestMetadata("noArgActualConstructor.kt") public void testNoArgActualConstructor() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java index 3a0b215a01d..9d0545ac9c4 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java @@ -33429,6 +33429,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo runTest("compiler/testData/codegen/box/multiplatform/kt59613.kt"); } + @Test + @TestMetadata("kt60854.kt") + public void testKt60854() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/kt60854.kt"); + } + @Test @TestMetadata("noArgActualConstructor.kt") public void testNoArgActualConstructor() throws Exception { diff --git a/compiler/testData/codegen/box/multiplatform/kt60854.kt b/compiler/testData/codegen/box/multiplatform/kt60854.kt new file mode 100644 index 00000000000..79d117a1a02 --- /dev/null +++ b/compiler/testData/codegen/box/multiplatform/kt60854.kt @@ -0,0 +1,20 @@ +// LANGUAGE: +MultiPlatformProjects +// TARGET_BACKEND: JVM_IR +// IGNORE_BACKEND_K1: ANY +// ISSUE: KT-60854 +// WITH_STDLIB +// FULL_JDK + +// MODULE: common +// FILE: common.kt + +expect open class CancellationException(message: String?) : IllegalStateException + +class TimeoutCancellationException(message: String) : CancellationException(message) + +// MODULE: platform()()(common) +// FILE: platform.kt + +public actual typealias CancellationException = java.util.concurrent.CancellationException + +fun box(): String = "OK" diff --git a/compiler/testData/ir/irText/classes/kt45853.__AX.fir.ir.txt b/compiler/testData/ir/irText/classes/kt45853.__AX.fir.ir.txt index b61887d84df..48b216bece1 100644 --- a/compiler/testData/ir/irText/classes/kt45853.__AX.fir.ir.txt +++ b/compiler/testData/ir/irText/classes/kt45853.__AX.fir.ir.txt @@ -15,16 +15,6 @@ CLASS IR_EXTERNAL_JAVA_DECLARATION_STUB CLASS name:AX modality:ABSTRACT visibili overridden: public abstract fun getA (): @[FlexibleNullability] .X? declared in .X $this: VALUE_PARAMETER FAKE_OVERRIDE name: type:.AX - PROPERTY IR_EXTERNAL_JAVA_DECLARATION_STUB name:a visibility:public modality:OPEN [val] - overridden: - public abstract a: .A? [val] - FUN IR_EXTERNAL_JAVA_DECLARATION_STUB name: visibility:public modality:OPEN <> ($this:.AX) returnType:@[FlexibleNullability] .AX? - annotations: - Override - correspondingProperty: PROPERTY IR_EXTERNAL_JAVA_DECLARATION_STUB name:a visibility:public modality:OPEN [val] - overridden: - public abstract fun (): .A? declared in .A - $this: VALUE_PARAMETER IR_EXTERNAL_JAVA_DECLARATION_STUB name: type:.AX FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:.AX, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .A diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index fe73fcffdb5..7dc9e27a96f 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -33429,6 +33429,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/multiplatform/kt59613.kt"); } + @Test + @TestMetadata("kt60854.kt") + public void testKt60854() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/kt60854.kt"); + } + @Test @TestMetadata("noArgActualConstructor.kt") public void testNoArgActualConstructor() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java index 64062741941..de8e6e260b8 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java @@ -33429,6 +33429,12 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack runTest("compiler/testData/codegen/box/multiplatform/kt59613.kt"); } + @Test + @TestMetadata("kt60854.kt") + public void testKt60854() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/kt60854.kt"); + } + @Test @TestMetadata("noArgActualConstructor.kt") public void testNoArgActualConstructor() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index d08d82b287a..db3f25e6637 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -28466,6 +28466,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/multiplatform/kt59613.kt"); } + @TestMetadata("kt60854.kt") + public void testKt60854() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/kt60854.kt"); + } + @TestMetadata("noArgActualConstructor.kt") public void testNoArgActualConstructor() throws Exception { runTest("compiler/testData/codegen/box/multiplatform/noArgActualConstructor.kt");