From c7ccfcc785236a5030ffd5bb55b90e658dc2f83d Mon Sep 17 00:00:00 2001 From: Marco Pennekamp Date: Wed, 21 Feb 2024 20:33:25 +0100 Subject: [PATCH] [AA] Fix sealed inheritors provider for binary libraries in Standalone tests - Since binary libraries don't carry decompiled files anymore, the static declaration provider doesn't index binary libraries in the Standalone mode, where we don't use stub-based deserialization. This led `LLSealedInheritorsProviderFactoryForTests` to fail in Standalone mode for sealed classes from binary libraries, as this provider is now populated from the declaration provider's index (see the previous commit). Luckily, class-based deserialization sets `sealedInheritorsAttr`, so we can simply use this attribute. ^KT-65960 --- .../services/LLSealedInheritorsProviderFactoryForTests.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 9565709b31b..ad793422819 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,9 +39,9 @@ private class SealedClassInheritorsProviderForTests( else -> ktModule } - // 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() + // If the module is absent in the map, it's either a binary library that wasn't stub-indexed (e.g. in Standalone mode) or the module + // doesn't have any `.kt` files, in which case there cannot be sealed inheritors. `sealedInheritorsAttr` covers the binary library + // case, as class-based deserialization sets this attribute. + return inheritorsByModule[relevantModule]?.get(firClass.classId) ?: firClass.sealedInheritorsAttr?.value ?: emptyList() } }