Test for KT-14381 and KT-13597

This commit is contained in:
Mikhail Glukhikh
2017-04-27 12:55:35 +03:00
committed by Mikhail Glukhikh
parent fbc1d1a844
commit 8fa739ed0f
3 changed files with 81 additions and 0 deletions
@@ -0,0 +1,48 @@
// Tests for KT-13597 (val assignment inside local object in constructor)
class Test {
val a: String
init {
val t = object {
fun some() {
// See KT-13597
a = "12"
}
}
a = "2"
t.some()
}
}
class Test2 {
init {
val t = object {
fun some() {
<!VAL_REASSIGNMENT!>a<!> = "12"
}
}
<!INITIALIZATION_BEFORE_DECLARATION!>a<!> = "2"
t.some()
}
val a: String
}
// Tests for KT-14381 (val assignment inside lambda in constructor)
fun <T> exec(f: () -> T): T = f()
class Test4 {
val a: String
init {
exec {
// See KT-14381
a = "12"
}
a = "34"
}
}