Introduce limited constant conversions for Kotlin/Native

#KT-25320 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2018-07-16 15:59:21 +03:00
parent 1a51132884
commit acd5b62148
15 changed files with 735 additions and 37 deletions
@@ -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)
}