[JS BE] Support val in when subject

#KT-25014 Fixed
This commit is contained in:
Zalim Bashorov
2018-08-02 13:28:53 +03:00
parent 289ff845c4
commit 3c765e3625
15 changed files with 82 additions and 59 deletions
@@ -1,22 +1,32 @@
// !LANGUAGE: +VariableDeclarationInWhenSubject +ProperIeee754Comparisons
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND: JS, JS_IR
// IGNORE_BACKEND: JS_IR
val az: Any = -0.0
val afz: Any = -0.0f
fun box(): String {
when (val y = az) {
val y = az
when (y) {
!is Double -> throw AssertionError()
0.0 -> {}
else -> throw AssertionError()
}
when (val y = afz) {
val yy = afz
when (yy) {
!is Float -> throw AssertionError()
0.0 -> {}
else -> throw AssertionError()
}
testDoubleAsUpperBound(-0.0)
return "OK"
}
}
fun <T: Double> testDoubleAsUpperBound(v: T): Boolean {
return when (val a = v*v) {
0.0 -> true
else -> throw AssertionError()
}
}