'when' should use intrinsics for '=='

#KT-19029 Fixed Target versions 1.1.5
 #KT-18818 Fixed Target versions 1.1.5
This commit is contained in:
Dmitry Petrov
2017-07-17 14:43:37 +03:00
parent 20cd748377
commit 2ed5a5e368
13 changed files with 281 additions and 51 deletions
@@ -0,0 +1,19 @@
var subjectEvaluated = 0
fun String.foo() = length.also { ++subjectEvaluated }
fun test(s: String?) =
when (s?.foo()) {
0 -> "zero"
1 -> "one"
2 -> "two"
else -> "other"
}
fun box(): String {
val t = test("12")
if (t != "two") return "Fail: $t"
if (subjectEvaluated != 1) return "Fail: subjectEvaluated=$subjectEvaluated"
return "OK"
}