Minor. Add tests with same JvmType in covariant override
This commit is contained in:
+48
@@ -0,0 +1,48 @@
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
interface I
|
||||
|
||||
@Suppress("UNSUPPORTED_FEATURE")
|
||||
inline class IC(val i: I): I
|
||||
|
||||
class Wrapper(val s: String): I
|
||||
|
||||
interface IBar {
|
||||
suspend fun bar(): I
|
||||
}
|
||||
|
||||
class Test() : IBar {
|
||||
override suspend fun bar(): IC = IC(Wrapper("OK"))
|
||||
|
||||
suspend fun test1(): String {
|
||||
val b: IBar = this
|
||||
return ((b.bar() as IC).i as Wrapper).s
|
||||
}
|
||||
|
||||
suspend fun test2(): String = ((bar() as IC).i as Wrapper).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
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
interface I
|
||||
|
||||
@Suppress("UNSUPPORTED_FEATURE")
|
||||
inline class IC(val i: I): I
|
||||
|
||||
class Wrapper(val s: String): I
|
||||
|
||||
interface IBar {
|
||||
suspend fun bar(): I?
|
||||
}
|
||||
|
||||
class Test() : IBar {
|
||||
override suspend fun bar(): IC = IC(Wrapper("OK"))
|
||||
|
||||
suspend fun test1(): String {
|
||||
val b: IBar = this
|
||||
return ((b.bar() as IC).i as Wrapper).s
|
||||
}
|
||||
|
||||
suspend fun test2(): String {
|
||||
return ((bar() as IC).i as Wrapper).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
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
interface I
|
||||
|
||||
@Suppress("UNSUPPORTED_FEATURE")
|
||||
inline class IC(val i: I): I
|
||||
|
||||
class Wrapper(val s: String): I
|
||||
|
||||
interface IBar {
|
||||
suspend fun bar(): I
|
||||
}
|
||||
|
||||
var c: Continuation<Any>? = null
|
||||
|
||||
suspend fun <T> suspendMe(): T = suspendCoroutine {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
c = it as Continuation<Any>
|
||||
}
|
||||
|
||||
class Test() : IBar {
|
||||
override suspend fun bar(): IC = suspendMe()
|
||||
|
||||
suspend fun test1(): String {
|
||||
val b: IBar = this
|
||||
return ((b.bar() as IC).i as Wrapper).s
|
||||
}
|
||||
|
||||
suspend fun test2(): String = ((bar() as IC).i as Wrapper).s
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var result = "FAIL 1"
|
||||
builder {
|
||||
result = Test().test1()
|
||||
}
|
||||
c?.resume(IC(Wrapper("OK")))
|
||||
if (result != "OK") return "FAIL 1 $result"
|
||||
|
||||
result = "FAIL2 "
|
||||
builder {
|
||||
result = Test().test2()
|
||||
}
|
||||
c?.resume(IC(Wrapper("OK")))
|
||||
if (result != "OK") return "FAIL 2 $result"
|
||||
|
||||
return result
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
interface I
|
||||
|
||||
@Suppress("UNSUPPORTED_FEATURE")
|
||||
inline class IC(val i: I): I
|
||||
|
||||
class Wrapper(val s: String): I
|
||||
|
||||
interface IBar {
|
||||
suspend fun bar(): I?
|
||||
}
|
||||
|
||||
var c: Continuation<Any>? = null
|
||||
|
||||
suspend fun <T> suspendMe(): T = suspendCoroutine {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
c = it as Continuation<Any>
|
||||
}
|
||||
|
||||
class Test() : IBar {
|
||||
override suspend fun bar(): IC = suspendMe()
|
||||
|
||||
suspend fun test1(): String {
|
||||
val b: IBar = this
|
||||
return ((b.bar() as IC).i as Wrapper).s
|
||||
}
|
||||
|
||||
suspend fun test2(): String {
|
||||
return ((bar() as IC).i as Wrapper).s
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var result = "FAIL"
|
||||
builder {
|
||||
result = Test().test1()
|
||||
}
|
||||
c?.resume(IC(Wrapper("OK")))
|
||||
if (result != "OK") return "FAIL 1 $result"
|
||||
|
||||
result = "FAIL2"
|
||||
builder {
|
||||
result = Test().test2()
|
||||
}
|
||||
c?.resume(IC(Wrapper("OK")))
|
||||
if (result != "OK") return "FAIL 2 $result"
|
||||
|
||||
return result
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
var result = "FAIL"
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(handleExceptionContinuation {
|
||||
result = it.message!!
|
||||
})
|
||||
}
|
||||
|
||||
interface I
|
||||
|
||||
@Suppress("UNSUPPORTED_FEATURE")
|
||||
inline class IC(val i: I): I
|
||||
|
||||
class Wrapper(val s: String): I
|
||||
|
||||
interface IBar {
|
||||
suspend fun bar(): I
|
||||
}
|
||||
|
||||
var c: Continuation<Any>? = null
|
||||
|
||||
suspend fun <T> suspendMe(): T = suspendCoroutine {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
c = it as Continuation<Any>
|
||||
}
|
||||
|
||||
class Test() : IBar {
|
||||
override suspend fun bar(): IC = suspendMe()
|
||||
|
||||
suspend fun test1(): String {
|
||||
val b: IBar = this
|
||||
return ((b.bar() as IC).i as Wrapper).s
|
||||
}
|
||||
|
||||
suspend fun test2(): String = ((bar() as IC).i as Wrapper).s
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
builder {
|
||||
Test().test1()
|
||||
}
|
||||
c?.resumeWithException(IllegalStateException("OK"))
|
||||
if (result != "OK") return "FAIL 1 $result"
|
||||
|
||||
result = "FAIL2 "
|
||||
builder {
|
||||
Test().test2()
|
||||
}
|
||||
c?.resumeWithException(IllegalStateException("OK"))
|
||||
if (result != "OK") return "FAIL 2 $result"
|
||||
|
||||
return result
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
var result = "FAIL"
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(handleExceptionContinuation {
|
||||
result = it.message!!
|
||||
})
|
||||
}
|
||||
|
||||
interface I
|
||||
|
||||
@Suppress("UNSUPPORTED_FEATURE")
|
||||
inline class IC(val i: I): I
|
||||
|
||||
class Wrapper(val s: String): I
|
||||
|
||||
interface IBar {
|
||||
suspend fun bar(): I?
|
||||
}
|
||||
|
||||
var c: Continuation<Any>? = null
|
||||
|
||||
suspend fun <T> suspendMe(): T = suspendCoroutine {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
c = it as Continuation<Any>
|
||||
}
|
||||
|
||||
class Test() : IBar {
|
||||
override suspend fun bar(): IC = suspendMe()
|
||||
|
||||
suspend fun test1(): String {
|
||||
val b: IBar = this
|
||||
return ((b.bar() as IC).i as Wrapper).s
|
||||
}
|
||||
|
||||
suspend fun test2(): String {
|
||||
return ((bar() as IC).i as Wrapper).s
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
builder {
|
||||
Test().test1()
|
||||
}
|
||||
c?.resumeWithException(IllegalStateException("OK"))
|
||||
if (result != "OK") return "FAIL 1 $result"
|
||||
|
||||
result = "FAIL2"
|
||||
builder {
|
||||
Test().test2()
|
||||
}
|
||||
c?.resumeWithException(IllegalStateException("OK"))
|
||||
if (result != "OK") return "FAIL 2 $result"
|
||||
|
||||
return result
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
|
||||
interface I
|
||||
|
||||
inline class ICI(val i: I): I
|
||||
|
||||
class Wrapper(val s: String): I
|
||||
|
||||
suspend fun suspendICI(): ICI = ICI(Wrapper(""))
|
||||
suspend fun suspendI(): I = ICI(Wrapper(""))
|
||||
suspend fun <T> suspendGeneric(x: T): T = x
|
||||
|
||||
fun useICString(x: ICI) {}
|
||||
fun useI(x: I) {}
|
||||
|
||||
suspend fun test() {
|
||||
useICString(suspendICI())
|
||||
useICString(suspendGeneric(ICI(Wrapper(""))))
|
||||
useI(suspendI())
|
||||
useI(suspendICI())
|
||||
}
|
||||
|
||||
// -- 1 in 'suspendAny(): I = ICI("")'
|
||||
// -- 1 in 'useI(suspendICI())'
|
||||
// -- 1 in 'suspendGeneric(ICI(""))'
|
||||
// 3 INVOKESTATIC ICI\.box-impl
|
||||
|
||||
// -- 1 in 'useICI(suspendGeneric(ICI("")))
|
||||
// -- 1 in 'equals-impl' for ICI
|
||||
// -- 2 in resume path of suspendICI
|
||||
// 4 INVOKEVIRTUAL ICI\.unbox-impl
|
||||
Reference in New Issue
Block a user