Replies: 2 comments 3 replies
-
|
It works for me on Kotlin 1.6.21 at the command line. In IntelliJ the symbol doesn’t resolve. I consider this to be a bug in IntelliJ. |
Beta Was this translation helpful? Give feedback.
3 replies
-
|
When using v3.1.0, reference to FileSystem.SYSTEM inside common source will fail the compiler. Define a custom actual/expect to use FileSystem can avoid the error before new version was shipped.😅 internal expect fun defaultFileSystem(): FileSysteminternal actual fun defaultFileSystem(): FileSystem {
return FileSystem.SYSTEM
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am developing an app for JVM, LinuxX64, MingwX64 and MacosX64 targets. I am trying to place common logic in a common source set for all four targets like this (Okio 3.1.0, Kotlin 1.6.21 with HMPP enabled, Gradle 7.4.2):
plugins { kotlin("multiplatform") version "1.6.21" } repositories { mavenCentral() } kotlin { jvm() val nativeTargets = listOf(linuxX64(), mingwX64(), macosX64()) sourceSets { val commonMain by getting val commonTest by getting val commonNonJsMain by creating { dependsOn(commonMain) dependencies { api("com.squareup.okio:okio:3.1.0") } } val commonNonJsTest by creating { dependsOn(commonTest) dependencies { implementation(kotlin("test-common")) implementation(kotlin("test-annotations-common")) } } val jvmMain by getting { dependsOn(commonNonJsMain) } val jvmTest by getting { dependsOn(commonNonJsTest) dependencies { implementation(kotlin("test-junit5")) implementation("org.junit.jupiter:junit-jupiter-engine:5.8.2") } } nativeTargets.forEach { getByName("${it.name}Main").dependsOn(commonNonJsMain) } nativeTargets.forEach { getByName("${it.name}Test").dependsOn(commonNonJsTest) } } }and then use this source set like this:
src/commonNonJsMain/kotlin/org/example/Main.kt:However, this code doesn't compile. This can be fixed by adding
expect val FileSystem.SYSTEMincommonNonJsMainand addingactualdeclarations in just two source sets:jvmMainandnativeMain. Is it supposed to be working like this or am I doing something wrong? I suspect that the reason may be that there is noexpect val SYSTEMin any high-level source set in Okio;FileSystem.SYSTEMjust appears in some of target source sets, unlike e.g.runBlockingin this example.Also, disabling HMPP by adding
kotlin.mpp.hierarchicalStructureSupport=falseingradle.propertiesmakes this example compile, even though symbols are still unresolved in IDEA.Beta Was this translation helpful? Give feedback.
All reactions