[FIR] Freeze the current behavior of ImplicitIntegerCoercion+overloads

Adding the tests "just in case", ensuring the
K2 behaves similar to K1.
This commit is contained in:
Nikolay Lunyak
2023-04-24 15:14:51 +03:00
committed by Space Team
parent 931894ab3c
commit f3ca465647
7 changed files with 80 additions and 0 deletions
@@ -0,0 +1,25 @@
// ISSUE: KT-57655
// !LANGUAGE: +ImplicitSignedToUnsignedIntegerConversion
// ALLOW_KOTLIN_PACKAGE
// FILE: annotation.kt
package kotlin.internal
annotation class ImplicitIntegerCoercion
// FILE: test.kt
import kotlin.internal.ImplicitIntegerCoercion
fun test(@ImplicitIntegerCoercion x: UInt) = x
fun test(@ImplicitIntegerCoercion x: ULong) = x
fun testLong(@ImplicitIntegerCoercion x: ULong) = x
fun box(): String = when {
test(5) != 5.toUInt() -> "Fail: test(5)"
<!NONE_APPLICABLE!>test<!>(5L) != 5L.toULong() -> "Fail: test(5L)"
testLong(5) != 5L.toULong() -> "Fail: test(5L)"
testLong(<!ARGUMENT_TYPE_MISMATCH!>5L<!>) != 5L.toULong() -> "Fail: test(5L)"
else -> "OK"
}
@@ -0,0 +1,25 @@
// ISSUE: KT-57655
// !LANGUAGE: +ImplicitSignedToUnsignedIntegerConversion
// ALLOW_KOTLIN_PACKAGE
// FILE: annotation.kt
package kotlin.internal
annotation class ImplicitIntegerCoercion
// FILE: test.kt
import kotlin.internal.ImplicitIntegerCoercion
fun test(@ImplicitIntegerCoercion x: UInt) = x
fun test(@ImplicitIntegerCoercion x: ULong) = x
fun testLong(@ImplicitIntegerCoercion x: ULong) = x
fun box(): String = when {
test(5) != 5.toUInt() -> "Fail: test(5)"
<!EQUALITY_NOT_APPLICABLE!>test(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>5L<!>) != 5L.toULong()<!> -> "Fail: test(5L)"
testLong(5) != 5L.toULong() -> "Fail: test(5L)"
testLong(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>5L<!>) != 5L.toULong() -> "Fail: test(5L)"
else -> "OK"
}