KT-4173: Can't pass a non-trivial closure to a super-call for object expression
#KT-4173 Fixed
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
open class C(val f: () -> Unit) {
|
||||
fun test() {
|
||||
f()
|
||||
}
|
||||
}
|
||||
|
||||
class B(var x: Int) {
|
||||
fun foo() {
|
||||
object : C({x = 3}) {}.test()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun box() : String {
|
||||
val b = B(1)
|
||||
b.foo()
|
||||
return if (b.x != 3) "fail: b.x = ${b.x}" else "OK"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
open class X(var s: ()-> Unit)
|
||||
|
||||
open class C(val f: X) {
|
||||
fun test() {
|
||||
f.s()
|
||||
}
|
||||
}
|
||||
|
||||
class B(var x: Int) {
|
||||
fun foo() {
|
||||
object : C(object: X({x = 3}) {}) {}.test()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun box() : String {
|
||||
val b = B(1)
|
||||
b.foo()
|
||||
return if (b.x != 3) "fail: b.x = ${b.x}" else "OK"
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
open class C(s: Int) {
|
||||
fun test() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class B(var x: Int) {
|
||||
fun foo() {
|
||||
class A(val a: Int) : C({a}()) {
|
||||
|
||||
}
|
||||
A(11).test()
|
||||
|
||||
|
||||
class B(val a: Int) : C(a) {
|
||||
}
|
||||
|
||||
B(11).test()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun box() : String {
|
||||
val b = B(1)
|
||||
b.foo()
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user