Fix deprecations in Native
diff --git a/kotlin-native/Interop/Runtime/src/main/kotlin/kotlinx/cinterop/Utils.kt b/kotlin-native/Interop/Runtime/src/main/kotlin/kotlinx/cinterop/Utils.kt
index 0f74241..79849fd 100644
--- a/kotlin-native/Interop/Runtime/src/main/kotlin/kotlinx/cinterop/Utils.kt
+++ b/kotlin-native/Interop/Runtime/src/main/kotlin/kotlinx/cinterop/Utils.kt
@@ -479,12 +479,12 @@
var indexIn = 0
var indexOut = 0
while (indexIn < chars.size) {
- var value = chars[indexIn++].toInt()
+ var value = chars[indexIn++].code
if (value >= 0xd800 && value < 0xdc00) {
// Surrogate pair.
if (indexIn >= chars.size - 1) throw IllegalArgumentException()
indexIn++
- val next = chars[indexIn].toInt()
+ val next = chars[indexIn].code
if (next < 0xdc00 || next >= 0xe000) throw IllegalArgumentException()
value = 0x10000 + ((value and 0x3ff) shl 10) + (next and 0x3ff)
}
@@ -527,7 +527,7 @@
val chars = CharArray(length)
var index = 0
while (index < length) {
- chars[index] = nativeBytes[index].toChar()
+ chars[index] = nativeBytes[index].toUShort().let(::Char)
++index
}
return chars.concatToString()
@@ -556,10 +556,10 @@
while (toIndex < length) {
var value = nativeBytes[fromIndex++]
if (value >= 0x10000 && value <= 0x10ffff) {
- chars[toIndex++] = (((value - 0x10000) shr 10) or 0xd800).toChar()
- chars[toIndex++] = (((value - 0x10000) and 0x3ff) or 0xdc00).toChar()
+ chars[toIndex++] = (((value - 0x10000) shr 10) or 0xd800).toUShort().let(::Char)
+ chars[toIndex++] = (((value - 0x10000) and 0x3ff) or 0xdc00).toUShort().let(::Char)
} else {
- chars[toIndex++] = value.toChar()
+ chars[toIndex++] = value.toUShort().let(::Char)
}
}
return chars.concatToString()
diff --git a/kotlin-native/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/CodeUtils.kt b/kotlin-native/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/CodeUtils.kt
index 6ad1baf..95e313e 100644
--- a/kotlin-native/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/CodeUtils.kt
+++ b/kotlin-native/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/CodeUtils.kt
@@ -71,7 +71,7 @@
when (c) {
in charactersAllowedInKotlinStringLiterals -> append(c)
'$' -> append("\\$")
- else -> append("\\u" + "%04X".format(c.toInt()))
+ else -> append("\\u" + "%04X".format(c.code))
}
}
diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IntrinsicGenerator.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IntrinsicGenerator.kt
index 1ca324a..c73de10 100644
--- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IntrinsicGenerator.kt
+++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IntrinsicGenerator.kt
@@ -735,7 +735,7 @@
private fun makeConstOfType(type: LLVMTypeRef, value: Int): LLVMValueRef = when (type) {
int8Type -> Int8(value.toByte()).llvm
- int16Type -> Char16(value.toChar()).llvm
+ int16Type -> Char16(value.toUShort().let(::Char)).llvm
int32Type -> Int32(value).llvm
int64Type -> Int64(value.toLong()).llvm
floatType -> Float32(value.toFloat()).llvm
diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt
index d69ad7e..1263581 100644
--- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt
+++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt
@@ -1613,7 +1613,7 @@
IrConstKind.Null -> true
IrConstKind.Boolean -> (value.value as Boolean) == false
IrConstKind.Byte -> (value.value as Byte) == 0.toByte()
- IrConstKind.Char -> (value.value as Char) == 0.toChar()
+ IrConstKind.Char -> (value.value as Char) == Char(0)
IrConstKind.Short -> (value.value as Short) == 0.toShort()
IrConstKind.Int -> (value.value as Int) == 0
IrConstKind.Long -> (value.value as Long) == 0L
diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/LlvmUtils.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/LlvmUtils.kt
index 480dff8..29d536b 100644
--- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/LlvmUtils.kt
+++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/LlvmUtils.kt
@@ -128,7 +128,7 @@
}
internal class Char16(val value: Char) : ConstValue {
- override val llvm = LLVMConstInt(int16Type, value.toLong(), 1)!!
+ override val llvm = LLVMConstInt(int16Type, value.code.toLong(), 1)!!
}
internal class Int32(val value: Int) : ConstValue {
diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/StaticData.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/StaticData.kt
index 8b27ff9..b0efffa 100644
--- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/StaticData.kt
+++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/StaticData.kt
@@ -173,6 +173,6 @@
* @param args data for constant creation.
*/
internal fun StaticData.createImmutableBlob(value: IrConst<String>): LLVMValueRef {
- val args = value.value.map { Int8(it.toByte()).llvm }
+ val args = value.value.map { Int8(it.code.toByte()).llvm }
return createConstKotlinArray(context.ir.symbols.immutableBlob.owner, args)
}
\ No newline at end of file
diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/KonanDefaultParameterInjector.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/KonanDefaultParameterInjector.kt
index d6cb01a..4f2f0ab5 100644
--- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/KonanDefaultParameterInjector.kt
+++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/KonanDefaultParameterInjector.kt
@@ -23,7 +23,7 @@
PrimitiveBinaryType.BOOLEAN -> IrConstImpl.boolean(startOffset, endOffset, type, false)
PrimitiveBinaryType.BYTE -> IrConstImpl.byte(startOffset, endOffset, type, 0)
PrimitiveBinaryType.SHORT -> when (type.getInlinedClassNative()) {
- context.irBuiltIns.char -> IrConstImpl.char(startOffset, endOffset, type, 0.toChar())
+ context.irBuiltIns.char -> IrConstImpl.char(startOffset, endOffset, type, Char(0))
else -> IrConstImpl.short(startOffset, endOffset, type, 0)
}
PrimitiveBinaryType.INT -> IrConstImpl.int(startOffset, endOffset, type, 0)
diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/PostInlineLowering.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/PostInlineLowering.kt
index bd4ad0a..cdc47ce 100644
--- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/PostInlineLowering.kt
+++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/PostInlineLowering.kt
@@ -87,7 +87,7 @@
// Luckily, all values in range 0x00 .. 0xff represent valid UTF-16 symbols,
// block 0 (Basic Latin) and block 1 (Latin-1 Supplement) in
// Basic Multilingual Plane, so we could just append data "as is".
- builder.append(value.toChar())
+ builder.append(value.toUShort().let(::Char))
}
expression.putValueArgument(0, IrConstImpl(
expression.startOffset, expression.endOffset,