Fix erroneous full resolve cache filling

Before this commit, we could store partial resolve results in full
resolve cache (for some declarations, e.g. primary constructors).
This may be done iff current partial resolve mode provides all results
from full resolve mode (CFA results & diagnostics).
Otherwise we should not do it.

This fixes four quick-fix tests on CreateTypeParameter
So #KT-23860 Fixed
So #KT-22758 Fixed
This commit is contained in:
Mikhail Glukhikh
2018-06-19 16:37:47 +03:00
parent 40668e3f96
commit 152327d69d
7 changed files with 44 additions and 8 deletions
@@ -177,17 +177,23 @@ class ResolveElementCache(
val (bindingContext, statementFilter) = performElementAdditionalResolve(resolveElement, contextElements, bodyResolveMode)
if (statementFilter == StatementFilter.NONE) {
// partial resolve is not supported for the given declaration - full resolve performed instead
if (statementFilter == StatementFilter.NONE &&
bodyResolveMode.doControlFlowAnalysis && !bodyResolveMode.bindingTraceFilter.ignoreDiagnostics
) {
// Without statement filter, we analyze everything, so we can count partial resolve result as full resolve
// But we can do this only if our resolve mode also provides *both* CFA and diagnostics
// This is true only for PARTIAL_WITH_DIAGNOSTICS resolve mode
fullResolveMap[resolveElement] = CachedFullResolve(bindingContext, resolveElement)
return bindingContext
}
val resolveToCache = CachedPartialResolve(bindingContext, file, bodyResolveMode)
for (statement in (statementFilter as PartialBodyResolveFilter).allStatementsToResolve) {
if (bindingContext[BindingContext.PROCESSED, statement] == true) {
partialResolveMap.putIfAbsent(statement, resolveToCache)
if (statementFilter is PartialBodyResolveFilter) {
for (statement in statementFilter.allStatementsToResolve) {
if (bindingContext[BindingContext.PROCESSED, statement] == true) {
partialResolveMap.putIfAbsent(statement, resolveToCache)
}
}
}