[FIR] Sort KtSourceFiles analogously to KtFiles
The `IncrementalJsFirKlibCompilerWithScopeExpansionRunnerTestGenerate .testSerializedSubClassAndChangedInterfaces` test fail because the checksums of the `manifest` files don't match after the full recompilation. It happens, because the `b.kt` file may be passed to the compiler before `a.kt`, in which case while generating the data class members the compiler will generate a call to `Any::hashCode` when accessing the hashcode of the `a` property instead of generating a call to the fake override `A::hashCode`. When working with PSI, the compiler sorts the input files to at `KotlinCoreEnvironment.kt:200`. This change removes the flaky behavior by sorting the input files.
This commit is contained in:
committed by
Space Team
parent
90651c5851
commit
51b8e400d9
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.cli.jvm.compiler.forAllFiles
|
|||||||
import org.jetbrains.kotlin.config.CommonConfigurationKeys
|
import org.jetbrains.kotlin.config.CommonConfigurationKeys
|
||||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||||
import org.jetbrains.kotlin.idea.KotlinFileType
|
import org.jetbrains.kotlin.idea.KotlinFileType
|
||||||
|
import java.util.TreeSet
|
||||||
|
|
||||||
private const val kotlinFileExtensionWithDot = ".${KotlinFileType.EXTENSION}"
|
private const val kotlinFileExtensionWithDot = ".${KotlinFileType.EXTENSION}"
|
||||||
private const val javaFileExtensionWithDot = ".${JavaFileType.DEFAULT_EXTENSION}"
|
private const val javaFileExtensionWithDot = ".${JavaFileType.DEFAULT_EXTENSION}"
|
||||||
@@ -35,13 +36,19 @@ fun collectSources(
|
|||||||
return collectSources(compilerConfiguration, projectEnvironment.project, messageCollector)
|
return collectSources(compilerConfiguration, projectEnvironment.project, messageCollector)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val ktSourceFileComparator = Comparator<KtSourceFile> { o1, o2 ->
|
||||||
|
val path1 = o1.path ?: error("Expected a file with a well-defined path")
|
||||||
|
val path2 = o2.path ?: error("Expected a file with a well-defined path")
|
||||||
|
path1.compareTo(path2)
|
||||||
|
}
|
||||||
|
|
||||||
fun collectSources(
|
fun collectSources(
|
||||||
compilerConfiguration: CompilerConfiguration,
|
compilerConfiguration: CompilerConfiguration,
|
||||||
project: Project,
|
project: Project,
|
||||||
messageCollector: MessageCollector
|
messageCollector: MessageCollector
|
||||||
): GroupedKtSources {
|
): GroupedKtSources {
|
||||||
val platformSources = linkedSetOf<KtSourceFile>()
|
val platformSources = TreeSet(ktSourceFileComparator)
|
||||||
val commonSources = linkedSetOf<KtSourceFile>()
|
val commonSources = TreeSet(ktSourceFileComparator)
|
||||||
val sourcesByModuleName = mutableMapOf<String, MutableSet<KtSourceFile>>()
|
val sourcesByModuleName = mutableMapOf<String, MutableSet<KtSourceFile>>()
|
||||||
|
|
||||||
// TODO: the scripts checking should be part of the scripting plugin functionality, as it is implemented now in ScriptingProcessSourcesBeforeCompilingExtension
|
// TODO: the scripts checking should be part of the scripting plugin functionality, as it is implemented now in ScriptingProcessSourcesBeforeCompilingExtension
|
||||||
|
|||||||
Reference in New Issue
Block a user