diff --git a/SKIE/acceptance-tests b/SKIE/acceptance-tests index 1e780aa5..b0f9f6f1 160000 --- a/SKIE/acceptance-tests +++ b/SKIE/acceptance-tests @@ -1 +1 @@ -Subproject commit 1e780aa506a8f5a0c6a08006a5592326a6d48624 +Subproject commit b0f9f6f17a0ecf1d7582023781668a1fb6efa1a5 diff --git a/SKIE/compiler/kotlin-plugin/src/kgp_common/kotlin/co/touchlab/skie/sir/SirFileProvider.kt b/SKIE/compiler/kotlin-plugin/src/kgp_common/kotlin/co/touchlab/skie/sir/SirFileProvider.kt index d53e8f95..920a6324 100644 --- a/SKIE/compiler/kotlin-plugin/src/kgp_common/kotlin/co/touchlab/skie/sir/SirFileProvider.kt +++ b/SKIE/compiler/kotlin-plugin/src/kgp_common/kotlin/co/touchlab/skie/sir/SirFileProvider.kt @@ -9,6 +9,7 @@ import co.touchlab.skie.util.cache.writeTextIfDifferent import co.touchlab.skie.util.directory.SkieBuildDirectory import java.nio.file.Path import kotlin.io.path.absolute +import kotlin.io.path.absolutePathString import kotlin.io.path.extension class SirFileProvider( @@ -17,11 +18,11 @@ class SirFileProvider( private val skieBuildDirectory: SkieBuildDirectory, ) { - private val irFileByPathCache = mutableMapOf() + private val irFileByPathCache = mutableMapOf() - private val writtenSourceFileByPathCache = mutableMapOf() + private val writtenSourceFileByPathCache = mutableMapOf() - private val generatedSourceFileByPathCache = mutableMapOf() + private val generatedSourceFileByPathCache = mutableMapOf() private val skieNamespace: String get() = kirProvider.skieModule.name @@ -29,21 +30,21 @@ class SirFileProvider( fun getWrittenSourceFileFromSkieNamespace(name: String): SirSourceFile { val path = relativePath(skieNamespace, name) - check(path !in generatedSourceFileByPathCache) { + check(path.asCacheKey !in generatedSourceFileByPathCache) { "Generated source file for $path already exists. Combining written and generated source files is not supported." } - return writtenSourceFileByPathCache.getOrPut(path) { + return writtenSourceFileByPathCache.getOrPut(path.asCacheKey) { SirSourceFile(skieModule, path) } } fun getGeneratedSourceFile(irFile: SirIrFile): SirSourceFile { - check(irFile.relativePath !in writtenSourceFileByPathCache) { + check(irFile.relativePath.asCacheKey !in writtenSourceFileByPathCache) { "Written source file for ${irFile.relativePath} already exists. Combining written and generated source files is not supported." } - return generatedSourceFileByPathCache.getOrPut(irFile.relativePath) { + return generatedSourceFileByPathCache.getOrPut(irFile.relativePath.asCacheKey) { SirSourceFile(irFile.module, irFile.relativePath, irFile) } } @@ -52,7 +53,7 @@ class SirFileProvider( getIrFile(skieNamespace, name) fun getIrFile(namespace: String, name: String): SirIrFile = - irFileByPathCache.getOrPut(relativePath(namespace, name)) { + irFileByPathCache.getOrPut(relativePath(namespace, name).asCacheKey) { SirIrFile(namespace, name, skieModule) } @@ -84,6 +85,9 @@ class SirFileProvider( return SirCompilableFile(skieModule, absolutePath, null) } + private val Path.asCacheKey: String + get() = this.normalize().absolutePathString().lowercase() + companion object { fun relativePath(namespace: String, name: String): Path =