Ignore type parameters of inline class

when checking whether we can return unboxed inline class
from suspend function
This commit is contained in:
Ilmir Usmanov
2020-09-17 05:05:08 +02:00
parent fbfe56e0cc
commit f960201f52
7 changed files with 63 additions and 16 deletions
@@ -0,0 +1,41 @@
// TARGET_BACKEND: JVM
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND_FIR: JVM_IR
// FULL_JDK
// WITH_RUNTIME
// WITH_COROUTINES
// CHECK_TAIL_CALL_OPTIMIZATION
import helpers.*
import kotlin.coroutines.*
public inline class ValueOrClosed<out T>(val holder: Any?)
public interface Channel<out E> {
public suspend fun receiveOrClosed(): ValueOrClosed<E>
}
class AbstractChannel<E> : Channel<E> {
private suspend fun <R> receiveSuspend(): R {
TailCallOptimizationChecker.saveStackTrace()
return ValueOrClosed<String>("OK") as R
}
public final override suspend fun receiveOrClosed(): ValueOrClosed<E> {
return receiveSuspend()
}
}
fun builder(c: suspend () -> Unit) {
c.startCoroutine(EmptyContinuation)
}
fun box(): String {
var res = "FAIL"
builder {
val channel: Channel<String> = AbstractChannel<String>()
res = channel.receiveOrClosed().holder as String
}
TailCallOptimizationChecker.checkStateMachineIn("receiveOrClosed-v5DwqjU")
return res
}