vgrechka
09/14/2016, 12:16 PMfun test1() {
class B {
val value = "qweqwe"
}
class A(val b: B) {
val value = when {
true -> b.value
else -> "lalala"
}
}
val a = A(B())
println(a.value)
}
Execution result:
E:\work\kotlin-js-playground>node run.js test1
Running test1
E:\work\kotlin-js-playground\out\production\kotlin-js-playground\kotlin-js-playground.js:10
tmp$0 = this.b.value;
^
TypeError: Cannot read property 'value' of undefined
at new <anonymous> (E:\work\kotlin-js-playground\out\production\kotlin-js-playground\kotlin-js-playground.js:10:23)
Piece of generated JS:
test1$A: Kotlin.createClass(null, function (b) {
var tmp$0;
if (true)
tmp$0 = this.b.value; // <-- Error here
else
tmp$0 = 'lalala';
this.b = b; // <-- This should be above [if]
this.value = tmp$0;
}),