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:
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.resolve.calls.tower
|
package org.jetbrains.kotlin.resolve.calls.tower
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus
|
import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus
|
||||||
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
|
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
|
||||||
@@ -131,7 +132,7 @@ class TowerResolver {
|
|||||||
|
|
||||||
val localLevels =
|
val localLevels =
|
||||||
lexicalScope.parentsWithSelf.
|
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()
|
map { ScopeBasedTowerLevel(this@run, it) }.toList()
|
||||||
|
|
||||||
// local non-extensions or extension for explicit receiver
|
// local non-extensions or extension for explicit receiver
|
||||||
@@ -186,8 +187,8 @@ class TowerResolver {
|
|||||||
return resultCollector.getFinalCandidates()
|
return resultCollector.getFinalCandidates()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun ResolutionScope.mayFitForName(name: Name) =
|
private fun ResolutionScope.mayFitForName(name: Name, location: LookupLocation) =
|
||||||
!definitelyDoesNotContainName(name) || !definitelyDoesNotContainName(OperatorNameConventions.INVOKE)
|
!definitelyDoesNotContainName(name, location) || !definitelyDoesNotContainName(OperatorNameConventions.INVOKE, location)
|
||||||
|
|
||||||
fun <C : Candidate> runWithEmptyTowerData(
|
fun <C : Candidate> runWithEmptyTowerData(
|
||||||
processor: ScopeTowerProcessor<C>,
|
processor: ScopeTowerProcessor<C>,
|
||||||
|
|||||||
@@ -125,6 +125,6 @@ abstract class LexicalScopeStorage(
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun definitelyDoesNotContainName(name: Name) =
|
override fun definitelyDoesNotContainName(name: Name, location: LookupLocation) =
|
||||||
functionsByName?.get(name) == null && variablesAndClassifiersByName?.get(name) == null
|
functionsByName?.get(name) == null && variablesAndClassifiersByName?.get(name) == null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ interface LexicalScope : HierarchicalScope {
|
|||||||
override val kind: LexicalScopeKind
|
override val kind: LexicalScopeKind
|
||||||
get() = LexicalScopeKind.EMPTY
|
get() = LexicalScopeKind.EMPTY
|
||||||
|
|
||||||
override fun definitelyDoesNotContainName(name: Name) = true
|
override fun definitelyDoesNotContainName(name: Name, location: LookupLocation) = true
|
||||||
|
|
||||||
override fun printStructure(p: Printer) {
|
override fun printStructure(p: Printer) {
|
||||||
p.println("Base lexical scope with owner = $ownerDescriptor and parent = $parent")
|
p.println("Base lexical scope with owner = $ownerDescriptor and parent = $parent")
|
||||||
@@ -128,8 +128,9 @@ interface ImportingScope : HierarchicalScope {
|
|||||||
p.println("ImportingScope.Empty")
|
p.println("ImportingScope.Empty")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun definitelyDoesNotContainName(name: Name) = true
|
|
||||||
override fun computeImportedNames() = emptySet<Name>()
|
override fun computeImportedNames() = emptySet<Name>()
|
||||||
|
|
||||||
|
override fun definitelyDoesNotContainName(name: Name, location: LookupLocation) = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -44,7 +44,7 @@ class InnerClassesScopeWrapper(val workerScope: MemberScope) : MemberScopeImpl()
|
|||||||
override fun getVariableNames() = workerScope.getVariableNames()
|
override fun getVariableNames() = workerScope.getVariableNames()
|
||||||
override fun getClassifierNames() = workerScope.getClassifierNames()
|
override fun getClassifierNames() = workerScope.getClassifierNames()
|
||||||
|
|
||||||
override fun definitelyDoesNotContainName(name: Name) = workerScope.definitelyDoesNotContainName(name)
|
override fun definitelyDoesNotContainName(name: Name, location: LookupLocation) = workerScope.definitelyDoesNotContainName(name, location)
|
||||||
|
|
||||||
override fun toString() = "Classes from $workerScope"
|
override fun toString() = "Classes from $workerScope"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,5 +40,5 @@ interface ResolutionScope {
|
|||||||
nameFilter: (Name) -> Boolean = MemberScope.ALL_NAME_FILTER
|
nameFilter: (Name) -> Boolean = MemberScope.ALL_NAME_FILTER
|
||||||
): Collection<DeclarationDescriptor>
|
): Collection<DeclarationDescriptor>
|
||||||
|
|
||||||
fun definitelyDoesNotContainName(name: Name): Boolean = false
|
fun definitelyDoesNotContainName(name: Name, location: LookupLocation): Boolean = false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ class SubstitutingScope(private val workerScope: MemberScope, givenSubstitutor:
|
|||||||
override fun getVariableNames() = workerScope.getVariableNames()
|
override fun getVariableNames() = workerScope.getVariableNames()
|
||||||
override fun getClassifierNames() = workerScope.getClassifierNames()
|
override fun getClassifierNames() = workerScope.getClassifierNames()
|
||||||
|
|
||||||
override fun definitelyDoesNotContainName(name: Name) = workerScope.definitelyDoesNotContainName(name)
|
override fun definitelyDoesNotContainName(name: Name, location: LookupLocation) = workerScope.definitelyDoesNotContainName(name, location)
|
||||||
|
|
||||||
override fun printScopeStructure(p: Printer) {
|
override fun printScopeStructure(p: Printer) {
|
||||||
p.println(this::class.java.simpleName, " {")
|
p.println(this::class.java.simpleName, " {")
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ public class ErrorUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean definitelyDoesNotContainName(@NotNull Name name) {
|
public boolean definitelyDoesNotContainName(@NotNull Name name, @NotNull LookupLocation location) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,7 +296,7 @@ public class ErrorUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean definitelyDoesNotContainName(@NotNull Name name) {
|
public boolean definitelyDoesNotContainName(@NotNull Name name, @NotNull LookupLocation location) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.descriptors.PackagePartProvider
|
|||||||
import org.jetbrains.kotlin.descriptors.SourceElement
|
import org.jetbrains.kotlin.descriptors.SourceElement
|
||||||
import org.jetbrains.kotlin.descriptors.deserialization.AdditionalClassPartsProvider
|
import org.jetbrains.kotlin.descriptors.deserialization.AdditionalClassPartsProvider
|
||||||
import org.jetbrains.kotlin.descriptors.deserialization.PlatformDependentDeclarationFilter
|
import org.jetbrains.kotlin.descriptors.deserialization.PlatformDependentDeclarationFilter
|
||||||
|
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||||
import org.jetbrains.kotlin.name.ClassId
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
@@ -106,7 +107,7 @@ class MetadataPackageFragment(
|
|||||||
containerSource = null, components = components, classNames = { emptyList() }
|
containerSource = null, components = components, classNames = { emptyList() }
|
||||||
) {
|
) {
|
||||||
override fun hasClass(name: Name): Boolean = hasTopLevelClass(name)
|
override fun hasClass(name: Name): Boolean = hasTopLevelClass(name)
|
||||||
override fun definitelyDoesNotContainName(name: Name) = false
|
override fun definitelyDoesNotContainName(name: Name, location: LookupLocation) = false
|
||||||
override fun getClassifierNames(): Set<Name>? = null
|
override fun getClassifierNames(): Set<Name>? = null
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user