diff --git a/idea/src/org/jetbrains/kotlin/idea/caches/KotlinIndicesHelper.kt b/idea/src/org/jetbrains/kotlin/idea/caches/KotlinIndicesHelper.kt index f72e43480d2..0b35a27d265 100644 --- a/idea/src/org/jetbrains/kotlin/idea/caches/KotlinIndicesHelper.kt +++ b/idea/src/org/jetbrains/kotlin/idea/caches/KotlinIndicesHelper.kt @@ -85,8 +85,9 @@ public class KotlinIndicesHelper( if (receiverValues.isEmpty()) return emptyList() val dataFlowInfo = bindingContext.getDataFlowInfo(expression) + val containingDeclaration = bindingContext[BindingContext.RESOLUTION_SCOPE, expression]?.getContainingDeclaration() ?: return emptyList() - val receiverTypeNames = possibleReceiverTypeNames(receiverValues.map { it.first }, dataFlowInfo) + val receiverTypeNames = possibleReceiverTypeNames(receiverValues.map { it.first }, containingDeclaration, dataFlowInfo) val index = JetTopLevelExtensionsByReceiverTypeIndex.INSTANCE @@ -101,10 +102,10 @@ public class KotlinIndicesHelper( return findSuitableExtensions(declarations, receiverValues, dataFlowInfo, bindingContext) } - private fun possibleReceiverTypeNames(receiverValues: Collection, dataFlowInfo: DataFlowInfo): Set { + private fun possibleReceiverTypeNames(receiverValues: Collection, containingDeclaration: DeclarationDescriptor, dataFlowInfo: DataFlowInfo): Set { val result = HashSet() for (receiverValue in receiverValues) { - for (type in SmartCastUtils.getSmartCastVariants(receiverValue, bindingContext, dataFlowInfo)) { + for (type in SmartCastUtils.getSmartCastVariants(receiverValue, bindingContext, containingDeclaration, dataFlowInfo)) { result.addTypeNames(type) } }