[K2/N] IntegerLiteralType coercion only to unsigned integer types

^KT-57484 Fixed

Merge-request: KT-MR-10270
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
This commit is contained in:
Vladimir Sukharev
2023-05-24 07:56:14 +00:00
committed by Space Team
parent a534708900
commit fde8909e6f
12 changed files with 195 additions and 5 deletions
@@ -0,0 +1,38 @@
// TARGET_BACKEND: JVM_IR
// TARGET_BACKEND: NATIVE
// IGNORE_BACKEND_K1: NATIVE
// !LANGUAGE: +MultiPlatformProjects +ImplicitSignedToUnsignedIntegerConversion
// WITH_STDLIB
// MODULE: common
// TARGET_PLATFORM: Common
// FILE: annotation.kt
package kotlin.internal
annotation class ImplicitIntegerCoercion
// FILE: common.kt
import kotlin.internal.ImplicitIntegerCoercion
expect class Signed
expect value class Unsigned internal constructor(internal val data: Signed)
class FooUnsigned {
constructor(@ImplicitIntegerCoercion x: Unsigned) {}
constructor(@ImplicitIntegerCoercion y: String) {}
}
// MODULE: platform()()(common)
// FILE: platform.kt
actual typealias Signed = Int
actual typealias Unsigned = UInt
fun box(): String {
FooUnsigned(42) // coercion
FooUnsigned(42u) // match
FooUnsigned("42") // match
return "OK"
}