Files
kotlin-fork/compiler/testData/codegen/box/intrinsics/tostring.kt
T
Juan Chen 3dc58bc995 [FIR2IR] Fix translating primitive array types
This commit fixes two issues in the existing implementation of translating primitive array types:

 * IrType.getArrayElementType throws an exception when the receiver is a primitive array type, because IR expects primitive array types use symbols defined in IrBuiltIns, but fir2ir translation doesn't;
 * IteratorNext.toCallable assumes all element types are boxed.

The first issue is fixed by changing the fir2ir type translation to use symbols in IrBuiltIns for primitive array types, and the second by not unboxing primitive types.
2019-12-27 15:32:18 +03:00

28 lines
1.7 KiB
Kotlin
Vendored

// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS
fun box(): String {
if (239.toByte().toString() != (239.toByte() as Byte?).toString()) return "byte failed"
if (239.toShort().toString() != (239.toShort() as Short?).toString()) return "short failed"
if (239.toInt().toString() != (239.toInt() as Int?).toString()) return "int failed"
if (239.toFloat().toString() != (239.toFloat() as Float?).toString()) return "float failed"
if (239.toLong().toString() != (239.toLong() as Long?).toString()) return "long failed"
if (239.toDouble().toString() != (239.toDouble() as Double?).toString()) return "double failed"
if (true.toString() != (true as Boolean?).toString()) return "boolean failed"
if ('a'.toChar().toString() != ('a'.toChar() as Char?).toString()) return "char failed"
if ("${239.toByte()}" != (239.toByte() as Byte?).toString()) return "byte template failed"
if ("${239.toShort()}" != (239.toShort() as Short?).toString()) return "short template failed"
if ("${239.toInt()}" != (239.toInt() as Int?).toString()) return "int template failed"
if ("${239.toFloat()}" != (239.toFloat() as Float?).toString()) return "float template failed"
if ("${239.toLong()}" != (239.toLong() as Long?).toString()) return "long template failed"
if ("${239.toDouble()}" != (239.toDouble() as Double?).toString()) return "double template failed"
if ("${true}" != (true as Boolean?).toString()) return "boolean template failed"
if ("${'a'.toChar()}" != ('a'.toChar() as Char?).toString()) return "char template failed"
for(b in 0..255) {
if("${b.toByte()}" != (b.toByte() as Byte?).toString()) return "byte conversion failed"
}
return "OK"
}