diff --git a/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/deserialization/AbstractFirDeserializedSymbolProvider.kt b/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/deserialization/AbstractFirDeserializedSymbolProvider.kt index 712e7dba351..f1aae62e290 100644 --- a/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/deserialization/AbstractFirDeserializedSymbolProvider.kt +++ b/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/deserialization/AbstractFirDeserializedSymbolProvider.kt @@ -57,7 +57,15 @@ abstract class LibraryPathFilter { override fun accepts(path: Path?): Boolean { if (path == null) return false - return libs.any { path.startsWith(it) } + val isPathAbsolute = path.isAbsolute + val absolutePath by lazy(LazyThreadSafetyMode.NONE) { path.toAbsolutePath() } + return libs.any { + when { + it.isAbsolute && !isPathAbsolute -> absolutePath.startsWith(it) + !it.isAbsolute && isPathAbsolute -> path.startsWith(it.toAbsolutePath()) + else -> path.startsWith(it) + } + } } } } diff --git a/compiler/tests/org/jetbrains/kotlin/cli/LauncherScriptTest.kt b/compiler/tests/org/jetbrains/kotlin/cli/LauncherScriptTest.kt index 718999acbde..8800ebfe27f 100644 --- a/compiler/tests/org/jetbrains/kotlin/cli/LauncherScriptTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/cli/LauncherScriptTest.kt @@ -21,6 +21,7 @@ import com.intellij.openapi.util.text.StringUtil import org.jetbrains.kotlin.cli.common.CompilerSystemProperties import org.jetbrains.kotlin.cli.common.ExitCode import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler +import org.jetbrains.kotlin.test.CompilerTestUtil import org.jetbrains.kotlin.test.KotlinTestUtils import org.jetbrains.kotlin.test.TestCaseWithTmpdir import org.jetbrains.kotlin.test.util.KtTestUtil @@ -507,4 +508,21 @@ println(42) expectedStderr = "" ) } + + fun testK2ClassPathWithRelativeDir() { + val file1kt = tmpdir.resolve("file1.kt").apply { + writeText("class C") + } + CompilerTestUtil.executeCompilerAssertSuccessful(K2JVMCompiler(), listOf("-d", tmpdir.absolutePath, "-language-version", "2.0", file1kt.absolutePath)) + val file2kt = tmpdir.resolve("file1.kt").apply { + writeText("val c = C()") + } + runProcess( + "kotlinc", + "-cp", ".", "-d", ".", "-language-version", "2.0", file2kt.absolutePath, + workDirectory = tmpdir, + expectedStdout = "", + expectedStderr = "warning: language version 2.0 is experimental, there are no backwards compatibility guarantees for new language and library features\n" + ) + } }