Box inline class return value in covariant override of suspend fun
This commit is contained in:
+45
@@ -0,0 +1,45 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
@Suppress("UNSUPPORTED_FEATURE")
|
||||
inline class IC(val s: String)
|
||||
|
||||
interface IBar {
|
||||
suspend fun bar(): Any
|
||||
}
|
||||
|
||||
class Test() : IBar {
|
||||
|
||||
override suspend fun bar(): IC = IC("OK")
|
||||
|
||||
suspend fun test1(): String {
|
||||
val b: IBar = this
|
||||
return (b.bar() as IC).s
|
||||
}
|
||||
|
||||
suspend fun test2(): String = bar().s
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var result = "FAIL 1"
|
||||
builder {
|
||||
result = Test().test1()
|
||||
}
|
||||
if (result != "OK") return "FAIL 1 $result"
|
||||
|
||||
result = "FAIL2 "
|
||||
builder {
|
||||
result = Test().test2()
|
||||
}
|
||||
if (result != "OK") return "FAIL 2 $result"
|
||||
|
||||
return result
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
@Suppress("UNSUPPORTED_FEATURE")
|
||||
inline class IC(val s: String)
|
||||
|
||||
interface IBar {
|
||||
suspend fun bar(): IC?
|
||||
}
|
||||
|
||||
class Test() : IBar {
|
||||
|
||||
override suspend fun bar(): IC = IC("OK")
|
||||
|
||||
suspend fun test1(): String {
|
||||
val b: IBar = this
|
||||
return b.bar()!!.s
|
||||
}
|
||||
|
||||
suspend fun test2(): String {
|
||||
return bar().s
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var result = "FAIL"
|
||||
builder {
|
||||
result = Test().test1()
|
||||
}
|
||||
if (result != "OK") return "FAIL 1 $result"
|
||||
|
||||
result = "FAIL2"
|
||||
builder {
|
||||
result = Test().test2()
|
||||
}
|
||||
if (result != "OK") return "FAIL 2 $result"
|
||||
|
||||
return result
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
@Suppress("UNSUPPORTED_FEATURE")
|
||||
inline class IC(val s: Any)
|
||||
|
||||
interface IBar {
|
||||
suspend fun bar(): IC?
|
||||
}
|
||||
|
||||
class Test() : IBar {
|
||||
override suspend fun bar(): IC = IC("OK")
|
||||
|
||||
suspend fun test1(): String {
|
||||
val b: IBar = this
|
||||
return b.bar()!!.s as String
|
||||
}
|
||||
|
||||
suspend fun test2(): String {
|
||||
return bar()!!.s as String
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var result = "FAIL"
|
||||
builder {
|
||||
result = Test().test1()
|
||||
}
|
||||
if (result != "OK") return "FAIL 1 $result"
|
||||
|
||||
result = "FAIL2"
|
||||
builder {
|
||||
result = Test().test2()
|
||||
}
|
||||
if (result != "OK") return "FAIL 2 $result"
|
||||
|
||||
return result
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
@Suppress("UNSUPPORTED_FEATURE")
|
||||
inline class IC(val s: Int)
|
||||
|
||||
interface IBar {
|
||||
suspend fun bar(): IC?
|
||||
}
|
||||
|
||||
fun Int.toResultString() =
|
||||
if (this == 42) "OK" else "!!! $this"
|
||||
|
||||
class Test() : IBar {
|
||||
override suspend fun bar(): IC = IC(42)
|
||||
|
||||
suspend fun test1(): String {
|
||||
val b: IBar = this
|
||||
return b.bar()!!.s.toResultString()
|
||||
}
|
||||
|
||||
suspend fun test2(): String {
|
||||
return bar()!!.s.toResultString()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var result = "FAIL"
|
||||
builder {
|
||||
result = Test().test1()
|
||||
}
|
||||
if (result != "OK") return "FAIL 1 $result"
|
||||
|
||||
result = "FAIL2"
|
||||
builder {
|
||||
result = Test().test2()
|
||||
}
|
||||
if (result != "OK") return "FAIL 2 $result"
|
||||
|
||||
return result
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
@Suppress("UNSUPPORTED_FEATURE")
|
||||
inline class IC(val s: Any?)
|
||||
|
||||
interface IBar {
|
||||
suspend fun bar(): IC?
|
||||
}
|
||||
|
||||
class Test() : IBar {
|
||||
override suspend fun bar(): IC = IC("OK")
|
||||
|
||||
suspend fun test1(): String {
|
||||
val b: IBar = this
|
||||
return b.bar()!!.s as String
|
||||
}
|
||||
|
||||
suspend fun test2(): String = bar().s as String
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
var result = "FAIL"
|
||||
builder {
|
||||
result = Test().test1()
|
||||
}
|
||||
if (result != "OK") return "FAIL 1 $result"
|
||||
|
||||
result = "FAIL2"
|
||||
builder {
|
||||
result = Test().test2()
|
||||
}
|
||||
if (result != "OK") return "FAIL 2 $result"
|
||||
|
||||
return result
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
@Suppress("UNSUPPORTED_FEATURE")
|
||||
inline class IC(val s: Any?)
|
||||
|
||||
interface IBar {
|
||||
suspend fun bar(): IC?
|
||||
}
|
||||
|
||||
class Test1() : IBar {
|
||||
override suspend fun bar(): IC {
|
||||
return IC(null)
|
||||
}
|
||||
|
||||
suspend fun test(): Any? {
|
||||
val b: IBar = this
|
||||
return b.bar()!!.s
|
||||
}
|
||||
}
|
||||
|
||||
class Test2() : IBar {
|
||||
override suspend fun bar(): IC {
|
||||
return IC(null)
|
||||
}
|
||||
|
||||
suspend fun test(): IC {
|
||||
val b: IBar = this
|
||||
return b.bar()!!
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
var result: Any? = "FAIL 1"
|
||||
builder {
|
||||
result = Test1().test()
|
||||
}
|
||||
if (result != null) return "FAIL 1 $result"
|
||||
|
||||
result = "FAIL 2"
|
||||
builder {
|
||||
result = Test2().test()
|
||||
}
|
||||
if (result != IC(null)) return "FAIL 2 $result"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
@Suppress("UNSUPPORTED_FEATURE")
|
||||
inline class IC(val s: Int?)
|
||||
|
||||
interface IBar {
|
||||
suspend fun bar(): IC?
|
||||
}
|
||||
|
||||
fun Int?.toResultString() =
|
||||
if (this == 42) "OK" else "!!! $this"
|
||||
|
||||
class Test() : IBar {
|
||||
override suspend fun bar(): IC = IC(42)
|
||||
|
||||
suspend fun test1(): String {
|
||||
val b: IBar = this
|
||||
return b.bar()!!.s.toResultString()
|
||||
}
|
||||
|
||||
suspend fun test2(): String {
|
||||
return bar()!!.s.toResultString()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var result = "FAIL"
|
||||
builder {
|
||||
result = Test().test1()
|
||||
}
|
||||
if (result != "OK") return "FAIL 1 $result"
|
||||
|
||||
result = "FAIL2"
|
||||
builder {
|
||||
result = Test().test2()
|
||||
}
|
||||
if (result != "OK") return "FAIL 2 $result"
|
||||
|
||||
return result
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
@Suppress("UNSUPPORTED_FEATURE")
|
||||
inline class IC(val s: Int?)
|
||||
|
||||
interface IBar {
|
||||
suspend fun bar(): IC?
|
||||
}
|
||||
|
||||
fun Int?.toResultString() =
|
||||
if (this == null) "OK" else "!!! $this"
|
||||
|
||||
class Test() : IBar {
|
||||
override suspend fun bar(): IC = IC(null)
|
||||
|
||||
suspend fun test1(): String {
|
||||
val b: IBar = this
|
||||
return b.bar()!!.s.toResultString()
|
||||
}
|
||||
|
||||
suspend fun test2(): String {
|
||||
return bar()!!.s.toResultString()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var result = "FAIL"
|
||||
builder {
|
||||
result = Test().test1()
|
||||
}
|
||||
if (result != "OK") return "FAIL 1 $result"
|
||||
|
||||
result = "FAIL2"
|
||||
builder {
|
||||
result = Test().test2()
|
||||
}
|
||||
if (result != "OK") return "FAIL 2 $result"
|
||||
|
||||
return result
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
@Suppress("UNSUPPORTED_FEATURE")
|
||||
inline class IC(val s: Any)
|
||||
|
||||
interface IBar {
|
||||
suspend fun bar(): Any
|
||||
}
|
||||
|
||||
class Test() : IBar {
|
||||
|
||||
override suspend fun bar(): IC = IC("OK")
|
||||
|
||||
suspend fun test1(): String {
|
||||
val b: IBar = this
|
||||
return (b.bar() as IC).s as String
|
||||
}
|
||||
|
||||
suspend fun test2(): String = bar().s as String
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
var result = "FAIL 1"
|
||||
builder {
|
||||
result = Test().test1()
|
||||
}
|
||||
if (result != "OK") return "FAIL 1 $result"
|
||||
|
||||
result = "FAIL2 "
|
||||
builder {
|
||||
result = Test().test2()
|
||||
}
|
||||
if (result != "OK") return "FAIL 2 $result"
|
||||
|
||||
return result
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
@Suppress("UNSUPPORTED_FEATURE")
|
||||
inline class IC(val s: Int)
|
||||
|
||||
interface IBar {
|
||||
suspend fun bar(): Any
|
||||
}
|
||||
|
||||
class Test() : IBar {
|
||||
override suspend fun bar(): IC = IC(42)
|
||||
|
||||
suspend fun test1(): Int {
|
||||
val b: IBar = this
|
||||
return (b.bar() as IC).s
|
||||
}
|
||||
|
||||
suspend fun test2(): Int {
|
||||
val b: IBar = this
|
||||
return (b.bar() as IC).s
|
||||
}
|
||||
}
|
||||
|
||||
fun Int.toBoxResult() =
|
||||
if (this == 42) "OK" else toString()
|
||||
|
||||
fun box(): String {
|
||||
var result: String = "FAIL"
|
||||
builder {
|
||||
result = Test().test1().toBoxResult()
|
||||
}
|
||||
if (result != "OK") return "FAIL 1 $result"
|
||||
|
||||
result = "FAIL2"
|
||||
builder {
|
||||
result = Test().test2().toBoxResult()
|
||||
}
|
||||
if (result != "OK") return "FAIL 2 $result"
|
||||
|
||||
return result as String
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
inline class IC(val s: String)
|
||||
|
||||
interface Base<T> {
|
||||
suspend fun generic(): T
|
||||
}
|
||||
|
||||
class Derived : Base<IC> {
|
||||
override suspend fun generic(): IC = suspendCoroutine { it.resume(IC("OK")) }
|
||||
}
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var res: String? = null
|
||||
builder {
|
||||
val base: Base<*> = Derived()
|
||||
res = (base.generic() as IC).s
|
||||
}
|
||||
return res!!
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
inline class IC(val s: Any)
|
||||
|
||||
interface Base<T> {
|
||||
suspend fun generic(): T
|
||||
}
|
||||
|
||||
class Derived : Base<IC> {
|
||||
override suspend fun generic(): IC = suspendCoroutine { it.resume(IC("OK")) }
|
||||
}
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var res: String? = null
|
||||
builder {
|
||||
val base: Base<*> = Derived()
|
||||
res = (base.generic() as IC).s as String
|
||||
}
|
||||
return res!!
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
inline class IC(val s: Any)
|
||||
|
||||
interface Base<T : IC?> {
|
||||
suspend fun generic(): T
|
||||
}
|
||||
|
||||
class Derived : Base<IC> {
|
||||
override suspend fun generic(): IC = suspendCoroutine { it.resume(IC("OK")) }
|
||||
}
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var res: String? = null
|
||||
builder {
|
||||
val base: Base<*> = Derived()
|
||||
res = base.generic()!!.s as String
|
||||
}
|
||||
return res!!
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
inline class IC(val s: Int)
|
||||
|
||||
fun Int.toResultString() =
|
||||
if (this == 42) "OK" else "!! $this"
|
||||
|
||||
interface Base<T> {
|
||||
suspend fun generic(): T
|
||||
}
|
||||
|
||||
class Derived : Base<IC> {
|
||||
override suspend fun generic(): IC = suspendCoroutine { it.resume(IC(42)) }
|
||||
}
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var res: String? = null
|
||||
builder {
|
||||
val base: Base<*> = Derived()
|
||||
res = (base.generic() as IC).s.toResultString()
|
||||
}
|
||||
return res!!
|
||||
}
|
||||
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
inline class IC(val s: Any?)
|
||||
|
||||
interface Base<T> {
|
||||
suspend fun generic(): T
|
||||
}
|
||||
|
||||
class Derived : Base<IC> {
|
||||
override suspend fun generic(): IC = suspendCoroutine { it.resume(IC("OK")) }
|
||||
}
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var res: String? = null
|
||||
builder {
|
||||
val base: Base<*> = Derived()
|
||||
res = (base.generic() as IC).s as String
|
||||
}
|
||||
return res!!
|
||||
}
|
||||
compiler/testData/codegen/box/coroutines/inlineClasses/genericOverrideSuspendFun_NullableAny_null.kt
Vendored
+32
@@ -0,0 +1,32 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
inline class IC(val s: Any?)
|
||||
|
||||
interface Base<T> {
|
||||
suspend fun generic(): T
|
||||
}
|
||||
|
||||
class Derived : Base<IC> {
|
||||
override suspend fun generic(): IC = suspendCoroutine { it.resume(IC(null)) }
|
||||
}
|
||||
|
||||
fun Any?.toResultString(): String =
|
||||
if (this == null) "OK" else "!! $this"
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var res: String? = null
|
||||
builder {
|
||||
val base: Base<*> = Derived()
|
||||
res = (base.generic() as IC).s.toResultString()
|
||||
}
|
||||
return res!!
|
||||
}
|
||||
Vendored
+32
@@ -0,0 +1,32 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
inline class IC(val s: Int?)
|
||||
|
||||
fun Int?.toResultString() =
|
||||
if (this == 42) "OK" else "!! $this"
|
||||
|
||||
interface Base<T> {
|
||||
suspend fun generic(): T
|
||||
}
|
||||
|
||||
class Derived : Base<IC> {
|
||||
override suspend fun generic(): IC = suspendCoroutine { it.resume(IC(42)) }
|
||||
}
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var res: String? = null
|
||||
builder {
|
||||
val base: Base<*> = Derived()
|
||||
res = (base.generic() as IC).s.toResultString()
|
||||
}
|
||||
return res!!
|
||||
}
|
||||
compiler/testData/codegen/box/coroutines/inlineClasses/genericOverrideSuspendFun_NullableInt_null.kt
Vendored
+32
@@ -0,0 +1,32 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
inline class IC(val s: Int?)
|
||||
|
||||
fun Int?.toResultString() =
|
||||
if (this == null) "OK" else "!! $this"
|
||||
|
||||
interface Base<T> {
|
||||
suspend fun generic(): T
|
||||
}
|
||||
|
||||
class Derived : Base<IC> {
|
||||
override suspend fun generic(): IC = suspendCoroutine { it.resume(IC(null)) }
|
||||
}
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var res: String? = null
|
||||
builder {
|
||||
val base: Base<*> = Derived()
|
||||
res = (base.generic() as IC).s.toResultString()
|
||||
}
|
||||
return res!!
|
||||
}
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
// COMMON_COROUTINES_TEST
|
||||
|
||||
import helpers.*
|
||||
import COROUTINES_PACKAGE.*
|
||||
import COROUTINES_PACKAGE.intrinsics.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
@Suppress("UNSUPPORTED_FEATURE")
|
||||
inline class IC(val s: String)
|
||||
|
||||
interface IBar {
|
||||
suspend fun bar(): IC
|
||||
}
|
||||
|
||||
class Test1() : IBar {
|
||||
|
||||
suspend fun <T> foo(value: T): T {
|
||||
return suspendCoroutineUninterceptedOrReturn {
|
||||
it.resume(value)
|
||||
COROUTINE_SUSPENDED
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun qux(ss: IC): IC = IC(ss.s)
|
||||
|
||||
suspend fun <T> quz(t: T): T = t
|
||||
|
||||
override suspend fun bar(): IC {
|
||||
return foo(qux(quz(IC("OK"))))
|
||||
}
|
||||
|
||||
suspend fun test(): String {
|
||||
val b: IBar = this
|
||||
return b.bar().s
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Test2 : IBar {
|
||||
|
||||
suspend fun foo(value: IC): IC {
|
||||
return suspendCoroutineUninterceptedOrReturn {
|
||||
it.resume(value)
|
||||
COROUTINE_SUSPENDED
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun qux(s: String): IC = IC(s)
|
||||
|
||||
suspend fun quz(): String = "OK"
|
||||
|
||||
override suspend fun bar(): IC {
|
||||
return foo(qux(quz()))
|
||||
}
|
||||
|
||||
suspend fun test(): String {
|
||||
val b: IBar = this
|
||||
return b.bar().s
|
||||
}
|
||||
}
|
||||
|
||||
class Test3 : IBar {
|
||||
suspend fun <T> foo(value: T): T {
|
||||
return suspendCoroutineUninterceptedOrReturn {
|
||||
it.resume(value)
|
||||
COROUTINE_SUSPENDED
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun bar(): IC {
|
||||
return foo(IC("OK"))
|
||||
}
|
||||
|
||||
suspend fun test(): String {
|
||||
val b: IBar = this
|
||||
return b.bar().s
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
|
||||
var result = "FAIL"
|
||||
builder {
|
||||
result = Test1().test()
|
||||
}
|
||||
|
||||
if (result != "OK") return "FAIL 1 $result"
|
||||
|
||||
result = "FAIL2"
|
||||
|
||||
builder {
|
||||
result = Test2().test()
|
||||
}
|
||||
|
||||
if (result != "OK") return "FAIL 2 $result"
|
||||
|
||||
result = "FAIL 3"
|
||||
|
||||
builder {
|
||||
result = Test3().test()
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
// COMMON_COROUTINES_TEST
|
||||
|
||||
import helpers.*
|
||||
import COROUTINES_PACKAGE.*
|
||||
import COROUTINES_PACKAGE.intrinsics.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
@Suppress("UNSUPPORTED_FEATURE")
|
||||
inline class IC(val s: Any)
|
||||
|
||||
interface IBar {
|
||||
suspend fun bar(): IC
|
||||
}
|
||||
|
||||
class Test1() : IBar {
|
||||
|
||||
suspend fun <T> foo(value: T): T {
|
||||
return suspendCoroutineUninterceptedOrReturn {
|
||||
it.resume(value)
|
||||
COROUTINE_SUSPENDED
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun qux(ss: IC): IC = IC(ss.s)
|
||||
|
||||
suspend fun <T> quz(t: T): T = t
|
||||
|
||||
override suspend fun bar(): IC {
|
||||
return foo(qux(quz(IC("OK"))))
|
||||
}
|
||||
|
||||
suspend fun test(): Any {
|
||||
val b: IBar = this
|
||||
return b.bar().s
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Test2 : IBar {
|
||||
|
||||
suspend fun foo(value: IC): IC {
|
||||
return suspendCoroutineUninterceptedOrReturn {
|
||||
it.resume(value)
|
||||
COROUTINE_SUSPENDED
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun qux(s: String): IC = IC(s)
|
||||
|
||||
suspend fun quz(): String = "OK"
|
||||
|
||||
override suspend fun bar(): IC {
|
||||
return foo(qux(quz()))
|
||||
}
|
||||
|
||||
suspend fun test(): Any {
|
||||
val b: IBar = this
|
||||
return b.bar().s
|
||||
}
|
||||
}
|
||||
|
||||
class Test3 : IBar {
|
||||
suspend fun <T> foo(value: T): T {
|
||||
return suspendCoroutineUninterceptedOrReturn {
|
||||
it.resume(value)
|
||||
COROUTINE_SUSPENDED
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun bar(): IC {
|
||||
return foo(IC("OK"))
|
||||
}
|
||||
|
||||
suspend fun test(): Any {
|
||||
val b: IBar = this
|
||||
return b.bar().s
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var result: Any = "FAIL1"
|
||||
builder {
|
||||
result = Test1().test()
|
||||
}
|
||||
if (result != "OK") return "FAIL 1 $result"
|
||||
|
||||
result = "FAIL2"
|
||||
builder {
|
||||
result = Test2().test()
|
||||
}
|
||||
if (result != "OK") return "FAIL 2 $result"
|
||||
|
||||
result = "FAIL 3"
|
||||
builder {
|
||||
result = Test3().test()
|
||||
}
|
||||
return result as String
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
// COMMON_COROUTINES_TEST
|
||||
|
||||
import helpers.*
|
||||
import COROUTINES_PACKAGE.*
|
||||
import COROUTINES_PACKAGE.intrinsics.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
@Suppress("UNSUPPORTED_FEATURE")
|
||||
inline class IC(val s: Any)
|
||||
|
||||
interface IBar {
|
||||
suspend fun bar(): IC
|
||||
}
|
||||
|
||||
class Test0() : IBar {
|
||||
override suspend fun bar(): IC = IC("OK")
|
||||
|
||||
suspend fun test(): Any {
|
||||
val b: IBar = this
|
||||
return b.bar().s
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var result: Any = "FAIL"
|
||||
builder {
|
||||
result = Test0().test()
|
||||
}
|
||||
if (result != "OK") return "FAIL 0 $result"
|
||||
|
||||
return result as String
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
// COMMON_COROUTINES_TEST
|
||||
|
||||
import helpers.*
|
||||
import COROUTINES_PACKAGE.*
|
||||
import COROUTINES_PACKAGE.intrinsics.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
@Suppress("UNSUPPORTED_FEATURE")
|
||||
inline class IC(val s: Any)
|
||||
|
||||
interface IBar {
|
||||
suspend fun bar(): IC
|
||||
}
|
||||
|
||||
class Test0() : IBar {
|
||||
override suspend fun bar(): IC = IC("OK")
|
||||
|
||||
suspend fun test(): Any {
|
||||
return bar().s
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var result: Any = "FAIL"
|
||||
builder {
|
||||
result = Test0().test()
|
||||
}
|
||||
if (result != "OK") return "FAIL 0 $result"
|
||||
|
||||
return result as String
|
||||
}
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
// COMMON_COROUTINES_TEST
|
||||
|
||||
import helpers.*
|
||||
import COROUTINES_PACKAGE.*
|
||||
import COROUTINES_PACKAGE.intrinsics.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
@Suppress("UNSUPPORTED_FEATURE")
|
||||
inline class IC(val s: Int)
|
||||
|
||||
interface IBar {
|
||||
suspend fun bar(): IC
|
||||
}
|
||||
|
||||
class Test1() : IBar {
|
||||
|
||||
suspend fun <T> foo(value: T): T {
|
||||
return suspendCoroutineUninterceptedOrReturn {
|
||||
it.resume(value)
|
||||
COROUTINE_SUSPENDED
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun qux(ss: IC): IC = IC(ss.s)
|
||||
|
||||
suspend fun <T> quz(t: T): T = t
|
||||
|
||||
override suspend fun bar(): IC {
|
||||
return foo(qux(quz(IC(42))))
|
||||
}
|
||||
|
||||
suspend fun test(): Int {
|
||||
val b: IBar = this
|
||||
return b.bar().s
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Test2 : IBar {
|
||||
|
||||
suspend fun foo(value: IC): IC {
|
||||
return suspendCoroutineUninterceptedOrReturn {
|
||||
it.resume(value)
|
||||
COROUTINE_SUSPENDED
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun qux(s: Int): IC = IC(s)
|
||||
|
||||
suspend fun quz(): Int = 42
|
||||
|
||||
override suspend fun bar(): IC {
|
||||
return foo(qux(quz()))
|
||||
}
|
||||
|
||||
suspend fun test(): Int {
|
||||
val b: IBar = this
|
||||
return b.bar().s
|
||||
}
|
||||
}
|
||||
|
||||
class Test3 : IBar {
|
||||
suspend fun <T> foo(value: T): T {
|
||||
return suspendCoroutineUninterceptedOrReturn {
|
||||
it.resume(value)
|
||||
COROUTINE_SUSPENDED
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun bar(): IC {
|
||||
return foo(IC(42))
|
||||
}
|
||||
|
||||
suspend fun test(): Int {
|
||||
val b: IBar = this
|
||||
return b.bar().s
|
||||
}
|
||||
}
|
||||
|
||||
fun Int.toBoxResult() =
|
||||
if (this == 42) "OK" else toString()
|
||||
|
||||
fun box(): String {
|
||||
|
||||
var result: String = "FAIL"
|
||||
builder {
|
||||
result = Test1().test().toBoxResult()
|
||||
}
|
||||
|
||||
if (result != "OK") return "FAIL 1 $result"
|
||||
|
||||
result = "FAIL2"
|
||||
|
||||
builder {
|
||||
result = Test2().test().toBoxResult()
|
||||
}
|
||||
|
||||
if (result != "OK") return "FAIL 2 $result"
|
||||
|
||||
result = "FAIL 3"
|
||||
|
||||
builder {
|
||||
result = Test3().test().toBoxResult()
|
||||
}
|
||||
|
||||
return result as String
|
||||
}
|
||||
Reference in New Issue
Block a user