I've been experimenting with porting navigation with types here, and I just tried running in a wasmJs app, and I get this error:
illegal cast
RuntimeError: illegal cast
at <com.eygraber:wasmJsApp>.androidx.collection.commonGet (http://localhost:8080/nav-sample-wasm.wasm:wasm-function[20938]:0x3afa25)
at <com.eygraber:wasmJsApp>.androidx.collection.SparseArrayCompat.get (http://localhost:8080/nav-sample-wasm.wasm:wasm-function[21016]:0x3b1d4b)
at <com.eygraber:wasmJsApp>.androidx.navigation.NavGraph.findNode (http://localhost:8080/nav-sample-wasm.wasm:wasm-function[41678]:0x55ca60)
at <com.eygraber:wasmJsApp>.androidx.navigation.NavGraph.findNode (http://localhost:8080/nav-sample-wasm.wasm:wasm-function[41675]:0x55c9b7)
at <com.eygraber:wasmJsApp>.androidx.navigation.NavGraph.setStartDestination (http://localhost:8080/nav-sample-wasm.wasm:wasm-function[41689]:0x55cf09)
at <com.eygraber:wasmJsApp>.androidx.navigation.NavGraph.setStartDestination (http://localhost:8080/nav-sample-wasm.wasm:wasm-function[41688]:0x55ced8)
at <com.eygraber:wasmJsApp>.androidx.navigation.NavGraphBuilder.build (http://localhost:8080/nav-sample-wasm.wasm:wasm-function[41712]:0x55d734)
at <com.eygraber:wasmJsApp>.androidx.navigation.compose.navigation (http://localhost:8080/nav-sample-wasm.wasm:wasm-function[45157]:0x5a2b8d)
My thinking was that wasmJs doesn't like the cast to T since the actual type is E:
@Suppress("NOTHING_TO_INLINE")
private inline fun <E, T : E?> SparseArrayCompat<E>.internalGet(key: Int, defaultValue: T): T {
val i = binarySearch(keys, size, key)
return if (i < 0 || values[i] === DELETED) {
defaultValue
} else {
@Suppress("UNCHECKED_CAST")
values[i] as T
}
}
Changing the cast (and return type) to E fixes the problem:
@Suppress("NOTHING_TO_INLINE")
private inline fun <E, T : E?> SparseArrayCompat<E>.internalGet(key: Int, defaultValue: T): E {
val i = binarySearch(keys, size, key)
return if (i < 0 || values[i] === DELETED) {
@Suppress("UNCHECKED_CAST")
defaultValue as E
} else {
@Suppress("UNCHECKED_CAST")
values[i] as E
}
}
I don't think that's the actual solution though, because I think that will cause cast issues if the default is being used and it is null (although I'm not 100% sure).
I haven't tested with js. jvm works fine without changing the cast and return type.
Deploy to maven local with ./gradlew :mpp:publishComposeJbToMavenLocal -Pcompose.platforms=js,jvm,androidRelease,androidDebug,wasmJs -Pjetbrains.publication.version.COMPOSE=1.6.10-rc02 -Pjetbrains.publication.version.LIFECYCLE=2.8.0-rc01
Describe the bug
I've been experimenting with porting navigation with types here, and I just tried running in a wasmJs app, and I get this error:
My thinking was that wasmJs doesn't like the cast to
T
since the actual type isE
:Changing the cast (and return type) to
E
fixes the problem:I don't think that's the actual solution though, because I think that will cause cast issues if the default is being used and it is
null
(although I'm not 100% sure).I haven't tested with js. jvm works fine without changing the cast and return type.
Affected platforms
Versions
To Reproduce Steps to reproduce the behavior:
./gradlew :mpp:publishComposeJbToMavenLocal -Pcompose.platforms=js,jvm,androidRelease,androidDebug,wasmJs -Pjetbrains.publication.version.COMPOSE=1.6.10-rc02 -Pjetbrains.publication.version.LIFECYCLE=2.8.0-rc01
./gradlew :samples:nav:wasmJsApp:wasmJsBrowserRun