diff --git a/compiler/testData/codegen/java9/box/kt36984.kt b/compiler/testData/codegen/java9/box/kt36984.kt new file mode 100644 index 00000000000..2d7b725c713 --- /dev/null +++ b/compiler/testData/codegen/java9/box/kt36984.kt @@ -0,0 +1,16 @@ +// TARGET_BACKEND: JVM +// WITH_RUNTIME + +fun box(): String { + val f = {} + val sam = Runnable(f) + val samJavaClass = sam::class.java + + if (samJavaClass.simpleName != "") + throw Exception("samJavaClass.simpleName='${samJavaClass.simpleName}'") + + if (!samJavaClass.isAnonymousClass()) + throw Exception("!samJavaClass.isAnonymousClass(): '${samJavaClass.name}'") + + return "OK" +} \ No newline at end of file diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractJdk9BlackBoxCodegenTest.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractJdk9BlackBoxCodegenTest.kt index 7d61b2af0a5..682f56112a9 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractJdk9BlackBoxCodegenTest.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractJdk9BlackBoxCodegenTest.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.codegen +import org.jetbrains.kotlin.test.TargetBackend import org.jetbrains.kotlin.test.TestJdkKind import org.jetbrains.kotlin.test.util.KtTestUtil import java.io.File @@ -14,3 +15,8 @@ abstract class AbstractJdk9BlackBoxCodegenTest : AbstractCustomJDKBlackBoxCodege override fun getJdkHome(): File = KtTestUtil.getJdk9Home() override fun getPrefix(): String = "java9/box" } + +abstract class AbstractJdk9IrBlackBoxCodegenTest : AbstractJdk9BlackBoxCodegenTest() { + override val backend: TargetBackend + get() = TargetBackend.JVM_IR +} \ No newline at end of file diff --git a/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit3CompilerTests.kt b/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit3CompilerTests.kt index e099bf85ed6..b73af3237a4 100644 --- a/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit3CompilerTests.kt +++ b/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit3CompilerTests.kt @@ -153,6 +153,10 @@ fun generateJUnit3CompilerTests(args: Array) { model("codegen/java9/box") } + testClass { + model("codegen/java9/box", targetBackend = TargetBackend.JVM_IR) + } + testClass { model("codegen/script", extension = "kts") } diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/Jdk9BlackBoxCodegenTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/Jdk9BlackBoxCodegenTestGenerated.java index 527f0f839e1..8e0a4b59837 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/Jdk9BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/Jdk9BlackBoxCodegenTestGenerated.java @@ -64,6 +64,11 @@ public class Jdk9BlackBoxCodegenTestGenerated extends AbstractJdk9BlackBoxCodege runTest("compiler/testData/codegen/java9/box/concatDynamicWithInline.kt"); } + @TestMetadata("kt36984.kt") + public void testKt36984() throws Exception { + runTest("compiler/testData/codegen/java9/box/kt36984.kt"); + } + @TestMetadata("varHandle.kt") public void testVarHandle() throws Exception { runTest("compiler/testData/codegen/java9/box/varHandle.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/Jdk9IrBlackBoxCodegenTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/Jdk9IrBlackBoxCodegenTestGenerated.java new file mode 100644 index 00000000000..56d97d3ea33 --- /dev/null +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/Jdk9IrBlackBoxCodegenTestGenerated.java @@ -0,0 +1,77 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.codegen; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.util.KtTestUtil; +import org.jetbrains.kotlin.test.TargetBackend; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("compiler/testData/codegen/java9/box") +@TestDataPath("$PROJECT_ROOT") +@RunWith(JUnit3RunnerWithInners.class) +public class Jdk9IrBlackBoxCodegenTestGenerated extends AbstractJdk9IrBlackBoxCodegenTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInBox() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/java9/box"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @TestMetadata("concatDynamic.kt") + public void testConcatDynamic() throws Exception { + runTest("compiler/testData/codegen/java9/box/concatDynamic.kt"); + } + + @TestMetadata("concatDynamic200.kt") + public void testConcatDynamic200() throws Exception { + runTest("compiler/testData/codegen/java9/box/concatDynamic200.kt"); + } + + @TestMetadata("concatDynamic201.kt") + public void testConcatDynamic201() throws Exception { + runTest("compiler/testData/codegen/java9/box/concatDynamic201.kt"); + } + + @TestMetadata("concatDynamicIndy200.kt") + public void testConcatDynamicIndy200() throws Exception { + runTest("compiler/testData/codegen/java9/box/concatDynamicIndy200.kt"); + } + + @TestMetadata("concatDynamicIndy201.kt") + public void testConcatDynamicIndy201() throws Exception { + runTest("compiler/testData/codegen/java9/box/concatDynamicIndy201.kt"); + } + + @TestMetadata("concatDynamicInlineClasses.kt") + public void testConcatDynamicInlineClasses() throws Exception { + runTest("compiler/testData/codegen/java9/box/concatDynamicInlineClasses.kt"); + } + + @TestMetadata("concatDynamicWithInline.kt") + public void testConcatDynamicWithInline() throws Exception { + runTest("compiler/testData/codegen/java9/box/concatDynamicWithInline.kt"); + } + + @TestMetadata("kt36984.kt") + public void testKt36984() throws Exception { + runTest("compiler/testData/codegen/java9/box/kt36984.kt"); + } + + @TestMetadata("varHandle.kt") + public void testVarHandle() throws Exception { + runTest("compiler/testData/codegen/java9/box/varHandle.kt"); + } +}