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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019fqLYHsGZQLj55XxoB6RN7
This commit is contained in:
Claude
2026-09-28 15:51:23 +00:00
parent 09b491e0fd
commit c16ea454e4
2 changed files with 4 additions and 3 deletions
@@ -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)))
}
@@ -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()
}