cla-bot ยท GitHub

A generic `@inline(__always)` function is emitted as a Kotlin
`inline fun <reified T>`, which has no JVM-callable method. The bridge
generator nonetheless emitted a `getMethodID(...)!` JNI lookup for it,
so the force-unwrap trapped at class load ("Unexpectedly found nil while
unwrapping an Optional value") for any native-Swift-on-Android caller.
This reproduces whenever the reified method lives on an `open` class that
has a subclass (the method is then lifted to a top-level `inline fun
<reified T>` extension and bridged via `getStaticMethodID`) โ€” the root
cause behind skiptools/skip-firebase#81 and the still-open skiptools#91.
Return nil from `KotlinFunctionDeclaration.checkBridgable` for a generic
`@inline(__always)` function so it is not JNI-bridged. Native-Swift
callers use the `@inline(__always)` Swift body directly (inlined); Kotlin
callers use the `inline fun <reified T>`. An inline reified function was
never JNI-callable to begin with, so nothing is lost.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
A `// SKIP DECLARE: ... inline fun <reified T> ...` override produces the
same JVM-uncallable Kotlin as @inline(__always) but carries no structured
attribute, so the attribute guard alone left the crash reachable via
skip-firebase's FirestoreDecoder.decode(from:) (called from the inlined
body of DocumentSnapshot.decoded()) โ€” i.e. skiptools#91 was not fully closed.
Also bail out of bridging when the declaration override is an inline
reified function.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@marcprux

Read the original on github.com โ†—