Minor. Add test with reified type parameter

This commit is contained in:
Ilmir Usmanov
2020-09-17 06:51:56 +02:00
parent 9ecf5dc9af
commit dfd7f33bd3
11 changed files with 155 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
// WITH_RUNTIME
// WITH_COROUTINES
// NO_CHECK_LAMBDA_INLINING
// FILE: 1.kt
package test
import kotlin.coroutines.*
suspend fun callMe(): String = "OK"
inline suspend fun <reified T> isSuspend(t: T): Boolean = t is (SuspendFunction0<*>)
inline suspend fun <reified T> callSuspend(t: T): String = (t as (suspend () -> String))()
// FILE: 2.kt
import helpers.*
import test.*
import kotlin.coroutines.*
fun builder(c: suspend () -> Unit) {
c.startCoroutine(EmptyContinuation)
}
fun box(): String {
var res = "FAIL"
builder {
res = if (isSuspend(::callMe)) callSuspend(::callMe) else "!isSuspend"
}
return res
}

View File

@@ -0,0 +1,34 @@
// WITH_RUNTIME
// WITH_COROUTINES
// NO_CHECK_LAMBDA_INLINING
// FILE: 1.kt
package test
import kotlin.coroutines.*
inline fun <reified T> Any?.instanceOf() = this is T
inline suspend fun <reified T: suspend () -> String> T.callSuspend(): String = (this as (suspend () -> String))()
// FILE: 2.kt
import helpers.*
import test.*
import kotlin.coroutines.*
fun Any?.isSuspend(): Boolean = instanceOf<suspend () -> String>()
fun callMe(): String = "OK"
fun makeSuspend(x: suspend () -> String) = x
fun builder(c: suspend () -> Unit) {
c.startCoroutine(EmptyContinuation)
}
fun box(): String {
var res = "FAIL"
builder {
val adapted = makeSuspend(::callMe)
res = if (adapted.isSuspend()) adapted.callSuspend() else "!isSuspend"
}
return res
}

View File

@@ -4070,6 +4070,16 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/suspend/callableReference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
}
@TestMetadata("isAsReified.kt")
public void testIsAsReified() throws Exception {
runTest("compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified.kt");
}
@TestMetadata("isAsReified2.kt")
public void testIsAsReified2() throws Exception {
runTest("compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified2.kt");
}
@TestMetadata("nonTailCall.kt")
public void testNonTailCall() throws Exception {
runTest("compiler/testData/codegen/boxInline/suspend/callableReference/nonTailCall.kt");

View File

@@ -4070,6 +4070,16 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/suspend/callableReference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
}
@TestMetadata("isAsReified.kt")
public void testIsAsReified() throws Exception {
runTest("compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified.kt");
}
@TestMetadata("isAsReified2.kt")
public void testIsAsReified2() throws Exception {
runTest("compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified2.kt");
}
@TestMetadata("nonTailCall.kt")
public void testNonTailCall() throws Exception {
runTest("compiler/testData/codegen/boxInline/suspend/callableReference/nonTailCall.kt");

View File

@@ -3960,6 +3960,16 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/suspend/callableReference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@TestMetadata("isAsReified.kt")
public void testIsAsReified() throws Exception {
runTest("compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified.kt");
}
@TestMetadata("isAsReified2.kt")
public void testIsAsReified2() throws Exception {
runTest("compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified2.kt");
}
@TestMetadata("nonTailCall.kt")
public void testNonTailCall() throws Exception {
runTest("compiler/testData/codegen/boxInline/suspend/callableReference/nonTailCall.kt");

View File

@@ -3960,6 +3960,16 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/suspend/callableReference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@TestMetadata("isAsReified.kt")
public void testIsAsReified() throws Exception {
runTest("compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified.kt");
}
@TestMetadata("isAsReified2.kt")
public void testIsAsReified2() throws Exception {
runTest("compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified2.kt");
}
@TestMetadata("nonTailCall.kt")
public void testNonTailCall() throws Exception {
runTest("compiler/testData/codegen/boxInline/suspend/callableReference/nonTailCall.kt");

View File

@@ -3960,6 +3960,16 @@ public class JvmIrAgainstOldBoxInlineTestGenerated extends AbstractJvmIrAgainstO
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/suspend/callableReference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_MULTI_MODULE_IR_AGAINST_OLD, true);
}
@TestMetadata("isAsReified.kt")
public void testIsAsReified() throws Exception {
runTest("compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified.kt");
}
@TestMetadata("isAsReified2.kt")
public void testIsAsReified2() throws Exception {
runTest("compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified2.kt");
}
@TestMetadata("nonTailCall.kt")
public void testNonTailCall() throws Exception {
runTest("compiler/testData/codegen/boxInline/suspend/callableReference/nonTailCall.kt");

View File

@@ -3960,6 +3960,16 @@ public class JvmOldAgainstIrBoxInlineTestGenerated extends AbstractJvmOldAgainst
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/suspend/callableReference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_MULTI_MODULE_OLD_AGAINST_IR, true);
}
@TestMetadata("isAsReified.kt")
public void testIsAsReified() throws Exception {
runTest("compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified.kt");
}
@TestMetadata("isAsReified2.kt")
public void testIsAsReified2() throws Exception {
runTest("compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified2.kt");
}
@TestMetadata("nonTailCall.kt")
public void testNonTailCall() throws Exception {
runTest("compiler/testData/codegen/boxInline/suspend/callableReference/nonTailCall.kt");

View File

@@ -3515,6 +3515,16 @@ public class IrJsCodegenInlineES6TestGenerated extends AbstractIrJsCodegenInline
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/suspend/callableReference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
}
@TestMetadata("isAsReified.kt")
public void testIsAsReified() throws Exception {
runTest("compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified.kt");
}
@TestMetadata("isAsReified2.kt")
public void testIsAsReified2() throws Exception {
runTest("compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified2.kt");
}
@TestMetadata("nonTailCall.kt")
public void testNonTailCall() throws Exception {
runTest("compiler/testData/codegen/boxInline/suspend/callableReference/nonTailCall.kt");

View File

@@ -3515,6 +3515,16 @@ public class IrJsCodegenInlineTestGenerated extends AbstractIrJsCodegenInlineTes
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/suspend/callableReference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
}
@TestMetadata("isAsReified.kt")
public void testIsAsReified() throws Exception {
runTest("compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified.kt");
}
@TestMetadata("isAsReified2.kt")
public void testIsAsReified2() throws Exception {
runTest("compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified2.kt");
}
@TestMetadata("nonTailCall.kt")
public void testNonTailCall() throws Exception {
runTest("compiler/testData/codegen/boxInline/suspend/callableReference/nonTailCall.kt");

View File

@@ -3515,6 +3515,16 @@ public class JsCodegenInlineTestGenerated extends AbstractJsCodegenInlineTest {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/suspend/callableReference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true);
}
@TestMetadata("isAsReified.kt")
public void testIsAsReified() throws Exception {
runTest("compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified.kt");
}
@TestMetadata("isAsReified2.kt")
public void testIsAsReified2() throws Exception {
runTest("compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified2.kt");
}
@TestMetadata("nonTailCall.kt")
public void testNonTailCall() throws Exception {
runTest("compiler/testData/codegen/boxInline/suspend/callableReference/nonTailCall.kt");