mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-03-31 08:31:31 +00:00
Minor. Add test with reified type parameter
This commit is contained in:
31
compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified.kt
vendored
Normal file
31
compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified.kt
vendored
Normal 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
|
||||
}
|
||||
34
compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified2.kt
vendored
Normal file
34
compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified2.kt
vendored
Normal 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
|
||||
}
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user