Enable delegation by interface for inline classes in old FE

#KT-27435
This commit is contained in:
Ilmir Usmanov
2021-11-29 14:50:16 +01:00
parent 3002829acf
commit bb53ba4a2e
20 changed files with 371 additions and 5 deletions
@@ -0,0 +1,20 @@
// WITH_STDLIB
// IGNORE_LIGHT_ANALYSIS
// IGNORE_BACKEND: JVM
// IGNORE_BACKEND_FIR: JVM_IR
// LANGUAGE: +InlineClassImplementationByDelegation
interface I {
fun ok(): String = "OK"
}
inline class IC(val i: I): I by i
fun box(): String {
val i = object : I {}
var res = IC(i).ok()
if (res != "OK") return "FAIL: $res"
val ic: I = IC(i)
res = ic.ok()
return res
}
@@ -0,0 +1,28 @@
// WITH_STDLIB
// IGNORE_LIGHT_ANALYSIS
// IGNORE_BACKEND: JVM
// IGNORE_BACKEND_FIR: JVM_IR
// LANGUAGE: +InlineClassImplementationByDelegation
interface I {
fun o(k: String = "K"): String = "O$k"
}
inline class IC(val i: I): I by i
fun box(): String {
val i = object : I {}
val ic1 = IC(i)
var res = ic1.o()
if (res != "OK") return "FAIL 1: $res"
res = ic1.o("KK")
if (res != "OKK") return "FAIL 2: $res"
val ic2: I = IC(i)
res = ic2.o()
if (res != "OK") return "FAIL 3: $res"
res = ic2.o("KK")
if (res != "OKK") return "FAIL 4: $res"
return "OK"
}
@@ -0,0 +1,22 @@
// WITH_STDLIB
// IGNORE_LIGHT_ANALYSIS
// IGNORE_BACKEND: JVM
// IGNORE_BACKEND_FIR: JVM_IR
// LANGUAGE: +InlineClassImplementationByDelegation
interface I {
fun ok(): String
}
inline class IC(val i: I): I by i
fun box(): String {
val i = object : I {
override fun ok(): String = "OK"
}
var res = IC(i).ok()
if (res != "OK") return "FAIL: $res"
val ic: I = IC(i)
res = ic.ok()
return res
}