KT-4173: Can't pass a non-trivial closure to a super-call for object expression

#KT-4173 Fixed
This commit is contained in:
Mikhael Bogdanov
2013-11-08 13:58:58 +04:00
parent 2c75bdacc5
commit df03eb5330
5 changed files with 151 additions and 22 deletions
@@ -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"
}