Support calling methods annotated with PolymorphicSignature

#KT-14416 Fixed
 #KT-26165 Fixed
This commit is contained in:
Alexander Udalov
2018-11-12 17:38:42 +01:00
parent b940418604
commit a796f11934
18 changed files with 595 additions and 25 deletions
@@ -16773,6 +16773,49 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
}
}
@TestMetadata("compiler/testData/codegen/box/polymorphicSignature")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class PolymorphicSignature extends AbstractBlackBoxCodegenTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
}
public void testAllFilesPresentInPolymorphicSignature() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/polymorphicSignature"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
}
@TestMetadata("anonymousSubclass.kt")
public void testAnonymousSubclass() throws Exception {
runTest("compiler/testData/codegen/box/polymorphicSignature/anonymousSubclass.kt");
}
@TestMetadata("invoke.kt")
public void testInvoke() throws Exception {
runTest("compiler/testData/codegen/box/polymorphicSignature/invoke.kt");
}
@TestMetadata("invokeExact.kt")
public void testInvokeExact() throws Exception {
runTest("compiler/testData/codegen/box/polymorphicSignature/invokeExact.kt");
}
@TestMetadata("invokeExactWithInlineClass.kt")
public void testInvokeExactWithInlineClass() throws Exception {
runTest("compiler/testData/codegen/box/polymorphicSignature/invokeExactWithInlineClass.kt");
}
@TestMetadata("varargOfObjects_after.kt")
public void testVarargOfObjects_after() throws Exception {
runTest("compiler/testData/codegen/box/polymorphicSignature/varargOfObjects_after.kt");
}
@TestMetadata("varargOfObjects_before.kt")
public void testVarargOfObjects_before() throws Exception {
runTest("compiler/testData/codegen/box/polymorphicSignature/varargOfObjects_before.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/primitiveTypes")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -0,0 +1,54 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. 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 org.jetbrains.kotlin.cli.common.output.writeAll
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils
import org.jetbrains.kotlin.test.ConfigurationKind
import org.jetbrains.kotlin.test.KotlinTestUtils
import org.jetbrains.kotlin.test.TestJdkKind
import java.io.File
import java.util.concurrent.TimeUnit
// TODO: merge into main codegen box tests somehow
class Java9CodegenTest : AbstractBlackBoxCodegenTest() {
override fun setUp() {
super.setUp()
val fileName = KotlinTestUtils.getTestDataPathBase() + "/codegen/" + getPrefix() + "/" + getTestName(true) + ".kt"
val testFile = TestFile(fileName, File(fileName).readText())
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.NO_KOTLIN_REFLECT, listOf(testFile), TestJdkKind.FULL_JDK_9)
}
override fun getPrefix(): String = "java9/box"
override fun blackBox() {
val tmpdir = KotlinTestUtils.tmpDirForTest(this)
generateClassesInFile().writeAll(tmpdir, null)
val jdk9Home = KotlinTestUtils.getJdk9Home()
val javaExe = File(jdk9Home, "bin/java.exe").takeIf(File::exists)
?: File(jdk9Home, "bin/java").takeIf(File::exists)
?: error("Can't find 'java' executable in $jdk9Home")
val command = arrayOf(
javaExe.absolutePath,
"-ea",
"-classpath",
listOf(tmpdir, ForTestCompileRuntime.runtimeJarForTests()).joinToString(File.pathSeparator, transform = File::getAbsolutePath),
PackagePartClassUtils.getFilePartShortName(getTestName(false))
)
val process = ProcessBuilder(*command).inheritIO().start()
process.waitFor(1, TimeUnit.MINUTES)
assertEquals(0, process.exitValue())
}
fun testVarHandle() {
loadFile()
blackBox()
}
}
@@ -16773,6 +16773,49 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
}
}
@TestMetadata("compiler/testData/codegen/box/polymorphicSignature")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class PolymorphicSignature extends AbstractLightAnalysisModeTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
}
public void testAllFilesPresentInPolymorphicSignature() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/polymorphicSignature"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
}
@TestMetadata("anonymousSubclass.kt")
public void testAnonymousSubclass() throws Exception {
runTest("compiler/testData/codegen/box/polymorphicSignature/anonymousSubclass.kt");
}
@TestMetadata("invoke.kt")
public void testInvoke() throws Exception {
runTest("compiler/testData/codegen/box/polymorphicSignature/invoke.kt");
}
@TestMetadata("invokeExact.kt")
public void testInvokeExact() throws Exception {
runTest("compiler/testData/codegen/box/polymorphicSignature/invokeExact.kt");
}
@TestMetadata("invokeExactWithInlineClass.kt")
public void testInvokeExactWithInlineClass() throws Exception {
runTest("compiler/testData/codegen/box/polymorphicSignature/invokeExactWithInlineClass.kt");
}
@TestMetadata("varargOfObjects_after.kt")
public void testVarargOfObjects_after() throws Exception {
runTest("compiler/testData/codegen/box/polymorphicSignature/varargOfObjects_after.kt");
}
@TestMetadata("varargOfObjects_before.kt")
public void testVarargOfObjects_before() throws Exception {
runTest("compiler/testData/codegen/box/polymorphicSignature/varargOfObjects_before.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/primitiveTypes")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -16778,6 +16778,49 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
}
}
@TestMetadata("compiler/testData/codegen/box/polymorphicSignature")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class PolymorphicSignature extends AbstractIrBlackBoxCodegenTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath);
}
public void testAllFilesPresentInPolymorphicSignature() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/polymorphicSignature"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true);
}
@TestMetadata("anonymousSubclass.kt")
public void testAnonymousSubclass() throws Exception {
runTest("compiler/testData/codegen/box/polymorphicSignature/anonymousSubclass.kt");
}
@TestMetadata("invoke.kt")
public void testInvoke() throws Exception {
runTest("compiler/testData/codegen/box/polymorphicSignature/invoke.kt");
}
@TestMetadata("invokeExact.kt")
public void testInvokeExact() throws Exception {
runTest("compiler/testData/codegen/box/polymorphicSignature/invokeExact.kt");
}
@TestMetadata("invokeExactWithInlineClass.kt")
public void testInvokeExactWithInlineClass() throws Exception {
runTest("compiler/testData/codegen/box/polymorphicSignature/invokeExactWithInlineClass.kt");
}
@TestMetadata("varargOfObjects_after.kt")
public void testVarargOfObjects_after() throws Exception {
runTest("compiler/testData/codegen/box/polymorphicSignature/varargOfObjects_after.kt");
}
@TestMetadata("varargOfObjects_before.kt")
public void testVarargOfObjects_before() throws Exception {
runTest("compiler/testData/codegen/box/polymorphicSignature/varargOfObjects_before.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/primitiveTypes")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)