From cca6ba38bec2b7a08de38f8a8a240bb4e8c1742f Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 9 Jan 2019 18:50:37 +0100 Subject: [PATCH] Add tests for obsolete codegen issues #KT-16790 Obsolete #KT-16858 Obsolete #KT-17441 Obsolete --- .../objectExtendsLocal_kt16858.kt | 6 ++++++ .../localClasses/anonymousObjectInExtension.kt | 14 ++++++++++++++ .../codegen/box/sam/constructors/kt16790.kt | 15 +++++++++++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 15 +++++++++++++++ .../codegen/LightAnalysisModeTestGenerated.java | 15 +++++++++++++++ .../ir/IrBlackBoxCodegenTestGenerated.java | 15 +++++++++++++++ .../semantics/IrJsCodegenBoxTestGenerated.java | 10 ++++++++++ .../test/semantics/JsCodegenBoxTestGenerated.java | 10 ++++++++++ 8 files changed, 100 insertions(+) create mode 100644 compiler/testData/codegen/box/innerNested/superConstructorCall/objectExtendsLocal_kt16858.kt create mode 100644 compiler/testData/codegen/box/localClasses/anonymousObjectInExtension.kt create mode 100644 compiler/testData/codegen/box/sam/constructors/kt16790.kt diff --git a/compiler/testData/codegen/box/innerNested/superConstructorCall/objectExtendsLocal_kt16858.kt b/compiler/testData/codegen/box/innerNested/superConstructorCall/objectExtendsLocal_kt16858.kt new file mode 100644 index 00000000000..34cca882b86 --- /dev/null +++ b/compiler/testData/codegen/box/innerNested/superConstructorCall/objectExtendsLocal_kt16858.kt @@ -0,0 +1,6 @@ +open class A(val a: String, val b: Int) + +fun box(): String { + val o = object : A(b = 2, a = "OK") {} + return o.a +} diff --git a/compiler/testData/codegen/box/localClasses/anonymousObjectInExtension.kt b/compiler/testData/codegen/box/localClasses/anonymousObjectInExtension.kt new file mode 100644 index 00000000000..0eb1d3217a4 --- /dev/null +++ b/compiler/testData/codegen/box/localClasses/anonymousObjectInExtension.kt @@ -0,0 +1,14 @@ +// IGNORE_BACKEND: JVM_IR, JS_IR + +fun WithCompanion.test(): String { + object : WithCompanion(this) {} + return "OK" +} + +open class WithCompanion(a: WithCompanion.Companion) { + companion object +} + +fun box(): String { + return WithCompanion(WithCompanion.Companion).test() +} diff --git a/compiler/testData/codegen/box/sam/constructors/kt16790.kt b/compiler/testData/codegen/box/sam/constructors/kt16790.kt new file mode 100644 index 00000000000..716b04f498b --- /dev/null +++ b/compiler/testData/codegen/box/sam/constructors/kt16790.kt @@ -0,0 +1,15 @@ +// TARGET_BACKEND: JVM +// IGNORE_BACKEND: JVM_IR +// SKIP_JDK6 +// FULL_JDK + +import java.util.function.Supplier + +open class Base(val supplier: Supplier) + +object Extended : Base(Supplier { 32 }) + +fun box(): String { + val blam = Extended + return if (blam.supplier.get() == 32) "OK" else "Fail" +} diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index e2a2119ed21..93955ae0a0e 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -13149,6 +13149,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/innerNested/superConstructorCall/objectExtendsLocalWithClosure.kt"); } + @TestMetadata("objectExtendsLocal_kt16858.kt") + public void testObjectExtendsLocal_kt16858() throws Exception { + runTest("compiler/testData/codegen/box/innerNested/superConstructorCall/objectExtendsLocal_kt16858.kt"); + } + @TestMetadata("objectOuterDiffersFromInnerOuter.kt") public void testObjectOuterDiffersFromInnerOuter() throws Exception { runTest("compiler/testData/codegen/box/innerNested/superConstructorCall/objectOuterDiffersFromInnerOuter.kt"); @@ -14880,6 +14885,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/localClasses"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); } + @TestMetadata("anonymousObjectInExtension.kt") + public void testAnonymousObjectInExtension() throws Exception { + runTest("compiler/testData/codegen/box/localClasses/anonymousObjectInExtension.kt"); + } + @TestMetadata("anonymousObjectInInitializer.kt") public void testAnonymousObjectInInitializer() throws Exception { runTest("compiler/testData/codegen/box/localClasses/anonymousObjectInInitializer.kt"); @@ -22351,6 +22361,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/sam/constructors/filenameFilter.kt"); } + @TestMetadata("kt16790.kt") + public void testKt16790() throws Exception { + runTest("compiler/testData/codegen/box/sam/constructors/kt16790.kt"); + } + @TestMetadata("kt19251.kt") public void testKt19251() throws Exception { runTest("compiler/testData/codegen/box/sam/constructors/kt19251.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index d9ae3206154..56d88894947 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -13149,6 +13149,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/innerNested/superConstructorCall/objectExtendsLocalWithClosure.kt"); } + @TestMetadata("objectExtendsLocal_kt16858.kt") + public void testObjectExtendsLocal_kt16858() throws Exception { + runTest("compiler/testData/codegen/box/innerNested/superConstructorCall/objectExtendsLocal_kt16858.kt"); + } + @TestMetadata("objectOuterDiffersFromInnerOuter.kt") public void testObjectOuterDiffersFromInnerOuter() throws Exception { runTest("compiler/testData/codegen/box/innerNested/superConstructorCall/objectOuterDiffersFromInnerOuter.kt"); @@ -14895,6 +14900,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/localClasses"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); } + @TestMetadata("anonymousObjectInExtension.kt") + public void testAnonymousObjectInExtension() throws Exception { + runTest("compiler/testData/codegen/box/localClasses/anonymousObjectInExtension.kt"); + } + @TestMetadata("anonymousObjectInInitializer.kt") public void testAnonymousObjectInInitializer() throws Exception { runTest("compiler/testData/codegen/box/localClasses/anonymousObjectInInitializer.kt"); @@ -22351,6 +22361,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/sam/constructors/filenameFilter.kt"); } + @TestMetadata("kt16790.kt") + public void testKt16790() throws Exception { + runTest("compiler/testData/codegen/box/sam/constructors/kt16790.kt"); + } + @TestMetadata("kt19251.kt") public void testKt19251() throws Exception { runTest("compiler/testData/codegen/box/sam/constructors/kt19251.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 0e3e072c15d..f245613e46c 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -13154,6 +13154,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/innerNested/superConstructorCall/objectExtendsLocalWithClosure.kt"); } + @TestMetadata("objectExtendsLocal_kt16858.kt") + public void testObjectExtendsLocal_kt16858() throws Exception { + runTest("compiler/testData/codegen/box/innerNested/superConstructorCall/objectExtendsLocal_kt16858.kt"); + } + @TestMetadata("objectOuterDiffersFromInnerOuter.kt") public void testObjectOuterDiffersFromInnerOuter() throws Exception { runTest("compiler/testData/codegen/box/innerNested/superConstructorCall/objectOuterDiffersFromInnerOuter.kt"); @@ -14885,6 +14890,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/localClasses"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true); } + @TestMetadata("anonymousObjectInExtension.kt") + public void testAnonymousObjectInExtension() throws Exception { + runTest("compiler/testData/codegen/box/localClasses/anonymousObjectInExtension.kt"); + } + @TestMetadata("anonymousObjectInInitializer.kt") public void testAnonymousObjectInInitializer() throws Exception { runTest("compiler/testData/codegen/box/localClasses/anonymousObjectInInitializer.kt"); @@ -22356,6 +22366,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/sam/constructors/filenameFilter.kt"); } + @TestMetadata("kt16790.kt") + public void testKt16790() throws Exception { + runTest("compiler/testData/codegen/box/sam/constructors/kt16790.kt"); + } + @TestMetadata("kt19251.kt") public void testKt19251() throws Exception { runTest("compiler/testData/codegen/box/sam/constructors/kt19251.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java index c6ab9c1f290..42c00650678 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java @@ -10694,6 +10694,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/innerNested/superConstructorCall/objectExtendsLocalWithClosure.kt"); } + @TestMetadata("objectExtendsLocal_kt16858.kt") + public void testObjectExtendsLocal_kt16858() throws Exception { + runTest("compiler/testData/codegen/box/innerNested/superConstructorCall/objectExtendsLocal_kt16858.kt"); + } + @TestMetadata("objectOuterDiffersFromInnerOuter.kt") public void testObjectOuterDiffersFromInnerOuter() throws Exception { runTest("compiler/testData/codegen/box/innerNested/superConstructorCall/objectOuterDiffersFromInnerOuter.kt"); @@ -11465,6 +11470,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/localClasses"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS_IR, true); } + @TestMetadata("anonymousObjectInExtension.kt") + public void testAnonymousObjectInExtension() throws Exception { + runTest("compiler/testData/codegen/box/localClasses/anonymousObjectInExtension.kt"); + } + @TestMetadata("anonymousObjectInInitializer.kt") public void testAnonymousObjectInInitializer() throws Exception { runTest("compiler/testData/codegen/box/localClasses/anonymousObjectInInitializer.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 52d809421c6..cbe23ffd244 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -11739,6 +11739,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/innerNested/superConstructorCall/objectExtendsLocalWithClosure.kt"); } + @TestMetadata("objectExtendsLocal_kt16858.kt") + public void testObjectExtendsLocal_kt16858() throws Exception { + runTest("compiler/testData/codegen/box/innerNested/superConstructorCall/objectExtendsLocal_kt16858.kt"); + } + @TestMetadata("objectOuterDiffersFromInnerOuter.kt") public void testObjectOuterDiffersFromInnerOuter() throws Exception { runTest("compiler/testData/codegen/box/innerNested/superConstructorCall/objectOuterDiffersFromInnerOuter.kt"); @@ -12510,6 +12515,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/localClasses"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true); } + @TestMetadata("anonymousObjectInExtension.kt") + public void testAnonymousObjectInExtension() throws Exception { + runTest("compiler/testData/codegen/box/localClasses/anonymousObjectInExtension.kt"); + } + @TestMetadata("anonymousObjectInInitializer.kt") public void testAnonymousObjectInInitializer() throws Exception { runTest("compiler/testData/codegen/box/localClasses/anonymousObjectInInitializer.kt");