From c6e32571d643d5cc545b281413b3be820595c987 Mon Sep 17 00:00:00 2001 From: Pavel Kunyavskiy Date: Fri, 5 Jan 2024 14:39:39 +0100 Subject: [PATCH] [FakeOverrideBuilder] Workaround KT-64743 Because of KT-64743 there is unexpanded type-alias in a place we don't expect it to occur. To workaround this, we just expand typialiases in one more place. ^KT-64743 --- ...LFirBlackBoxCodegenBasedTestGenerated.java | 6 ++++ ...rsedBlackBoxCodegenBasedTestGenerated.java | 6 ++++ .../generators/FakeOverrideGenerator.kt | 8 ++--- ...LightTreeBlackBoxCodegenTestGenerated.java | 6 ++++ ...hIrFakeOverrideGeneratorTestGenerated.java | 6 ++++ .../FirPsiBlackBoxCodegenTestGenerated.java | 6 ++++ .../multiplatform/k2/aliasSuperTypeInLazy.kt | 33 +++++++++++++++++++ .../fir/FirJsCodegenBoxTestGenerated.java | 6 ++++ .../fir/FirJsES6CodegenBoxTestGenerated.java | 6 ++++ .../FirNativeCodegenBoxTestGenerated.java | 6 ++++ .../FirNativeCodegenBoxTestNoPLGenerated.java | 6 ++++ .../test/FirWasmCodegenBoxTestGenerated.java | 6 ++++ 12 files changed, 96 insertions(+), 5 deletions(-) create mode 100644 compiler/testData/codegen/box/multiplatform/k2/aliasSuperTypeInLazy.kt diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirBlackBoxCodegenBasedTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirBlackBoxCodegenBasedTestGenerated.java index cccd5af4c41..3ff0076ddca 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirBlackBoxCodegenBasedTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirBlackBoxCodegenBasedTestGenerated.java @@ -35278,6 +35278,12 @@ public class LLFirBlackBoxCodegenBasedTestGenerated extends AbstractLLFirBlackBo runTest("compiler/testData/codegen/box/multiplatform/k2/actualInnerClassesFirMemberMapping.kt"); } + @Test + @TestMetadata("aliasSuperTypeInLazy.kt") + public void testAliasSuperTypeInLazy() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/k2/aliasSuperTypeInLazy.kt"); + } + @Test public void testAllFilesPresentInK2() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/multiplatform/k2"), Pattern.compile("^(.+)\\.kt$"), null, true); diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirReversedBlackBoxCodegenBasedTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirReversedBlackBoxCodegenBasedTestGenerated.java index d38572398c9..1dd8ffa7c30 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirReversedBlackBoxCodegenBasedTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirReversedBlackBoxCodegenBasedTestGenerated.java @@ -35278,6 +35278,12 @@ public class LLFirReversedBlackBoxCodegenBasedTestGenerated extends AbstractLLFi runTest("compiler/testData/codegen/box/multiplatform/k2/actualInnerClassesFirMemberMapping.kt"); } + @Test + @TestMetadata("aliasSuperTypeInLazy.kt") + public void testAliasSuperTypeInLazy() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/k2/aliasSuperTypeInLazy.kt"); + } + @Test public void testAllFilesPresentInK2() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/multiplatform/k2"), Pattern.compile("^(.+)\\.kt$"), null, true); 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 0689873c80e..cd332cc30b4 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 @@ -9,10 +9,7 @@ import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.backend.* import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.utils.* -import org.jetbrains.kotlin.fir.resolve.defaultType -import org.jetbrains.kotlin.fir.resolve.isRealOwnerOf -import org.jetbrains.kotlin.fir.resolve.toFirRegularClass -import org.jetbrains.kotlin.fir.resolve.toSymbol +import org.jetbrains.kotlin.fir.resolve.* import org.jetbrains.kotlin.fir.scopes.* import org.jetbrains.kotlin.fir.scopes.impl.FirFakeOverrideGenerator import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag @@ -251,7 +248,8 @@ class FakeOverrideGenerator( if (!compatibleType) { return@mapNotNull null } - symbol to superType.lookupTag + // TODO: it should be already expanded - KT-64743 + symbol to superType.fullyExpandedType(session).lookupTag } } } 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 70d0f17960d..2b64c71eacc 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 @@ -34869,6 +34869,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr runTest("compiler/testData/codegen/box/multiplatform/k2/actualInnerClassesFirMemberMapping.kt"); } + @Test + @TestMetadata("aliasSuperTypeInLazy.kt") + public void testAliasSuperTypeInLazy() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/k2/aliasSuperTypeInLazy.kt"); + } + @Test public void testAllFilesPresentInK2() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/multiplatform/k2"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.java index 1fda41f3840..b577bd31974 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.java @@ -34869,6 +34869,12 @@ public class FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated runTest("compiler/testData/codegen/box/multiplatform/k2/actualInnerClassesFirMemberMapping.kt"); } + @Test + @TestMetadata("aliasSuperTypeInLazy.kt") + public void testAliasSuperTypeInLazy() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/k2/aliasSuperTypeInLazy.kt"); + } + @Test public void testAllFilesPresentInK2() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/multiplatform/k2"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); 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 5be9ff81207..f2ab101d3d3 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 @@ -34869,6 +34869,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo runTest("compiler/testData/codegen/box/multiplatform/k2/actualInnerClassesFirMemberMapping.kt"); } + @Test + @TestMetadata("aliasSuperTypeInLazy.kt") + public void testAliasSuperTypeInLazy() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/k2/aliasSuperTypeInLazy.kt"); + } + @Test public void testAllFilesPresentInK2() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/multiplatform/k2"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); diff --git a/compiler/testData/codegen/box/multiplatform/k2/aliasSuperTypeInLazy.kt b/compiler/testData/codegen/box/multiplatform/k2/aliasSuperTypeInLazy.kt new file mode 100644 index 00000000000..b9c1470b12d --- /dev/null +++ b/compiler/testData/codegen/box/multiplatform/k2/aliasSuperTypeInLazy.kt @@ -0,0 +1,33 @@ +// LANGUAGE: +MultiPlatformProjects +// KT-64776 - test infra problems +// IGNORE_BACKEND: JS, JS_IR, JS_IR_ES6, WASM +// MODULE: dep +// FILE: dep.kt + +open class Base1() { + val prop = "O" + fun foo() = "K" +} +open class Base2 : Base1() + +// MODULE: lib-common(dep) +// FILE: lib-common.kt + + +open expect class BaseAlias() : Base1 + +open class Child: BaseAlias() + +// MODULE: lib-jvm(dep)()(lib-common) +// FILE: lib-jvm.kt + +actual typealias BaseAlias = Base2 + +// MODULE: main(lib-jvm, dep) +// FILE: main.kt + +class InMain : Child() + +fun box() : String { + return InMain().prop + InMain().foo() +} \ No newline at end of file diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java index baaff257673..7dda963ba96 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java @@ -24447,6 +24447,12 @@ public class FirJsCodegenBoxTestGenerated extends AbstractFirJsCodegenBoxTest { runTest("compiler/testData/codegen/box/multiplatform/k2/actualInnerClassesFirMemberMapping.kt"); } + @Test + @TestMetadata("aliasSuperTypeInLazy.kt") + public void testAliasSuperTypeInLazy() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/k2/aliasSuperTypeInLazy.kt"); + } + @Test public void testAllFilesPresentInK2() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/multiplatform/k2"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsES6CodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsES6CodegenBoxTestGenerated.java index 85e36594869..33f60535686 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsES6CodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsES6CodegenBoxTestGenerated.java @@ -24447,6 +24447,12 @@ public class FirJsES6CodegenBoxTestGenerated extends AbstractFirJsES6CodegenBoxT runTest("compiler/testData/codegen/box/multiplatform/k2/actualInnerClassesFirMemberMapping.kt"); } + @Test + @TestMetadata("aliasSuperTypeInLazy.kt") + public void testAliasSuperTypeInLazy() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/k2/aliasSuperTypeInLazy.kt"); + } + @Test public void testAllFilesPresentInK2() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/multiplatform/k2"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestGenerated.java index 57ffc945622..1271277623f 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestGenerated.java @@ -27806,6 +27806,12 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe runTest("compiler/testData/codegen/box/multiplatform/k2/actualInnerClassesFirMemberMapping.kt"); } + @Test + @TestMetadata("aliasSuperTypeInLazy.kt") + public void testAliasSuperTypeInLazy() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/k2/aliasSuperTypeInLazy.kt"); + } + @Test public void testAllFilesPresentInK2() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/multiplatform/k2"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestNoPLGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestNoPLGenerated.java index 33aec944df5..735663685ec 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestNoPLGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestNoPLGenerated.java @@ -28438,6 +28438,12 @@ public class FirNativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenB runTest("compiler/testData/codegen/box/multiplatform/k2/actualInnerClassesFirMemberMapping.kt"); } + @Test + @TestMetadata("aliasSuperTypeInLazy.kt") + public void testAliasSuperTypeInLazy() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/k2/aliasSuperTypeInLazy.kt"); + } + @Test public void testAllFilesPresentInK2() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/multiplatform/k2"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); diff --git a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/FirWasmCodegenBoxTestGenerated.java b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/FirWasmCodegenBoxTestGenerated.java index 9810adc5603..cef1f6d45ff 100644 --- a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/FirWasmCodegenBoxTestGenerated.java +++ b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/FirWasmCodegenBoxTestGenerated.java @@ -24417,6 +24417,12 @@ public class FirWasmCodegenBoxTestGenerated extends AbstractFirWasmCodegenBoxTes runTest("compiler/testData/codegen/box/multiplatform/k2/actualInnerClassesFirMemberMapping.kt"); } + @Test + @TestMetadata("aliasSuperTypeInLazy.kt") + public void testAliasSuperTypeInLazy() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/k2/aliasSuperTypeInLazy.kt"); + } + @Test public void testAllFilesPresentInK2() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/multiplatform/k2"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true);