Support not boxing inline class of reference class

even if the class is other than Any.
 #KT-41429 In progress
This commit is contained in:
Ilmir Usmanov
2020-08-20 21:44:35 +02:00
parent 5c011bc954
commit 023cdd7cd4
9 changed files with 196 additions and 67 deletions
@@ -0,0 +1,26 @@
// IGNORE_BACKEND: JVM_IR
inline class ICString(val x: String)
suspend fun suspendICString(): ICString = ICString("")
suspend fun suspendAny(): Any = ICString("")
suspend fun <T> suspendGeneric(x: T): T = x
fun useICString(x: ICString) {}
fun useAny(x: Any) {}
suspend fun test() {
useICString(suspendICString())
useICString(suspendGeneric(ICString("")))
useAny(suspendAny())
useAny(suspendICString())
}
// -- 1 in 'suspendAny(): Any = ICString("")'
// -- 1 in 'useAny(suspendICString())'
// -- 1 in 'suspendGeneric(ICString(""))'
// 3 INVOKESTATIC ICString\.box-impl
// -- 1 in 'useICString(suspendGeneric(ICString("")))
// -- 1 in 'equals-impl' for ICString
// 2 INVOKEVIRTUAL ICString\.unbox-impl
@@ -1,3 +1,5 @@
// IGNORE_BACKEND: JVM_IR
@Suppress("RESULT_CLASS_IN_RETURN_TYPE")
suspend fun signInFlowStepFirst(): Result<Unit> = Result.success(Unit)
@@ -6,4 +8,4 @@ inline class OurAny(val a: Any)
suspend fun returnsUnboxed(): OurAny = OurAny("OK")
// 1 INVOKESTATIC kotlin/Result.box-impl
// 0 INVOKESTATIC kotlin/OurAny.box-impl
// 0 INVOKESTATIC OurAny.box-impl
@@ -0,0 +1,11 @@
inline class IC(val s: String)
interface I {
suspend fun returnAny(): Any
}
class C : I {
override suspend fun returnAny(): IC = IC("OK")
}
// 1 INVOKESTATIC IC.box-impl