Add location parameter to ResolutionScope::definitelyDoesNotContainName

It should be used to record lookups in case of fast paths
in resolution
This commit is contained in:
Denis Zharkov
2017-08-15 18:48:22 +07:00
parent 69f3b01e98
commit 6e766634c1
8 changed files with 15 additions and 12 deletions
@@ -16,6 +16,7 @@
package org.jetbrains.kotlin.resolve.calls.tower
import org.jetbrains.kotlin.incremental.components.LookupLocation
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
@@ -131,7 +132,7 @@ class TowerResolver {
val localLevels =
lexicalScope.parentsWithSelf.
filterIsInstance<LexicalScope>().filter { it.kind.withLocalDescriptors && it.mayFitForName(name) }.
filterIsInstance<LexicalScope>().filter { it.kind.withLocalDescriptors && it.mayFitForName(name, location) }.
map { ScopeBasedTowerLevel(this@run, it) }.toList()
// local non-extensions or extension for explicit receiver
@@ -186,8 +187,8 @@ class TowerResolver {
return resultCollector.getFinalCandidates()
}
private fun ResolutionScope.mayFitForName(name: Name) =
!definitelyDoesNotContainName(name) || !definitelyDoesNotContainName(OperatorNameConventions.INVOKE)
private fun ResolutionScope.mayFitForName(name: Name, location: LookupLocation) =
!definitelyDoesNotContainName(name, location) || !definitelyDoesNotContainName(OperatorNameConventions.INVOKE, location)
fun <C : Candidate> runWithEmptyTowerData(
processor: ScopeTowerProcessor<C>,
@@ -125,6 +125,6 @@ abstract class LexicalScopeStorage(
return result
}
override fun definitelyDoesNotContainName(name: Name) =
override fun definitelyDoesNotContainName(name: Name, location: LookupLocation) =
functionsByName?.get(name) == null && variablesAndClassifiersByName?.get(name) == null
}
@@ -55,7 +55,7 @@ interface LexicalScope : HierarchicalScope {
override val kind: LexicalScopeKind
get() = LexicalScopeKind.EMPTY
override fun definitelyDoesNotContainName(name: Name) = true
override fun definitelyDoesNotContainName(name: Name, location: LookupLocation) = true
override fun printStructure(p: Printer) {
p.println("Base lexical scope with owner = $ownerDescriptor and parent = $parent")
@@ -128,8 +128,9 @@ interface ImportingScope : HierarchicalScope {
p.println("ImportingScope.Empty")
}
override fun definitelyDoesNotContainName(name: Name) = true
override fun computeImportedNames() = emptySet<Name>()
override fun definitelyDoesNotContainName(name: Name, location: LookupLocation) = true
}
}