JVM_IR KT-50076 avoid CHECKCAST on moved dispatch receiver parameter
This commit is contained in:
+35
@@ -0,0 +1,35 @@
|
||||
// WITH_STDLIB
|
||||
// WITH_COROUTINES
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
interface IFoo {
|
||||
fun foo(a: String): String =
|
||||
bar() + a
|
||||
|
||||
fun bar(): String
|
||||
}
|
||||
|
||||
suspend fun suspendK(a: String) =
|
||||
a + "K"
|
||||
|
||||
class FooImpl : IFoo {
|
||||
suspend fun test(a: String): String =
|
||||
super<IFoo>.foo(suspendK(a))
|
||||
|
||||
override fun bar(): String = "O"
|
||||
}
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var result = "FAIL"
|
||||
builder {
|
||||
result = FooImpl().test("")
|
||||
}
|
||||
return result
|
||||
}
|
||||
+48
-5
@@ -1,15 +1,58 @@
|
||||
// WITH_STDLIB
|
||||
|
||||
interface A {
|
||||
fun f(x: String) = x
|
||||
interface IFoo {
|
||||
fun foo(): String = "K"
|
||||
}
|
||||
|
||||
@Suppress("OPTIONAL_DECLARATION_USAGE_IN_NON_COMMON_SOURCE")
|
||||
@kotlin.jvm.JvmInline
|
||||
value class B(val y: String) : A {
|
||||
override fun f(x: String) = super.f(x + y)
|
||||
value class IcStr(val y: String) : IFoo {
|
||||
override fun foo(): String = y + super<IFoo>.foo()
|
||||
}
|
||||
|
||||
@Suppress("OPTIONAL_DECLARATION_USAGE_IN_NON_COMMON_SOURCE")
|
||||
@kotlin.jvm.JvmInline
|
||||
value class IcInt(val i: Int) : IFoo {
|
||||
override fun foo(): String = "O" + super<IFoo>.foo()
|
||||
}
|
||||
|
||||
@Suppress("OPTIONAL_DECLARATION_USAGE_IN_NON_COMMON_SOURCE")
|
||||
@kotlin.jvm.JvmInline
|
||||
value class IcLong(val l: Long) : IFoo {
|
||||
override fun foo(): String = "O" + super<IFoo>.foo()
|
||||
}
|
||||
|
||||
@Suppress("OPTIONAL_DECLARATION_USAGE_IN_NON_COMMON_SOURCE")
|
||||
@kotlin.jvm.JvmInline
|
||||
value class IcAny(val a: Any?) : IFoo {
|
||||
override fun foo(): String = "O" + super<IFoo>.foo()
|
||||
}
|
||||
|
||||
@Suppress("OPTIONAL_DECLARATION_USAGE_IN_NON_COMMON_SOURCE")
|
||||
@kotlin.jvm.JvmInline
|
||||
value class IcOverIc(val o: IcLong) : IFoo {
|
||||
override fun foo(): String = "O" + super<IFoo>.foo()
|
||||
}
|
||||
|
||||
@Suppress("OPTIONAL_DECLARATION_USAGE_IN_NON_COMMON_SOURCE")
|
||||
@kotlin.jvm.JvmInline
|
||||
value class IcOverSuperInterface(val x: IFoo) : IFoo {
|
||||
override fun foo(): String = "O" + super<IFoo>.foo()
|
||||
}
|
||||
|
||||
fun check(message: String, iFoo: IFoo) {
|
||||
val actual = iFoo.foo()
|
||||
if (actual != "OK")
|
||||
throw Exception("$message: \"$actual\" != OK")
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return B("K").f("O")
|
||||
check("IcStr", IcStr("O"))
|
||||
check("IcInt", IcInt(42))
|
||||
check("IcLong", IcLong(42L))
|
||||
check("IcAny", IcAny(""))
|
||||
check("IcOverIc", IcOverIc(IcLong(42L)))
|
||||
check("IcOverSuperInterface", IcOverSuperInterface(IcInt(42)))
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
interface Z {
|
||||
fun testFun() : String {
|
||||
return privateFun()
|
||||
}
|
||||
|
||||
fun testProperty() : String {
|
||||
return privateProp
|
||||
}
|
||||
|
||||
private fun privateFun(): String {
|
||||
return "O"
|
||||
}
|
||||
|
||||
private val privateProp: String
|
||||
get() = "K"
|
||||
}
|
||||
|
||||
object Z2 : Z
|
||||
|
||||
fun box() : String {
|
||||
return Z2.testFun() + Z2.testProperty()
|
||||
}
|
||||
|
||||
// 0 CHECKCAST
|
||||
@@ -0,0 +1,9 @@
|
||||
interface Tr {
|
||||
fun extra(): String = "e"
|
||||
}
|
||||
|
||||
class N : Tr {
|
||||
override fun extra(): String = super.extra()
|
||||
}
|
||||
|
||||
// 0 CHECKCAST
|
||||
Reference in New Issue
Block a user