Files
kotlin-fork/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder2.kt.txt
T
Vladimir Sukharev f7269eb384 [FIR2IR] Rework reordering condition to better handle synthetic class delegation fields
^KT-60243

Merge-request: KT-MR-11125
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-07-19 09:59:53 +00:00

162 lines
2.8 KiB
Kotlin
Vendored

package foo
interface Base {
abstract fun foo(x: String): String
}
class BaseImpl : Base {
constructor(s: String) /* primary */ {
super/*Any*/()
/* <init>() */
}
val s: String
field = s
get
override fun foo(x: String): String {
return "Base: " + <this>.<get-s>() + ":" + x
}
}
interface Base2 {
abstract fun bar(x: String): String
}
class Base2Impl : Base2 {
constructor(s: String) /* primary */ {
super/*Any*/()
/* <init>() */
}
val s: String
field = s
get
override fun bar(x: String): String {
return "Base2: " + <this>.<get-s>() + ":" + x
}
}
var global: String
field = ""
get
set
open class DerivedBase {
constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
init {
{ // BLOCK
<set-global>(<set-?> = <get-global>().plus(other = ":DerivedBase"))
}
}
}
fun newBase(): Base {
{ // BLOCK
<set-global>(<set-?> = <get-global>().plus(other = ":newBase"))
}
return BaseImpl(s = "test")
}
fun newBase2(): Base2 {
{ // BLOCK
<set-global>(<set-?> = <get-global>().plus(other = ":newBase2"))
}
return Base2Impl(s = "test")
}
class Derived : DerivedBase, Base, Base2 {
constructor() /* primary */ {
super/*DerivedBase*/()
/* <init>() */
}
private /* final field */ val $$delegate_0: Base = newBase()
override fun foo(x: String): String {
return <this>.#$$delegate_0.foo(x = x)
}
private /* final field */ val $$delegate_1: Base2 = newBase2()
override fun bar(x: String): String {
return <this>.#$$delegate_1.bar(x = x)
}
init {
{ // BLOCK
<set-global>(<set-?> = <get-global>().plus(other = ":Derived"))
}
}
}
class Derived1 : Base, DerivedBase, Base2 {
constructor() /* primary */ {
super/*DerivedBase*/()
/* <init>() */
}
private /* final field */ val $$delegate_0: Base = newBase()
override fun foo(x: String): String {
return <this>.#$$delegate_0.foo(x = x)
}
private /* final field */ val $$delegate_1: Base2 = newBase2()
override fun bar(x: String): String {
return <this>.#$$delegate_1.bar(x = x)
}
init {
{ // BLOCK
<set-global>(<set-?> = <get-global>().plus(other = ":Derived"))
}
}
}
class Derived2 : Base, Base2, DerivedBase {
constructor() /* primary */ {
super/*DerivedBase*/()
/* <init>() */
}
private /* final field */ val $$delegate_0: Base = newBase()
override fun foo(x: String): String {
return <this>.#$$delegate_0.foo(x = x)
}
private /* final field */ val $$delegate_1: Base2 = newBase2()
override fun bar(x: String): String {
return <this>.#$$delegate_1.bar(x = x)
}
init {
{ // BLOCK
<set-global>(<set-?> = <get-global>().plus(other = ":Derived"))
}
}
}
fun box(): String {
var d: Derived = Derived()
var d1: Derived1 = Derived1()
var d2: Derived2 = Derived2()
return "OK"
}