KT-16436 Incorrect primitive constants handling

Expression '1.unaryMinus()' is resolved as Int::unaryMinus call with Int receiver.
However, this expression is implicitly coerced to a different integral type (Byte, Short, Long)
based on results of constant evaluation.

Introduce IMPLICIT_INTEGER_COERCION type operator to handle such cases.

TODO: should we use it for simple constant expressions like '1' and '-1'?
This commit is contained in:
Dmitry Petrov
2017-02-27 17:32:39 +03:00
parent d0134f2c64
commit e66c2621af
5 changed files with 58 additions and 17 deletions
@@ -0,0 +1,9 @@
fun test() {
val test1: Int? = 42
val test2: Long = 42
val test3: Long? = 42
val test4: Long? = -1
val test5: Long? = 1.unaryMinus()
val test6: Short? = 1.unaryMinus()
val test7: Byte? = 1.unaryMinus()
}