[NI] Fix poor performance of recursive types approximation

#KT-32407 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2019-08-05 14:41:36 +03:00
parent 5f76918c90
commit 0219b86d06
7 changed files with 145 additions and 24 deletions
@@ -106,7 +106,10 @@ class PSICallResolver(
return OverloadResolutionResultsImpl.nameNotFound()
}
return convertToOverloadResolutionResults(context, result, tracingStrategy)
val overloadResolutionResults = convertToOverloadResolutionResults<D>(context, result, tracingStrategy)
return overloadResolutionResults.also {
clearCacheForApproximationResults()
}
}
// actually, `D` is at least FunctionDescriptor, but right now because of CallResolver it isn't possible change upper bound for `D`
@@ -133,7 +136,16 @@ class PSICallResolver(
val result = kotlinCallResolver.resolveGivenCandidates(
scopeTower, resolutionCallbacks, kotlinCall, calculateExpectedType(context), givenCandidates, context.collectAllCandidates
)
return convertToOverloadResolutionResults(context, result, tracingStrategy)
val overloadResolutionResults = convertToOverloadResolutionResults<D>(context, result, tracingStrategy)
return overloadResolutionResults.also {
clearCacheForApproximationResults()
}
}
private fun clearCacheForApproximationResults() {
// Mostly, we approximate captured or some other internal types that don't live longer than resolve for a call,
// so it's quite useless to preserve cache for longer time
typeApproximator.clearCache()
}
private fun resolveToDeprecatedMod(