Minor, add more tests on signature-polymorphic calls

Add a test on null (since null is a special case in the
PolymorphicSignature spec), and a test on a call without assignment to a
variable
This commit is contained in:
Alexander Udalov
2019-12-13 20:01:49 +03:00
parent 64d40b4743
commit 7eda60d57e
6 changed files with 56 additions and 0 deletions
@@ -43,5 +43,8 @@ fun box(): String {
val result3 = (o.p).handle.invoke(C(), "Hello", 0.01, Derived()) as String val result3 = (o.p).handle.invoke(C(), "Hello", 0.01, Derived()) as String
if (result1 != result3) return "Fail 3: $result1 != $result3" if (result1 != result3) return "Fail 3: $result1 != $result3"
// Check cast expression without assignment to a variable
mh.invoke(C(), "", 0.01, Derived()) as String
return "OK" return "OK"
} }
@@ -0,0 +1,28 @@
// !LANGUAGE: +PolymorphicSignature
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_FIR: JVM_IR
// FULL_JDK
// SKIP_JDK6
// WITH_RUNTIME
import java.lang.invoke.MethodHandles
import java.lang.invoke.MethodType
var result: String? = "Fail"
class C {
fun foo(s: Nothing?) {
result = s
}
}
fun box(): String {
val mh = MethodHandles.lookup().findVirtual(
C::class.java, "foo",
MethodType.methodType(Void.TYPE, Void::class.java)
)
mh.invokeExact(C(), null)
return result ?: "OK"
}
@@ -18410,6 +18410,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/polymorphicSignature/invokeExactWithInlineClass.kt"); runTest("compiler/testData/codegen/box/polymorphicSignature/invokeExactWithInlineClass.kt");
} }
@TestMetadata("nullArgument.kt")
public void testNullArgument() throws Exception {
runTest("compiler/testData/codegen/box/polymorphicSignature/nullArgument.kt");
}
@TestMetadata("varargOfObjects_after.kt") @TestMetadata("varargOfObjects_after.kt")
public void testVarargOfObjects_after() throws Exception { public void testVarargOfObjects_after() throws Exception {
runTest("compiler/testData/codegen/box/polymorphicSignature/varargOfObjects_after.kt"); runTest("compiler/testData/codegen/box/polymorphicSignature/varargOfObjects_after.kt");
@@ -18410,6 +18410,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/polymorphicSignature/invokeExactWithInlineClass.kt"); runTest("compiler/testData/codegen/box/polymorphicSignature/invokeExactWithInlineClass.kt");
} }
@TestMetadata("nullArgument.kt")
public void testNullArgument() throws Exception {
runTest("compiler/testData/codegen/box/polymorphicSignature/nullArgument.kt");
}
@TestMetadata("varargOfObjects_after.kt") @TestMetadata("varargOfObjects_after.kt")
public void testVarargOfObjects_after() throws Exception { public void testVarargOfObjects_after() throws Exception {
runTest("compiler/testData/codegen/box/polymorphicSignature/varargOfObjects_after.kt"); runTest("compiler/testData/codegen/box/polymorphicSignature/varargOfObjects_after.kt");
@@ -16894,6 +16894,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/polymorphicSignature/invokeExactWithInlineClass.kt"); runTest("compiler/testData/codegen/box/polymorphicSignature/invokeExactWithInlineClass.kt");
} }
@TestMetadata("nullArgument.kt")
public void testNullArgument() throws Exception {
runTest("compiler/testData/codegen/box/polymorphicSignature/nullArgument.kt");
}
@TestMetadata("varargOfObjects_after.kt") @TestMetadata("varargOfObjects_after.kt")
public void testVarargOfObjects_after() throws Exception { public void testVarargOfObjects_after() throws Exception {
runTest("compiler/testData/codegen/box/polymorphicSignature/varargOfObjects_after.kt"); runTest("compiler/testData/codegen/box/polymorphicSignature/varargOfObjects_after.kt");
@@ -16903,6 +16908,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
public void testVarargOfObjects_before() throws Exception { public void testVarargOfObjects_before() throws Exception {
runTest("compiler/testData/codegen/box/polymorphicSignature/varargOfObjects_before.kt"); runTest("compiler/testData/codegen/box/polymorphicSignature/varargOfObjects_before.kt");
} }
@TestMetadata("voidReturnType.kt")
public void testVoidReturnType() throws Exception {
runTest("compiler/testData/codegen/box/polymorphicSignature/voidReturnType.kt");
}
} }
@TestMetadata("compiler/testData/codegen/box/primitiveTypes") @TestMetadata("compiler/testData/codegen/box/primitiveTypes")
@@ -16894,6 +16894,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/polymorphicSignature/invokeExactWithInlineClass.kt"); runTest("compiler/testData/codegen/box/polymorphicSignature/invokeExactWithInlineClass.kt");
} }
@TestMetadata("nullArgument.kt")
public void testNullArgument() throws Exception {
runTest("compiler/testData/codegen/box/polymorphicSignature/nullArgument.kt");
}
@TestMetadata("varargOfObjects_after.kt") @TestMetadata("varargOfObjects_after.kt")
public void testVarargOfObjects_after() throws Exception { public void testVarargOfObjects_after() throws Exception {
runTest("compiler/testData/codegen/box/polymorphicSignature/varargOfObjects_after.kt"); runTest("compiler/testData/codegen/box/polymorphicSignature/varargOfObjects_after.kt");