Enable delegation by interface for inline classes in old FE
#KT-27435
This commit is contained in:
+20
@@ -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
|
||||
}
|
||||
+28
@@ -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"
|
||||
}
|
||||
+22
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user