From c16ea454e4862aa945aec834df1238fb4e4d8f17 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 28 Sep 2026 15:51:23 +0000 Subject: [PATCH] fix(commons): iOS test compile error and CharsetDecoder interop warnings Kotlin/Native rejects ',' in function names, so the backticked test name in UploadFallbackTest broke compileTestKotlinIosSimulatorArm64. Also opt into BetaInteropApi for NSData/NSString.create and drop the NSString-to-String? cast the compiler flags as only succeeding on null. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_019fqLYHsGZQLj55XxoB6RN7 --- .../commons/model/mediaServers/UploadFallbackTest.kt | 2 +- .../vitorpamplona/amethyst/commons/preview/CharsetDecoder.kt | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/model/mediaServers/UploadFallbackTest.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/model/mediaServers/UploadFallbackTest.kt index 9aeaee304e..4680301de8 100644 --- a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/model/mediaServers/UploadFallbackTest.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/model/mediaServers/UploadFallbackTest.kt @@ -34,7 +34,7 @@ class UploadFallbackTest { } @Test - fun `a server is never tried twice, even under another spelling`() { + fun `a server is never tried twice even under another spelling`() { val primalAgain = ServerName("primal", "https://BLOSSOM.PRIMAL.NET") assertEquals(listOf(primal, band), blossomUploadOrder(primal, listOf(primalAgain, band, band))) } diff --git a/commons/src/iosMain/kotlin/com/vitorpamplona/amethyst/commons/preview/CharsetDecoder.kt b/commons/src/iosMain/kotlin/com/vitorpamplona/amethyst/commons/preview/CharsetDecoder.kt index cf70fa5533..445fb83d3a 100644 --- a/commons/src/iosMain/kotlin/com/vitorpamplona/amethyst/commons/preview/CharsetDecoder.kt +++ b/commons/src/iosMain/kotlin/com/vitorpamplona/amethyst/commons/preview/CharsetDecoder.kt @@ -20,6 +20,7 @@ */ package com.vitorpamplona.amethyst.commons.preview +import kotlinx.cinterop.BetaInteropApi import kotlinx.cinterop.ExperimentalForeignApi import kotlinx.cinterop.addressOf import kotlinx.cinterop.usePinned @@ -41,7 +42,7 @@ import platform.Foundation.create * to their `NSStringEncoding`; anything else falls back to UTF-8 (matching the * "defaults to UTF-8" behaviour of the charset sniffer). */ -@OptIn(ExperimentalForeignApi::class) +@OptIn(ExperimentalForeignApi::class, BetaInteropApi::class) actual fun decodeBytes( bytes: ByteArray, charsetName: String?, @@ -55,7 +56,7 @@ actual fun decodeBytes( NSData.create(bytes = pinned.addressOf(0), length = bytes.size.toULong()) } - return (NSString.create(data, encoding) as String?) + return NSString.create(data = data, encoding = encoding)?.toString() ?: bytes.decodeToString() }