JS backend: fix missed variable declarations for tmps in class primary/default constructor

#KT-7864 Fixed
This commit is contained in:
Zalim Bashorov
2015-05-29 17:35:05 +03:00
parent e0f819d93c
commit f1d37572c8
4 changed files with 71 additions and 21 deletions
@@ -0,0 +1,37 @@
package foo
val x: Int?
get() = null
// Note: `x ?: 2` expression used to force to create tempary variable
class A {
val a = x ?: 2
}
enum class E(val a: Int = 0) {
X(),
Y() {
val y = x ?: 4
override fun value() = y
},
val e = x ?: 3
open fun value() = e
}
open class B(val b: Int)
class C : B(x ?: 6)
fun box(): String {
assertEquals(2, A().a)
assertEquals(3, E.X.e)
assertEquals(4, E.Y.value())
assertEquals(6, C().b)
return "OK"
}