KT-11996 Fix issue with referencing outer class in case of inner class constructors and members/properties. Fix issue with referencing outer classes from secondary constructors. Remove unnecessary tests.
This commit is contained in:
@@ -3,13 +3,13 @@ package foo
|
||||
class A() {
|
||||
fun test(): Int {
|
||||
open class B(open val x: Int) {
|
||||
inner class C(override val x: Int) : B(x * 10) {
|
||||
inner class C(x: Int) : B(x * 10) {
|
||||
inner class D() {
|
||||
var baz: () -> Int = { 0 }
|
||||
constructor(b: Boolean) : this() {
|
||||
baz = { x + this@B.x }
|
||||
}
|
||||
fun bar() = { x + this@B.x }
|
||||
fun bar() = { 100 * (x + this@B.x) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ package foo
|
||||
class A() {
|
||||
fun test(): Int {
|
||||
open class B(open val x: Int) {
|
||||
inner class C(override val x: Int) : B(x * 10) {
|
||||
inner class C(x: Int) : B(x * 10) {
|
||||
inner class D() {
|
||||
fun baz() = bar()
|
||||
}
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package foo
|
||||
|
||||
class A(val x: Int) {
|
||||
inner class B() {
|
||||
inner class C() {
|
||||
var result = 0
|
||||
|
||||
constructor(y: Boolean) : this() {
|
||||
result = x
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(23, A(23).B().C(true).result)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package foo
|
||||
|
||||
open class A(private val bar: String = "1") {
|
||||
inner class B : A("2") {
|
||||
fun foo(a: A): String {
|
||||
return bar + a.bar
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var r = ""
|
||||
|
||||
r = A().B().foo(A("3"))
|
||||
if (r != "13") return "r = $r"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user