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)
|
val virtualFileCreator = PreprocessedFileCreator(project)
|
||||||
|
|
||||||
for ((sourceRootPath, isCommon) in this) {
|
for ((sourceRootPath, isCommon) in this) {
|
||||||
val vFile = localFileSystem.findFileByPath(sourceRootPath)
|
val sourceRoot = File(sourceRootPath)
|
||||||
|
val vFile = localFileSystem.findFileByPath(sourceRoot.normalize().path)
|
||||||
if (vFile == null) {
|
if (vFile == null) {
|
||||||
val message = "Source file or directory not found: $sourceRootPath"
|
val message = "Source file or directory not found: $sourceRootPath"
|
||||||
|
|
||||||
@@ -63,10 +64,10 @@ inline fun List<KotlinSourceRoot>.forAllFiles(
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
for (file in File(sourceRootPath).walkTopDown()) {
|
for (file in sourceRoot.walkTopDown()) {
|
||||||
if (!file.isFile) continue
|
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)) {
|
if (virtualFile != null && processedFiles.add(virtualFile)) {
|
||||||
body(virtualFile, isCommon)
|
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");
|
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")
|
@TestMetadata("emptySources.args")
|
||||||
public void testEmptySources() throws Exception {
|
public void testEmptySources() throws Exception {
|
||||||
runTest("compiler/testData/cli/jvm/emptySources.args");
|
runTest("compiler/testData/cli/jvm/emptySources.args");
|
||||||
|
|||||||
Reference in New Issue
Block a user