Introduce limited constant conversions for Kotlin/Native
#KT-25320 Fixed
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
// WITH_UNSIGNED
|
||||
|
||||
// FILE: signedToUnsignedConversions_annotation.kt
|
||||
|
||||
package kotlin.internal
|
||||
|
||||
annotation class ImplicitIntegerCoercion
|
||||
|
||||
// FILE: signedToUnsignedConversions_test.kt
|
||||
|
||||
import kotlin.internal.ImplicitIntegerCoercion
|
||||
|
||||
@ImplicitIntegerCoercion
|
||||
const val IMPLICIT_INT = 255
|
||||
|
||||
@ImplicitIntegerCoercion
|
||||
const val EXPLICIT_INT: Int = 255
|
||||
|
||||
@ImplicitIntegerCoercion
|
||||
const val LONG_CONST = 255L
|
||||
|
||||
@ImplicitIntegerCoercion
|
||||
val NON_CONST = 255
|
||||
|
||||
@ImplicitIntegerCoercion
|
||||
const val BIGGER_THAN_UBYTE = 256
|
||||
|
||||
@ImplicitIntegerCoercion
|
||||
const val UINT_CONST = 42u
|
||||
|
||||
fun takeUByte(@ImplicitIntegerCoercion u: UByte) {}
|
||||
fun takeUShort(@ImplicitIntegerCoercion u: UShort) {}
|
||||
fun takeUInt(@ImplicitIntegerCoercion u: UInt) {}
|
||||
fun takeULong(@ImplicitIntegerCoercion u: ULong) {}
|
||||
|
||||
fun takeUBytes(@ImplicitIntegerCoercion vararg u: UByte) {}
|
||||
|
||||
fun takeLong(@ImplicitIntegerCoercion l: Long) {}
|
||||
|
||||
fun test() {
|
||||
takeUByte(IMPLICIT_INT)
|
||||
takeUByte(EXPLICIT_INT)
|
||||
|
||||
takeUShort(IMPLICIT_INT)
|
||||
takeUShort(BIGGER_THAN_UBYTE)
|
||||
|
||||
takeUInt(IMPLICIT_INT)
|
||||
|
||||
takeULong(IMPLICIT_INT)
|
||||
|
||||
takeUBytes(IMPLICIT_INT, EXPLICIT_INT, 42u)
|
||||
|
||||
takeLong(IMPLICIT_INT)
|
||||
}
|
||||
Reference in New Issue
Block a user