Files
kotlin-fork/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder1.fir.kt.txt
T
Dmitriy Novozhilov 3d6ec0ec75 [FIR2IR] Automatically store IR declaration in its parent upon creation
Previously, creating a declaration with Fir2IrCallableDeclarationsGenerator/
  Fir2IrClassifiersGenerator didn't guarantee that this declaration will
  be actually added to the list of parent class/file declarations, which
  lead to situations when FIR2IR created some declarations in the air
  (mostly fake-overrides)
2023-10-17 12:46:27 +00:00

90 lines
1.4 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
}
}
var global: String
field = ""
get
set
open class DerivedBase {
constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
init {
<set-global>(<set-?> = <get-global>().plus(other = ":DerivedBase"))
}
}
fun newBase(): Base {
<set-global>(<set-?> = <get-global>().plus(other = ":newBase"))
return BaseImpl(s = "test")
}
class Derived : DerivedBase, Base {
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)
}
init {
<set-global>(<set-?> = <get-global>().plus(other = ":Derived"))
}
}
class Derived1 : Base, 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)
}
init {
<set-global>(<set-?> = <get-global>().plus(other = ":Derived"))
}
}
fun box(): String {
var d: Derived = Derived()
var d1: Derived1 = Derived1()
return "OK"
}