[FIR] Report ASSIGNMENT_TYPE_MISMATCH on properties with numeric types
^KT-46047 ^KT-56951 Fixed
This commit is contained in:
committed by
Space Team
parent
f7733e819d
commit
71d6103122
@@ -0,0 +1,20 @@
|
||||
fun <T> assertEquals(a: T, b: T) {
|
||||
if (a != b) throw AssertionError("$a != $b")
|
||||
}
|
||||
|
||||
fun main() {
|
||||
val bytePos = 128.toByte() // Byte.MAX_VALUE + 1
|
||||
assertEquals(-128, bytePos.toInt()) // correct, wrapped to Byte.MIN_VALUE
|
||||
|
||||
val byteNeg: Byte = <!INITIALIZER_TYPE_MISMATCH, TYPE_MISMATCH!>-bytePos<!> // should not compile, byteNeg should be Int
|
||||
assertEquals(128, byteNeg.toInt()) // passes, should not be possible
|
||||
|
||||
val shortPos = 32768.toShort() // Short.MAX_VALUE + 1
|
||||
assertEquals(-32768, shortPos.toInt()) // correct, wrapped to Short.MIN_VALUE
|
||||
|
||||
val shortNeg: Short = <!INITIALIZER_TYPE_MISMATCH, TYPE_MISMATCH!>-shortPos<!> // should not compile, shortNeg should be Int
|
||||
assertEquals(32768, shortNeg.toInt()) // passes, should not be possible
|
||||
|
||||
(-128).toByte()
|
||||
-128.toByte()
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
// FIR_IDENTICAL
|
||||
fun <T> assertEquals(a: T, b: T) {
|
||||
if (a != b) throw AssertionError("$a != $b")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user