diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/inference/CollectingGroovyInferenceSession.kt b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/inference/CollectingGroovyInferenceSession.kt index e2112a3e1053..b8d10df1413e 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/inference/CollectingGroovyInferenceSession.kt +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/inference/CollectingGroovyInferenceSession.kt @@ -1,6 +1,7 @@ // Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.plugins.groovy.intentions.style.inference +import com.intellij.openapi.util.RecursionManager import com.intellij.openapi.util.component1 import com.intellij.openapi.util.component2 import com.intellij.psi.* @@ -29,11 +30,10 @@ class CollectingGroovyInferenceSession( companion object { fun getContextSubstitutor(resolveResult: GroovyMethodResult, - nearestCall: GrCall): PsiSubstitutor { + nearestCall: GrCall): PsiSubstitutor = RecursionManager.doPreventingRecursion(resolveResult, true) { val collectingSession = CollectingGroovyInferenceSession(nearestCall.parentOfType()!!.typeParameters, nearestCall) - return buildTopLevelSession(nearestCall, collectingSession).inferSubst(resolveResult) - - } + buildTopLevelSession(nearestCall, collectingSession).inferSubst(resolveResult) + } ?: PsiSubstitutor.EMPTY } private fun substituteForeignTypeParameters(type: PsiType?): PsiType? { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/InferredClosureParamsEnhancer.kt b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/InferredClosureParamsEnhancer.kt index 8e14a8690cdf..fb7ff2ab2bdd 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/InferredClosureParamsEnhancer.kt +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/InferredClosureParamsEnhancer.kt @@ -66,7 +66,7 @@ class InferredClosureParamsEnhancer : AbstractClosureParameterEnhancer() { val session = CollectingGroovyInferenceSession(virtualMethod.typeParameters, virtualMethod, resolveResult.contextSubstitutor, proxyMapping) session.addConstraint(MethodCallConstraint(null, resolveResult, virtualMethod)) - return session.inferSubst(resolveResult) + return session.inferSubst() } } \ No newline at end of file