From 3a7dddbb34d689715d85678a5846da9f19e80c15 Mon Sep 17 00:00:00 2001 From: Daniil Ovchinnikov Date: Tue, 9 Oct 2018 21:43:29 +0300 Subject: [PATCH] [groovy] don't compute methodCandidate when not needed in MethodResolveResult --- .../plugins/groovy/lang/resolve/MethodResolveResult.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/MethodResolveResult.kt b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/MethodResolveResult.kt index f966ee952c56..3823c79240e7 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/MethodResolveResult.kt +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/MethodResolveResult.kt @@ -17,8 +17,11 @@ class MethodResolveResult( state: ResolveState ) : BaseGroovyResolveResult(method, ref, state), GroovyMethodResult { + private val siteSubstitutor by lazy { + super.getSubstitutor().putAll(method.typeParameters, ref.typeArguments) + } + private val methodCandidate by lazy { - val siteSubstitutor = state[PsiSubstitutor.KEY].putAll(method.typeParameters, ref.typeArguments) val qualifierConstraint = buildQualifier(ref, state) val argumentConstraints = buildArguments(ref) @@ -36,7 +39,7 @@ class MethodResolveResult( private val applicabilitySubstitutor by lazy { if (ref.typeArguments.isNotEmpty()) { - methodCandidate.siteSubstitutor + siteSubstitutor } else { GroovyInferenceSessionBuilder(ref, methodCandidate).build().inferSubst() @@ -45,7 +48,7 @@ class MethodResolveResult( private val fullSubstitutor by lazy { if (ref.typeArguments.isNotEmpty()) { - methodCandidate.siteSubstitutor + siteSubstitutor } else { GroovyInferenceSessionBuilder(ref, methodCandidate)