mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-09 08:31:29 +00:00
There is a lot of changes about closures calculating and generating. 1. As classes can have more than one constructor each of them should have closure arguments. 2. Captured variables set is the same for all of them. 3. Within constructors bodies/delegating calls closure parameters should be accessed through method arguments because fields may be not initialized yet.
21 lines
374 B
Kotlin
Vendored
21 lines
374 B
Kotlin
Vendored
open class A<T> {
|
|
val prop: String
|
|
constructor(x: String) {
|
|
prop = x
|
|
}
|
|
constructor(x: T) {
|
|
prop = x.toString()
|
|
}
|
|
|
|
override fun toString() = prop
|
|
}
|
|
|
|
fun box(): String {
|
|
val a1 = WithGenerics.foo1()
|
|
if (a1 != "OK") return "fail1: $a1"
|
|
val a2 = WithGenerics.foo2()
|
|
if (a2 != "123") return "fail2: $a2"
|
|
|
|
return "OK"
|
|
}
|