[K/N] Supported outer this references from cached inline bodies

This commit is contained in:
Igor Chevdar
2021-09-16 10:37:59 +05:00
parent da02d25278
commit cb71240938
16 changed files with 268 additions and 89 deletions
@@ -0,0 +1,13 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
open class Outer(val x: Int) {
open inner class Inner1
inner class Middle(x: Int) : Outer(x) {
inner class Inner2 : Inner1() {
fun foo() = this@Outer.x + this@Middle.x
}
}
}
@@ -0,0 +1,9 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
fun main() {
val o = Outer(42).Middle(117).Inner2()
println(o.foo())
}
@@ -0,0 +1,14 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
open class Outer {
open inner class Inner1
inner class Middle {
inner class Inner2 : Inner1() {
fun getOuter() = this@Outer
fun getMiddle() = this@Middle
}
}
}
@@ -0,0 +1,10 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
fun main() {
val o = Outer().Middle().Inner2()
println(o.getOuter() != Outer())
println(o.getMiddle() != Outer().Middle())
}
@@ -0,0 +1,10 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
open class Foo(val z: Int) {
open inner class FooInner {
fun foo() = z
}
}
@@ -0,0 +1,14 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
class Bar : Foo(42) {
inner class BarInner(val x: Int) : FooInner()
}
fun main() {
val o = Bar().BarInner(117)
println(o.x)
println(o.foo())
}