FIR: fix libs filtering for abs/rel paths combinations
Some of the incoming paths "absoluteness" may not match the one of the corresponding library path, and that leaded to incorrect filtering out some items in the deserialized symbol providers. Fix the filtering to account for the mismatch. #KT-57535 fixed
This commit is contained in:
committed by
Space Team
parent
030866cb0b
commit
df35e5431c
+9
-1
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user