From 008d6704694d30f18c70b874c61201a3e278e98b Mon Sep 17 00:00:00 2001 From: Dmitry Savvinov Date: Fri, 26 Jan 2024 16:54:39 +0100 Subject: [PATCH] [Tests] Fix exception from SealedClassInheritorsProviderForTests 'getValue' throws if the key isn't present. Modules without .kt-files might be legitimately absent in inheritorsMap (see org.jetbrains.kotlin.analysis.low.level.api.fir.compiler.based.SealedClassesInheritorsCaclulatorPreAnalysisHandler) Previously, such tests were not failing because if a module doesn't contain .kt-files, then it contains only .java files. And there was another bug in the tests infra that was essentially folding all the .java-files in one main-module, effectively shadowing the bug in subject of this commit. --- .../fir/services/LLSealedInheritorsProviderFactoryForTests.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/services/LLSealedInheritorsProviderFactoryForTests.kt b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/services/LLSealedInheritorsProviderFactoryForTests.kt index 68b355f2e5a..9565709b31b 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/services/LLSealedInheritorsProviderFactoryForTests.kt +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/services/LLSealedInheritorsProviderFactoryForTests.kt @@ -39,7 +39,9 @@ private class SealedClassInheritorsProviderForTests( else -> ktModule } - val inheritorsForModuleMap = inheritorsByModule.getValue(relevantModule) + // the module might be absent in the map if it doesn't have any .kt-files whatsoever, in which case + // there's definitely no sealed inheritors + val inheritorsForModuleMap = inheritorsByModule[relevantModule] ?: return emptyList() return inheritorsForModuleMap[firClass.classId] ?: firClass.sealedInheritorsAttr?.value ?: emptyList() } }