Drop location parameter from ResolutionScope::definitelyDoesNotContainName

definitelyDoesNotContainName is called too eagerly sometimes and it leads
to obviously redundant lookups

The idea is to put responsibility for calling recordLookup to resolution
itself
This commit is contained in:
Denis Zharkov
2017-08-24 10:56:00 +03:00
parent 37440c70e2
commit 580a7e3e4d
13 changed files with 17 additions and 29 deletions
@@ -241,11 +241,7 @@ class FileScopeFactory(
override fun computeImportedNames() = packageView.memberScope.computeAllNames()
override fun definitelyDoesNotContainName(name: Name, location: LookupLocation): Boolean {
if (names?.let { name in it } != false) return false
packageView.memberScope.recordLookup(name, location)
return true
}
override fun definitelyDoesNotContainName(name: Name) = names?.let { name !in it } == true
override fun toString() = "Scope for current package (${filteringKind.name})"
@@ -197,13 +197,7 @@ class LazyImportResolver(
indexedImports.imports.flatMapToNullable(hashSetOf()) { getImportScope(it).computeImportedNames() }
}
fun definitelyDoesNotContainName(name: Name, location: LookupLocation): Boolean {
if (allNames?.let { name in it } != false) return false
indexedImports.importsForName(name).forEach {
getImportScope(it).recordLookup(name, location)
}
return true
}
fun definitelyDoesNotContainName(name: Name) = allNames?.let { name !in it } == true
}
class LazyImportScope(
@@ -283,6 +277,6 @@ class LazyImportScope(
p.println("}")
}
override fun definitelyDoesNotContainName(name: Name, location: LookupLocation) = importResolver.definitelyDoesNotContainName(name, location)
override fun definitelyDoesNotContainName(name: Name) = importResolver.definitelyDoesNotContainName(name)
override fun computeImportedNames() = importResolver.allNames
}