JS: fix absence of temporary variable in secondary constructors. See KT-16377

This commit is contained in:
Alexey Andreev
2017-02-15 17:58:12 +03:00
committed by Alexey Andreev
parent 3b222f13f3
commit 86d1c7b7ec
4 changed files with 56 additions and 2 deletions
@@ -0,0 +1,22 @@
// HAS_NO_CAPTURED_VARS: function=A_init except=Kotlin;A
class A() {
var y: String? = null
var z: Any? = null
constructor(x: Any) : this() {
y = if (x == "foo") "!!!" else { z = x; ">>>" }
}
}
fun box(): String {
val a = A("foo")
if (a.y != "!!!") return "fail1: ${a.y}"
if (a.z != null) return "fail2: ${a.z}"
val b = A(23)
if (b.y != ">>>") return "fail3: ${b.y}"
if (b.z != 23) return "fail4: ${b.z}"
return "OK"
}