From 2432571a8c4d9e60f4dc68b495a57ef08fd8af5a Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Wed, 19 Aug 2015 19:53:00 +0300 Subject: [PATCH] Get SmartCastManager as a service in ReferenceVariantsHelper --- .../kotlin/idea/codeInsight/ReferenceVariantsHelper.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt index d9e8871f3a2..3ecb7fa5aae 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt @@ -22,6 +22,7 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.idea.resolve.ResolutionFacade +import org.jetbrains.kotlin.idea.resolve.frontendService import org.jetbrains.kotlin.idea.util.CallType import org.jetbrains.kotlin.idea.util.ShadowedDeclarationsFilter import org.jetbrains.kotlin.idea.util.getImplicitReceiversWithInstance @@ -109,8 +110,10 @@ public class ReferenceVariantsHelper( val dataFlowInfo = context.getDataFlowInfo(expression) + val smartCastManager = resolutionFacade.frontendService(expression) val implicitReceiverTypes = resolutionScope.getImplicitReceiversWithInstance().flatMap { - SmartCastManager().getSmartCastVariantsWithLessSpecificExcluded(it.value, context, containingDeclaration, dataFlowInfo) + smartCastManager + .getSmartCastVariantsWithLessSpecificExcluded(it.value, context, containingDeclaration, dataFlowInfo) }.toSet() val pair = getExplicitReceiverData(expression) @@ -129,7 +132,8 @@ public class ReferenceVariantsHelper( context.getType(receiverExpression) if (expressionType != null && !expressionType.isError()) { val receiverValue = ExpressionReceiver(receiverExpression, expressionType) - val explicitReceiverTypes = SmartCastManager().getSmartCastVariantsWithLessSpecificExcluded(receiverValue, context, containingDeclaration, dataFlowInfo) + val explicitReceiverTypes = smartCastManager + .getSmartCastVariantsWithLessSpecificExcluded(receiverValue, context, containingDeclaration, dataFlowInfo) descriptors.processAll(implicitReceiverTypes, explicitReceiverTypes, resolutionScope, callType, kindFilter, nameFilter) }