d163853c97
This commit handles "subclass: super-interface by delegate-expression". During Psi2Fir, for each delegate, we add to the subclass a synthetic field (which has type super-interface), and an assignment of the delegate-expression to the synthetic field in the primary constructor, so that the delegate-expression can be resolved and transformed along the way. During Fir2Ir, we look up delegatable members from the super-interface and generate corresponding functions/properties for the subclass. TODO: support for generic delegatable members and generic super-interface.
25 lines
396 B
Kotlin
Vendored
25 lines
396 B
Kotlin
Vendored
interface Trait1 {
|
|
fun foo() : String
|
|
}
|
|
|
|
interface Trait2 {
|
|
fun bar() : String
|
|
}
|
|
|
|
class T1 : Trait1{
|
|
override fun foo() = "aaa"
|
|
}
|
|
|
|
class T2 : Trait2{
|
|
override fun bar() = "bbb"
|
|
}
|
|
|
|
class C(a:Trait1, b:Trait2) : Trait1 by a, Trait2 by b
|
|
|
|
fun box() : String {
|
|
val c = C(T1(),T2())
|
|
if(c.foo() != "aaa") return "fail"
|
|
if(c.bar() != "bbb") return "fail"
|
|
return "OK"
|
|
}
|