From 93c84a43d9cb4fc8891faaa41eefc9ece148d04d Mon Sep 17 00:00:00 2001 From: "Konstantin.Nisht" Date: Wed, 9 Oct 2019 10:28:28 +0300 Subject: [PATCH] fix regression with incorrect type resolving for closure parameter GitOrigin-RevId: 53b552039bfab2d51ebcd102eee6459d6730e27e --- .../style/inference/CollectingGroovyInferenceSession.kt | 8 ++++---- .../psi/typeEnhancers/InferredClosureParamsEnhancer.kt | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) 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