Don't track lookups:

* when find local variables
  we don't need them for incremental compilation;
* when check overrides
  we going to track inheritance separatly;
* when get companion object descriptor;
* when find Descriptor by fqname
  isn't interesting now because used from light-classes and and java-loder;
* when create qualifier
  we already looked up names in this context before.
This commit is contained in:
Zalim Bashorov
2015-10-30 16:43:26 +03:00
parent 2741215ed2
commit 16d585e204
5 changed files with 9 additions and 13 deletions
@@ -794,9 +794,9 @@ public class OverrideResolver {
) {
for (KotlinType supertype : declaringClass.getTypeConstructor().getSupertypes()) {
Set<CallableMemberDescriptor> all = Sets.newLinkedHashSet();
all.addAll(supertype.getMemberScope().getFunctions(declared.getName(), NoLookupLocation.UNSORTED));
all.addAll(supertype.getMemberScope().getFunctions(declared.getName(), NoLookupLocation.WHEN_CHECK_OVERRIDES));
//noinspection unchecked
all.addAll((Collection) supertype.getMemberScope().getProperties(declared.getName(), NoLookupLocation.UNSORTED));
all.addAll((Collection) supertype.getMemberScope().getProperties(declared.getName(), NoLookupLocation.WHEN_CHECK_OVERRIDES));
for (CallableMemberDescriptor fromSuper : all) {
if (OverridingUtil.DEFAULT.isOverridableBy(fromSuper, declared).getResult() == OVERRIDABLE) {
if (Visibilities.isVisible(ReceiverValue.IRRELEVANT_RECEIVER, fromSuper, declared)) {
@@ -81,7 +81,7 @@ public class ResolveSessionUtils {
KtScope scope = outerScope;
for (Name name : path.pathSegments()) {
ClassifierDescriptor classifier = scope.getClassifier(name, NoLookupLocation.UNSORTED);
ClassifierDescriptor classifier = scope.getClassifier(name, NoLookupLocation.WHEN_FIND_BY_FQNAME);
if (!(classifier instanceof ClassDescriptor)) return null;
scope = ((ClassDescriptor) classifier).getUnsubstitutedInnerClassesScope();
}
@@ -358,7 +358,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
}
Name name = ((JetClassOrObjectInfo) companionObjectInfo).getName();
assert name != null;
getUnsubstitutedMemberScope().getClassifier(name, NoLookupLocation.UNSORTED);
getUnsubstitutedMemberScope().getClassifier(name, NoLookupLocation.WHEN_GET_COMPANION_OBJECT);
ClassDescriptor companionObjectDescriptor = c.getTrace().get(BindingContext.CLASS, companionObject);
if (companionObjectDescriptor instanceof LazyClassDescriptor) {
assert DescriptorUtils.isCompanionObject(companionObjectDescriptor) : "Not a companion object: " + companionObjectDescriptor;
@@ -17,17 +17,13 @@
package org.jetbrains.kotlin.resolve.scopes.receivers
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.diagnostics.Errors.EXPRESSION_EXPECTED_PACKAGE_FOUND
import org.jetbrains.kotlin.diagnostics.Errors.NO_COMPANION_OBJECT
import org.jetbrains.kotlin.diagnostics.Errors.TYPE_PARAMETER_IS_NOT_AN_EXPRESSION
import org.jetbrains.kotlin.diagnostics.Errors.TYPE_PARAMETER_ON_LHS_OF_DOT
import org.jetbrains.kotlin.diagnostics.Errors.*
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.KtSimpleNameExpression
import org.jetbrains.kotlin.psi.psiUtil.getTopmostParentQualifiedExpressionForSelector
import org.jetbrains.kotlin.resolve.BindingContext.QUALIFIER
import org.jetbrains.kotlin.resolve.BindingContext.REFERENCE_TARGET
import org.jetbrains.kotlin.resolve.BindingContext.SHORT_REFERENCE_TO_COMPANION_OBJECT
import org.jetbrains.kotlin.resolve.BindingContext.*
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.DescriptorUtils.getFqName
import org.jetbrains.kotlin.resolve.bindingContextUtil.recordScope
@@ -158,7 +154,7 @@ fun createQualifier(
val name = expression.getReferencedNameAsName()
val packageViewDescriptor = receiverScope.getPackage(name)
val classifierDescriptor = receiverScope.getClassifier(name)
val classifierDescriptor = receiverScope.getClassifier(name, NoLookupLocation.WHEN_TYPING)
if (packageViewDescriptor == null && classifierDescriptor == null) return null
@@ -84,7 +84,7 @@ public fun LexicalScope.findLocalVariable(name: Name): VariableDescriptor? {
it is MemberScopeToImportingScopeAdapter -> it.memberScope.getLocalVariable(name) /* todo remove hack*/
it !is ImportingScope && it !is LexicalChainedScope -> it.getContributedVariables(name, NoLookupLocation.UNSORTED).singleOrNull() /* todo check this*/
it !is ImportingScope && it !is LexicalChainedScope -> it.getContributedVariables(name, NoLookupLocation.WHEN_GET_LOCAL_VARIABLE).singleOrNull() /* todo check this*/
else -> null
}