Ensure type of a stack value is coerced to the expected return type after the binary operation instruction with the different return type.

This commit is contained in:
Ilya Gorbunov
2015-07-11 16:09:22 +03:00
parent f7ccb3819e
commit 4ad6a8e301
6 changed files with 55 additions and 9 deletions
+14
View File
@@ -0,0 +1,14 @@
fun box(): String {
val a: Long = 2147483647 + 1
if (a != -2147483648L) return "fail: in this case we should add to ints and than cast the result to long - overflow expected"
val l1 = Long.MAX_VALUE
val l2 = l1 + 1
if (l2 > l1) return "fail: Long.MAX_VALUE + 1 should overflow to negative."
val l3 = Long.MIN_VALUE
val l4 = l3 - 1
if (l4 < l3) return "fail: Long.MIN_VALUE - 1 should overflow to positive."
return "OK"
}