LookupLocation.NO_LOCATION -> NoLookupLocation.UNSORTED

This commit is contained in:
Zalim Bashorov
2015-08-17 23:20:48 +03:00
parent 6c28dbd407
commit 16e1138374
12 changed files with 48 additions and 43 deletions
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
import org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl;
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl;
import org.jetbrains.kotlin.incremental.components.NoLookupLocation;
import org.jetbrains.kotlin.load.java.components.TypeUsage;
import org.jetbrains.kotlin.load.java.descriptors.JavaMethodDescriptor;
import org.jetbrains.kotlin.load.java.structure.JavaMethod;
@@ -44,7 +45,6 @@ import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature;
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmSignaturePackage;
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.KotlinToJvmSignatureMapper;
import org.jetbrains.kotlin.resolve.scopes.JetScope;
import org.jetbrains.kotlin.incremental.components.LookupLocation;
import org.jetbrains.kotlin.types.*;
import java.util.*;
@@ -303,7 +303,7 @@ public class SignaturesPropagationData {
Name name = method.getName();
JvmMethodSignature autoSignature = SIGNATURE_MAPPER.mapToJvmMethodSignature(autoMethodDescriptor);
for (JetType supertype : containingClass.getTypeConstructor().getSupertypes()) {
Collection<FunctionDescriptor> superFunctionCandidates = supertype.getMemberScope().getFunctions(name, LookupLocation.NO_LOCATION);
Collection<FunctionDescriptor> superFunctionCandidates = supertype.getMemberScope().getFunctions(name, NoLookupLocation.UNSORTED);
for (FunctionDescriptor candidate : superFunctionCandidates) {
JvmMethodSignature candidateSignature = SIGNATURE_MAPPER.mapToJvmMethodSignature(candidate);
if (JvmSignaturePackage.erasedSignaturesEqualIgnoringReturnTypes(autoSignature, candidateSignature)) {
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
import org.jetbrains.kotlin.descriptors.impl.*;
import org.jetbrains.kotlin.diagnostics.Errors;
import org.jetbrains.kotlin.incremental.components.LookupLocation;
import org.jetbrains.kotlin.incremental.components.NoLookupLocation;
import org.jetbrains.kotlin.lexer.JetTokens;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.name.Name;
@@ -39,7 +39,10 @@ import org.jetbrains.kotlin.resolve.constants.ConstantValue;
import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator;
import org.jetbrains.kotlin.resolve.dataClassUtils.DataClassUtilsPackage;
import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil;
import org.jetbrains.kotlin.resolve.scopes.*;
import org.jetbrains.kotlin.resolve.scopes.JetScope;
import org.jetbrains.kotlin.resolve.scopes.JetScopeUtils;
import org.jetbrains.kotlin.resolve.scopes.WritableScope;
import org.jetbrains.kotlin.resolve.scopes.WritableScopeImpl;
import org.jetbrains.kotlin.storage.StorageManager;
import org.jetbrains.kotlin.types.*;
import org.jetbrains.kotlin.types.checker.JetTypeChecker;
@@ -520,7 +523,7 @@ public class DescriptorResolver {
Name name = nameExpression.getReferencedNameAsName();
ClassifierDescriptor classifier = scope.getClassifier(name, LookupLocation.NO_LOCATION);
ClassifierDescriptor classifier = scope.getClassifier(name, NoLookupLocation.UNSORTED);
if (classifier instanceof TypeParameterDescriptor && classifier.getContainingDeclaration() == descriptor) continue;
if (classifier != null) {
@@ -33,12 +33,12 @@ import org.jetbrains.annotations.ReadOnly;
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor;
import org.jetbrains.kotlin.incremental.components.NoLookupLocation;
import org.jetbrains.kotlin.lexer.JetTokens;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.CallResolverUtilPackage;
import org.jetbrains.kotlin.resolve.dataClassUtils.DataClassUtilsPackage;
import org.jetbrains.kotlin.incremental.components.LookupLocation;
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
import org.jetbrains.kotlin.types.*;
import org.jetbrains.kotlin.types.checker.JetTypeChecker;
@@ -730,9 +730,9 @@ public class OverrideResolver {
) {
for (JetType supertype : declaringClass.getTypeConstructor().getSupertypes()) {
Set<CallableMemberDescriptor> all = Sets.newLinkedHashSet();
all.addAll(supertype.getMemberScope().getFunctions(declared.getName(), LookupLocation.NO_LOCATION));
all.addAll(supertype.getMemberScope().getFunctions(declared.getName(), NoLookupLocation.UNSORTED));
//noinspection unchecked
all.addAll((Collection) supertype.getMemberScope().getProperties(declared.getName(), LookupLocation.NO_LOCATION));
all.addAll((Collection) supertype.getMemberScope().getProperties(declared.getName(), NoLookupLocation.UNSORTED));
for (CallableMemberDescriptor fromSuper : all) {
if (OverridingUtil.DEFAULT.isOverridableBy(fromSuper, declared).getResult() == OVERRIDABLE) {
if (Visibilities.isVisible(ReceiverValue.IRRELEVANT_RECEIVER, fromSuper, declared)) {
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.resolve.calls.tasks.collectors
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.builtins.functions.FunctionInvokeDescriptor
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.incremental.components.LookupLocation
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.BindingTrace
import org.jetbrains.kotlin.resolve.DescriptorUtils.isStaticNestedClass
@@ -102,7 +102,7 @@ private object FunctionCollector : CallableDescriptorCollector<FunctionDescripto
override fun getExtensionsByName(scope: JetScope, name: Name, receiverTypes: Collection<JetType>, bindingTrace: BindingTrace): Collection<FunctionDescriptor> {
val functions = scope.getFunctions(name)
val (extensions, nonExtensions) = functions.partition { it.extensionReceiverParameter != null }
val syntheticExtensions = scope.getSyntheticExtensionFunctions(receiverTypes, name, LookupLocation.NO_LOCATION)
val syntheticExtensions = scope.getSyntheticExtensionFunctions(receiverTypes, name, NoLookupLocation.UNSORTED)
if (name == OperatorConventions.INVOKE) {
// Create synthesized "invoke" extensions for each non-extension "invoke" found in the scope
@@ -161,7 +161,7 @@ private object VariableCollector : CallableDescriptorCollector<VariableDescripto
// property may have an extension function type, we check the applicability later to avoid an early computing of deferred types
return scope.getLocalVariable(name).singletonOrEmptyList() +
scope.getProperties(name) +
scope.getSyntheticExtensionProperties(receiverTypes, name, LookupLocation.NO_LOCATION)
scope.getSyntheticExtensionProperties(receiverTypes, name, NoLookupLocation.UNSORTED)
}
override fun toString() = "VARIABLES"
@@ -21,6 +21,7 @@ import com.intellij.psi.util.PsiTreeUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.context.GlobalContext;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.incremental.components.NoLookupLocation;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.psi.*;
@@ -30,7 +31,6 @@ import org.jetbrains.kotlin.resolve.BindingContext;
import org.jetbrains.kotlin.resolve.BindingTrace;
import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyPackageDescriptor;
import org.jetbrains.kotlin.resolve.scopes.JetScope;
import org.jetbrains.kotlin.incremental.components.LookupLocation;
import org.jetbrains.kotlin.storage.LockBasedLazyResolveStorageManager;
import javax.inject.Inject;
@@ -70,7 +70,7 @@ public class LazyDeclarationResolver {
// class A {} class A { fun foo(): A<completion here>}
// and if we find the class by name only, we may b-not get the right one.
// This call is only needed to make sure the classes are written to trace
ClassifierDescriptor scopeDescriptor = resolutionScope.getClassifier(classOrObject.getNameAsSafeName(), LookupLocation.NO_LOCATION);
ClassifierDescriptor scopeDescriptor = resolutionScope.getClassifier(classOrObject.getNameAsSafeName(), NoLookupLocation.UNSORTED);
DeclarationDescriptor descriptor = getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, classOrObject);
if (descriptor == null) {
@@ -134,7 +134,7 @@ public class LazyDeclarationResolver {
@Override
public DeclarationDescriptor visitNamedFunction(@NotNull JetNamedFunction function, Void data) {
JetScope scopeForDeclaration = resolutionScopeToResolveDeclaration(function);
scopeForDeclaration.getFunctions(function.getNameAsSafeName(), LookupLocation.NO_LOCATION);
scopeForDeclaration.getFunctions(function.getNameAsSafeName(), NoLookupLocation.UNSORTED);
return getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, function);
}
@@ -146,7 +146,7 @@ public class LazyDeclarationResolver {
// This is a primary constructor parameter
ClassDescriptor classDescriptor = getClassDescriptor(jetClass);
if (parameter.hasValOrVar()) {
classDescriptor.getDefaultType().getMemberScope().getProperties(parameter.getNameAsSafeName(), LookupLocation.NO_LOCATION);
classDescriptor.getDefaultType().getMemberScope().getProperties(parameter.getNameAsSafeName(), NoLookupLocation.UNSORTED);
return getBindingContext().get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, parameter);
}
else {
@@ -189,7 +189,7 @@ public class LazyDeclarationResolver {
@Override
public DeclarationDescriptor visitProperty(@NotNull JetProperty property, Void data) {
JetScope scopeForDeclaration = resolutionScopeToResolveDeclaration(property);
scopeForDeclaration.getProperties(property.getNameAsSafeName(), LookupLocation.NO_LOCATION);
scopeForDeclaration.getProperties(property.getNameAsSafeName(), NoLookupLocation.UNSORTED);
return getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, property);
}
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor;
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor;
import org.jetbrains.kotlin.descriptors.ModuleDescriptor;
import org.jetbrains.kotlin.descriptors.PackageViewDescriptor;
import org.jetbrains.kotlin.incremental.components.NoLookupLocation;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.name.NamePackage;
@@ -31,7 +32,6 @@ import org.jetbrains.kotlin.name.SpecialNames;
import org.jetbrains.kotlin.psi.JetNamedDeclaration;
import org.jetbrains.kotlin.psi.JetNamedDeclarationUtil;
import org.jetbrains.kotlin.resolve.scopes.JetScope;
import org.jetbrains.kotlin.incremental.components.LookupLocation;
import java.util.ArrayList;
import java.util.Collection;
@@ -84,7 +84,7 @@ public class ResolveSessionUtils {
JetScope scope = outerScope;
for (Name name : path.pathSegments()) {
ClassifierDescriptor classifier = scope.getClassifier(name, LookupLocation.NO_LOCATION);
ClassifierDescriptor classifier = scope.getClassifier(name, NoLookupLocation.UNSORTED);
if (!(classifier instanceof ClassDescriptor)) return null;
scope = ((ClassDescriptor) classifier).getUnsubstitutedInnerClassesScope();
}
@@ -33,7 +33,7 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
import org.jetbrains.kotlin.descriptors.impl.ClassDescriptorBase;
import org.jetbrains.kotlin.incremental.components.LookupLocation;
import org.jetbrains.kotlin.incremental.components.NoLookupLocation;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.resolve.*;
@@ -58,7 +58,8 @@ import org.jetbrains.kotlin.types.TypeUtils;
import java.util.*;
import static kotlin.KotlinPackage.firstOrNull;
import static org.jetbrains.kotlin.diagnostics.Errors.*;
import static org.jetbrains.kotlin.diagnostics.Errors.CYCLIC_INHERITANCE_HIERARCHY;
import static org.jetbrains.kotlin.diagnostics.Errors.TYPE_PARAMETERS_IN_ENUM;
import static org.jetbrains.kotlin.resolve.BindingContext.TYPE;
import static org.jetbrains.kotlin.resolve.ModifiersChecker.*;
import static org.jetbrains.kotlin.resolve.source.SourcePackage.toSourceElement;
@@ -370,7 +371,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
}
Name name = ((JetClassOrObjectInfo) companionObjectInfo).getName();
assert name != null;
getUnsubstitutedMemberScope().getClassifier(name, LookupLocation.NO_LOCATION);
getUnsubstitutedMemberScope().getClassifier(name, NoLookupLocation.UNSORTED);
ClassDescriptor companionObjectDescriptor = c.getTrace().get(BindingContext.CLASS, companionObject);
if (companionObjectDescriptor instanceof LazyClassDescriptor) {
assert DescriptorUtils.isCompanionObject(companionObjectDescriptor) : "Not a companion object: " + companionObjectDescriptor;
@@ -23,10 +23,14 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
import org.jetbrains.kotlin.incremental.components.LookupLocation;
import org.jetbrains.kotlin.incremental.components.NoLookupLocation;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.resolve.DescriptorFactory;
import org.jetbrains.kotlin.resolve.OverridingUtil;
import org.jetbrains.kotlin.resolve.scopes.*;
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter;
import org.jetbrains.kotlin.resolve.scopes.JetScope;
import org.jetbrains.kotlin.resolve.scopes.JetScopeImpl;
import org.jetbrains.kotlin.resolve.scopes.StaticScopeForKotlinClass;
import org.jetbrains.kotlin.storage.MemoizedFunctionToNotNull;
import org.jetbrains.kotlin.storage.NotNullLazyValue;
import org.jetbrains.kotlin.storage.StorageManager;
@@ -200,7 +204,7 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
@NotNull
@SuppressWarnings("unchecked")
private Collection<PropertyDescriptor> computeProperties(@NotNull Name name) {
return resolveFakeOverrides(name, (Collection) getSupertypeScope().getProperties(name, LookupLocation.NO_LOCATION));
return resolveFakeOverrides(name, (Collection) getSupertypeScope().getProperties(name, NoLookupLocation.UNSORTED));
}
@NotNull
@@ -211,7 +215,7 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
@NotNull
private Collection<FunctionDescriptor> computeFunctions(@NotNull Name name) {
return resolveFakeOverrides(name, getSupertypeScope().getFunctions(name, LookupLocation.NO_LOCATION));
return resolveFakeOverrides(name, getSupertypeScope().getFunctions(name, NoLookupLocation.UNSORTED));
}
@NotNull
@@ -267,8 +271,8 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
private Collection<DeclarationDescriptor> computeAllDeclarations() {
Collection<DeclarationDescriptor> result = new HashSet<DeclarationDescriptor>();
for (Name name : enumMemberNames.invoke()) {
result.addAll(getFunctions(name, LookupLocation.NO_LOCATION));
result.addAll(getProperties(name, LookupLocation.NO_LOCATION));
result.addAll(getFunctions(name, NoLookupLocation.UNSORTED));
result.addAll(getProperties(name, NoLookupLocation.UNSORTED));
}
return result;
}
@@ -17,11 +17,6 @@
package org.jetbrains.kotlin.incremental.components
public interface LookupLocation {
companion object {
@deprecated("Use more suitable constant if possible")
val NO_LOCATION = NoLookupLocation.UNSORTED
}
}
public enum class NoLookupLocation : LookupLocation {
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor;
import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor;
import org.jetbrains.kotlin.descriptors.impl.FunctionExpressionDescriptor;
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl;
import org.jetbrains.kotlin.incremental.components.NoLookupLocation;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.name.FqNameUnsafe;
import org.jetbrains.kotlin.name.Name;
@@ -35,7 +36,6 @@ import org.jetbrains.kotlin.resolve.constants.StringValue;
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter;
import org.jetbrains.kotlin.resolve.scopes.FilteringScope;
import org.jetbrains.kotlin.resolve.scopes.JetScope;
import org.jetbrains.kotlin.incremental.components.LookupLocation;
import org.jetbrains.kotlin.types.ErrorUtils;
import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.types.LazyType;
@@ -393,7 +393,7 @@ public class DescriptorUtils {
@Nullable
public static ClassDescriptor getInnerClassByName(@NotNull ClassDescriptor classDescriptor, @NotNull String innerClassName) {
ClassifierDescriptor classifier =
classDescriptor.getDefaultType().getMemberScope().getClassifier(Name.identifier(innerClassName), LookupLocation.NO_LOCATION);
classDescriptor.getDefaultType().getMemberScope().getClassifier(Name.identifier(innerClassName), NoLookupLocation.UNSORTED);
assert classifier instanceof ClassDescriptor :
"Inner class " + innerClassName + " in " + classDescriptor + " should be instance of ClassDescriptor, but was: "
+ (classifier == null ? "null" : classifier.getClass());
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.resolve.scopes
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.incremental.components.LookupLocation
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.types.JetType
import org.jetbrains.kotlin.utils.Printer
@@ -47,12 +48,12 @@ public interface JetScope {
public fun getDeclarationsByLabel(labelName: Name): Collection<DeclarationDescriptor>
// Temporary overloads which will be dropped when all usages will be processed
@deprecated("Provide `location` explicitly", replaceWith = ReplaceWith("getClassifier(name, LookupLocation.NO_LOCATION)"))
public final fun getClassifier(name: Name): ClassifierDescriptor? = getClassifier(name, LookupLocation.NO_LOCATION)
@deprecated("Provide `location` explicitly", replaceWith = ReplaceWith("getClassifier(name, LookupLocation.NO_LOCATION)"))
public final fun getProperties(name: Name): Collection<VariableDescriptor> = getProperties(name, LookupLocation.NO_LOCATION)
@deprecated("Provide `location` explicitly", replaceWith = ReplaceWith("getClassifier(name, LookupLocation.NO_LOCATION)"))
public final fun getFunctions(name: Name): Collection<FunctionDescriptor> = getFunctions(name, LookupLocation.NO_LOCATION)
@deprecated("Provide `location` explicitly", replaceWith = ReplaceWith("getClassifier(name, NoLookupLocation.UNSORTED)"))
public final fun getClassifier(name: Name): ClassifierDescriptor? = getClassifier(name, NoLookupLocation.UNSORTED)
@deprecated("Provide `location` explicitly", replaceWith = ReplaceWith("getClassifier(name, NoLookupLocation.UNSORTED)"))
public final fun getProperties(name: Name): Collection<VariableDescriptor> = getProperties(name, NoLookupLocation.UNSORTED)
@deprecated("Provide `location` explicitly", replaceWith = ReplaceWith("getClassifier(name, NoLookupLocation.UNSORTED)"))
public final fun getFunctions(name: Name): Collection<FunctionDescriptor> = getFunctions(name, NoLookupLocation.UNSORTED)
/**
* All visible descriptors from current scope.
@@ -23,10 +23,11 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
import org.jetbrains.kotlin.descriptors.impl.*;
import org.jetbrains.kotlin.incremental.components.LookupLocation;
import org.jetbrains.kotlin.incremental.components.NoLookupLocation;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter;
import org.jetbrains.kotlin.resolve.scopes.JetScope;
import org.jetbrains.kotlin.incremental.components.LookupLocation;
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
import org.jetbrains.kotlin.types.error.ErrorSimpleFunctionDescriptorImpl;
import org.jetbrains.kotlin.utils.Printer;
@@ -77,19 +78,19 @@ public class ErrorUtils {
@Nullable
@Override
public ClassifierDescriptor getClassifier(@NotNull Name name) {
return getClassifier(name, LookupLocation.NO_LOCATION);
return getClassifier(name, NoLookupLocation.UNSORTED);
}
@NotNull
@Override
public Collection<VariableDescriptor> getProperties(@NotNull Name name) {
return getProperties(name, LookupLocation.NO_LOCATION);
return getProperties(name, NoLookupLocation.UNSORTED);
}
@NotNull
@Override
public Collection<FunctionDescriptor> getFunctions(@NotNull Name name) {
return getFunctions(name, LookupLocation.NO_LOCATION);
return getFunctions(name, NoLookupLocation.UNSORTED);
}
}