Normalize virtual file paths to prevent duplicate sources
#KT-52465 Fixed
This commit is contained in:
@@ -44,7 +44,8 @@ inline fun List<KotlinSourceRoot>.forAllFiles(
|
||||
val virtualFileCreator = PreprocessedFileCreator(project)
|
||||
|
||||
for ((sourceRootPath, isCommon) in this) {
|
||||
val vFile = localFileSystem.findFileByPath(sourceRootPath)
|
||||
val sourceRoot = File(sourceRootPath)
|
||||
val vFile = localFileSystem.findFileByPath(sourceRoot.normalize().path)
|
||||
if (vFile == null) {
|
||||
val message = "Source file or directory not found: $sourceRootPath"
|
||||
|
||||
@@ -63,10 +64,10 @@ inline fun List<KotlinSourceRoot>.forAllFiles(
|
||||
continue
|
||||
}
|
||||
|
||||
for (file in File(sourceRootPath).walkTopDown()) {
|
||||
for (file in sourceRoot.walkTopDown()) {
|
||||
if (!file.isFile) continue
|
||||
|
||||
val virtualFile = localFileSystem.findFileByPath(file.absolutePath)?.let(virtualFileCreator::create)
|
||||
val virtualFile = localFileSystem.findFileByPath(file.absoluteFile.normalize().path)?.let(virtualFileCreator::create)
|
||||
if (virtualFile != null && processedFiles.add(virtualFile)) {
|
||||
body(virtualFile, isCommon)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
$TESTDATA_DIR$/simple.kt
|
||||
$TESTDATA_DIR$/./simple.kt
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
@@ -0,0 +1 @@
|
||||
OK
|
||||
@@ -264,6 +264,11 @@ public class CliTestGenerated extends AbstractCliTest {
|
||||
runTest("compiler/testData/cli/jvm/duplicateSourcesInModule.args");
|
||||
}
|
||||
|
||||
@TestMetadata("duplicateSourcesNormalized.args")
|
||||
public void testDuplicateSourcesNormalized() throws Exception {
|
||||
runTest("compiler/testData/cli/jvm/duplicateSourcesNormalized.args");
|
||||
}
|
||||
|
||||
@TestMetadata("emptySources.args")
|
||||
public void testEmptySources() throws Exception {
|
||||
runTest("compiler/testData/cli/jvm/emptySources.args");
|
||||
|
||||
Reference in New Issue
Block a user