From 5f43628f1ba0757e3046f8a4dddc31036b42ccfa Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Mon, 5 Oct 2015 14:48:29 +0300 Subject: [PATCH] Abstract data is forbidden: Idea module infos fixed --- .../idea/caches/resolve/IdeaModuleInfos.kt | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IdeaModuleInfos.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IdeaModuleInfos.kt index 357628f709b..7a610b32f8c 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IdeaModuleInfos.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IdeaModuleInfos.kt @@ -116,24 +116,35 @@ internal fun ModuleSourceInfo.isTests() = this is ModuleTestSourceInfo public fun Module.productionSourceInfo(): ModuleProductionSourceInfo = ModuleProductionSourceInfo(this) public fun Module.testSourceInfo(): ModuleTestSourceInfo = ModuleTestSourceInfo(this) -private abstract data class ModuleSourceScope(val module: Module) : GlobalSearchScope(module.getProject()) { +private abstract class ModuleSourceScope(val module: Module) : GlobalSearchScope(module.getProject()) { override fun compare(file1: VirtualFile, file2: VirtualFile) = 0 override fun isSearchInModuleContent(aModule: Module) = aModule == module override fun isSearchInLibraries() = false - - // KT-6206 - override fun hashCode(): Int = module.hashCode() } private class ModuleProductionSourceScope(module: Module) : ModuleSourceScope(module) { val moduleFileIndex = ModuleRootManager.getInstance(module).getFileIndex() + override fun equals(other: Any?): Boolean { + if (this === other) return true + return (other is ModuleProductionSourceScope && module == other.module) + } + // KT-6206 + override fun hashCode(): Int = 31 * module.hashCode() + override fun contains(file: VirtualFile) = moduleFileIndex.isInSourceContent(file) && !moduleFileIndex.isInTestSourceContent(file) } private class ModuleTestSourceScope(module: Module) : ModuleSourceScope(module) { val moduleFileIndex = ModuleRootManager.getInstance(module).getFileIndex() + override fun equals(other: Any?): Boolean { + if (this === other) return true + return (other is ModuleTestSourceScope && module == other.module) + } + // KT-6206 + override fun hashCode(): Int = 37 * module.hashCode() + override fun contains(file: VirtualFile) = moduleFileIndex.isInTestSourceContent(file) }