https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
j

James Ward

09/21/2023, 4:34 AM
Maybe already covered but would it make sense to enable running
commonTest
tests without a platform for pure Kotlin/Common code?
j

jw

09/21/2023, 4:52 AM
How would they run? Common code is only considered common because it's a subset of a set of selected targets.
👍 3
👍🏻 1
👍🏾 1
j

James Ward

09/21/2023, 5:39 PM
Theoretically couldn't we have a Kotlin/Common runtime that has no platform?
j

jw

09/21/2023, 5:41 PM
What semantics would it have though? Would it be single threaded like JS and WASM or multithreaded like JVM and native? What actuals would be used for expect definitions?
There's no definition for common Kotlin because common actually means common-to-your-defined-targets. A project with only iOS and macOS targets can access Darwin APIs in common, for example.
Moreover the addition of new targets can change what common means. If you only support JVM and native you can use things like runBlocking from coroutines in common. But if you add JS or WASM that now fails to compile because those targets don't support it.
j

James Ward

09/21/2023, 5:45 PM
Yeah, expects couldn't work, but could non-expects work? ie. could you test
1 + 1 == 2
without a platform? Maybe way to limited for real use.
j

jw

09/21/2023, 5:48 PM
I think the closest you could get is constant expressions and constant functions where the compiler defines a subset of the language that can be interpreted at compile time with platform-agnostic semantics. https://youtrack.jetbrains.com/issue/KT-14652