KT-11030 Minor code improvements
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
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 D() {
|
||||
var baz: () -> Int = { 0 }
|
||||
constructor(b: Boolean) : this() {
|
||||
baz = { x + this@B.x }
|
||||
}
|
||||
fun bar() = { x + this@B.x }
|
||||
}
|
||||
}
|
||||
}
|
||||
return B(3).C(2).D().bar()() + B(5).C(4).D(true).baz()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(2345, A().test())
|
||||
return "OK"
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
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 D() {
|
||||
fun baz() = bar()
|
||||
}
|
||||
|
||||
fun D.bar() = { x + this@B.x }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return B(3).C(2).D().baz()()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(23, A().test())
|
||||
return "OK"
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package foo
|
||||
|
||||
class A {
|
||||
fun test() = 23
|
||||
}
|
||||
|
||||
fun <T : A> T.foo(): Int {
|
||||
class B {
|
||||
fun foo() = test()
|
||||
}
|
||||
return B().foo()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(23, A().foo())
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user