[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.
This commit is contained in:
committed by
Space Team
parent
f19859db4e
commit
008d670469
+3
-1
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user