From 35caae355da4794b6b9083b08650b3cca997a0d9 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Tue, 16 Jan 2024 18:09:27 +0100 Subject: [PATCH] Tests: minor, add box test for KT-31367/KT-61805 For some reason, codegen box test was not added in 082c337faa. The main point of it now is to check that everything works correctly in the IrFakeOverrideBuilder mode. --- ...LFirBlackBoxCodegenBasedTestGenerated.java | 6 ++++ ...rsedBlackBoxCodegenBasedTestGenerated.java | 6 ++++ ...LightTreeBlackBoxCodegenTestGenerated.java | 6 ++++ ...hIrFakeOverrideGeneratorTestGenerated.java | 6 ++++ .../FirPsiBlackBoxCodegenTestGenerated.java | 6 ++++ .../javaForKotlinOverrideProperty.kt | 32 +++++++++++++++++++ .../JvmAbiConsistencyTestBoxGenerated.java | 6 ++++ .../codegen/BlackBoxCodegenTestGenerated.java | 6 ++++ .../IrBlackBoxCodegenTestGenerated.java | 6 ++++ ...kBoxCodegenWithIrInlinerTestGenerated.java | 6 ++++ .../LightAnalysisModeTestGenerated.java | 5 +++ 11 files changed, 91 insertions(+) create mode 100644 compiler/testData/codegen/box/javaInterop/javaForKotlinOverrideProperty.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 e5445781ff6..f8198f3c5e5 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 @@ -31054,6 +31054,12 @@ public class LLFirBlackBoxCodegenBasedTestGenerated extends AbstractLLFirBlackBo runTest("compiler/testData/codegen/box/javaInterop/inheritanceWithWildcard.kt"); } + @Test + @TestMetadata("javaForKotlinOverrideProperty.kt") + public void testJavaForKotlinOverrideProperty() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/javaForKotlinOverrideProperty.kt"); + } + @Test @TestMetadata("javaInterfaceFieldDirectAccess.kt") public void testJavaInterfaceFieldDirectAccess() throws Exception { 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 9095a159c91..b976dd91643 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 @@ -31054,6 +31054,12 @@ public class LLFirReversedBlackBoxCodegenBasedTestGenerated extends AbstractLLFi runTest("compiler/testData/codegen/box/javaInterop/inheritanceWithWildcard.kt"); } + @Test + @TestMetadata("javaForKotlinOverrideProperty.kt") + public void testJavaForKotlinOverrideProperty() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/javaForKotlinOverrideProperty.kt"); + } + @Test @TestMetadata("javaInterfaceFieldDirectAccess.kt") public void testJavaInterfaceFieldDirectAccess() throws Exception { 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 e0874eae568..b690dc053e5 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 @@ -30703,6 +30703,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr runTest("compiler/testData/codegen/box/javaInterop/inheritanceWithWildcard.kt"); } + @Test + @TestMetadata("javaForKotlinOverrideProperty.kt") + public void testJavaForKotlinOverrideProperty() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/javaForKotlinOverrideProperty.kt"); + } + @Test @TestMetadata("javaInterfaceFieldDirectAccess.kt") public void testJavaInterfaceFieldDirectAccess() throws Exception { 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 68e4dc5e108..f18cc0d1eba 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 @@ -30703,6 +30703,12 @@ public class FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated runTest("compiler/testData/codegen/box/javaInterop/inheritanceWithWildcard.kt"); } + @Test + @TestMetadata("javaForKotlinOverrideProperty.kt") + public void testJavaForKotlinOverrideProperty() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/javaForKotlinOverrideProperty.kt"); + } + @Test @TestMetadata("javaInterfaceFieldDirectAccess.kt") public void testJavaInterfaceFieldDirectAccess() 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 d74f7f73ed1..303c7da385a 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 @@ -30703,6 +30703,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo runTest("compiler/testData/codegen/box/javaInterop/inheritanceWithWildcard.kt"); } + @Test + @TestMetadata("javaForKotlinOverrideProperty.kt") + public void testJavaForKotlinOverrideProperty() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/javaForKotlinOverrideProperty.kt"); + } + @Test @TestMetadata("javaInterfaceFieldDirectAccess.kt") public void testJavaInterfaceFieldDirectAccess() throws Exception { diff --git a/compiler/testData/codegen/box/javaInterop/javaForKotlinOverrideProperty.kt b/compiler/testData/codegen/box/javaInterop/javaForKotlinOverrideProperty.kt new file mode 100644 index 00000000000..79c8323b4f3 --- /dev/null +++ b/compiler/testData/codegen/box/javaInterop/javaForKotlinOverrideProperty.kt @@ -0,0 +1,32 @@ +// TARGET_BACKEND: JVM +// FILE: A.java + +public abstract class A { + public String getValue() { + return "A"; + } +} + +// FILE: I.kt + +interface I { + val value: String? +} + +// FILE: B.java + +public class B extends A implements I {} + +// FILE: C.kt + +class C : B(), I + +fun box(): String { + val c = C() + if (c.value != "A") return "Fail C" + if ((c as B).value != "A") return "Fail B" + if ((c as I).value != "A") return "Fail I" + if ((c as A).value != "A") return "Fail A value" + if ((c as A).getValue() != "A") return "Fail A getValue" + return "OK" +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/JvmAbiConsistencyTestBoxGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/JvmAbiConsistencyTestBoxGenerated.java index 1c16faf44e2..b038f88b1e5 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/JvmAbiConsistencyTestBoxGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/JvmAbiConsistencyTestBoxGenerated.java @@ -30703,6 +30703,12 @@ public class JvmAbiConsistencyTestBoxGenerated extends AbstractJvmAbiConsistency runTest("compiler/testData/codegen/box/javaInterop/inheritanceWithWildcard.kt"); } + @Test + @TestMetadata("javaForKotlinOverrideProperty.kt") + public void testJavaForKotlinOverrideProperty() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/javaForKotlinOverrideProperty.kt"); + } + @Test @TestMetadata("javaInterfaceFieldDirectAccess.kt") public void testJavaInterfaceFieldDirectAccess() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index fa8cd523a08..9a0aff06dc1 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -28993,6 +28993,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/javaInterop/inheritanceWithWildcard.kt"); } + @Test + @TestMetadata("javaForKotlinOverrideProperty.kt") + public void testJavaForKotlinOverrideProperty() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/javaForKotlinOverrideProperty.kt"); + } + @Test @TestMetadata("javaOuterClassDependsOnInner.kt") public void testJavaOuterClassDependsOnInner() throws Exception { 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 01c728bd874..5ddd53dc171 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 @@ -30703,6 +30703,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/javaInterop/inheritanceWithWildcard.kt"); } + @Test + @TestMetadata("javaForKotlinOverrideProperty.kt") + public void testJavaForKotlinOverrideProperty() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/javaForKotlinOverrideProperty.kt"); + } + @Test @TestMetadata("javaInterfaceFieldDirectAccess.kt") public void testJavaInterfaceFieldDirectAccess() 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 34328dff539..e0903e59dac 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 @@ -30703,6 +30703,12 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack runTest("compiler/testData/codegen/box/javaInterop/inheritanceWithWildcard.kt"); } + @Test + @TestMetadata("javaForKotlinOverrideProperty.kt") + public void testJavaForKotlinOverrideProperty() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/javaForKotlinOverrideProperty.kt"); + } + @Test @TestMetadata("javaInterfaceFieldDirectAccess.kt") public void testJavaInterfaceFieldDirectAccess() 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 377d9c3a41d..6d09dfe3645 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -26003,6 +26003,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/javaInterop/inheritanceWithWildcard.kt"); } + @TestMetadata("javaForKotlinOverrideProperty.kt") + public void testJavaForKotlinOverrideProperty() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/javaForKotlinOverrideProperty.kt"); + } + @TestMetadata("javaInterfaceFieldDirectAccess.kt") public void testJavaInterfaceFieldDirectAccess() throws Exception { runTest("compiler/testData/codegen/box/javaInterop/javaInterfaceFieldDirectAccess.kt");