UsageLocation -> LookupLocation

This commit is contained in:
Zalim Bashorov
2015-08-04 22:03:20 +03:00
parent 96696c6846
commit 2aa4c383cd
52 changed files with 190 additions and 194 deletions
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.CallResolverUtilPackage;
import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilPackage;
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
import org.jetbrains.kotlin.resolve.scopes.UsageLocation;
import org.jetbrains.kotlin.resolve.scopes.LookupLocation;
import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.types.TypeUtils;
import org.jetbrains.kotlin.types.checker.JetTypeChecker;
@@ -60,7 +60,7 @@ public class CodegenUtil {
@NotNull ClassifierDescriptor returnedClassifier,
@NotNull ClassifierDescriptor... valueParameterClassifiers
) {
Collection<FunctionDescriptor> functions = owner.getDefaultType().getMemberScope().getFunctions(name, UsageLocation.NO_LOCATION);
Collection<FunctionDescriptor> functions = owner.getDefaultType().getMemberScope().getFunctions(name, LookupLocation.NO_LOCATION);
for (FunctionDescriptor function : functions) {
if (!CallResolverUtilPackage.isOrOverridesSynthesized(function)
&& function.getTypeParameters().isEmpty()
@@ -36,7 +36,7 @@ import org.jetbrains.kotlin.load.kotlin.PackageClassUtils;
import org.jetbrains.kotlin.psi.JetElement;
import org.jetbrains.kotlin.resolve.BindingContext;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.scopes.UsageLocation;
import org.jetbrains.kotlin.resolve.scopes.LookupLocation;
import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.types.expressions.OperatorConventions;
import org.jetbrains.kotlin.utils.UtilsPackage;
@@ -453,6 +453,6 @@ public class ClosureCodegen extends MemberCodegen<JetElement> {
ClassDescriptor elementClass = elementDescriptor.getExtensionReceiverParameter() == null
? getBuiltIns(elementDescriptor).getFunction(arity)
: getBuiltIns(elementDescriptor).getExtensionFunction(arity);
return elementClass.getDefaultType().getMemberScope().getFunctions(OperatorConventions.INVOKE, UsageLocation.NO_LOCATION).iterator().next();
return elementClass.getDefaultType().getMemberScope().getFunctions(OperatorConventions.INVOKE, LookupLocation.NO_LOCATION).iterator().next();
}
}
@@ -74,7 +74,7 @@ import org.jetbrains.kotlin.resolve.inline.InlineUtil;
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterKind;
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterSignature;
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature;
import org.jetbrains.kotlin.resolve.scopes.UsageLocation;
import org.jetbrains.kotlin.resolve.scopes.LookupLocation;
import org.jetbrains.kotlin.resolve.scopes.receivers.*;
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor;
import org.jetbrains.kotlin.types.JetType;
@@ -1075,7 +1075,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
Type asmLoopRangeType = asmType(loopRangeType);
Collection<VariableDescriptor> incrementProp =
loopRangeType.getMemberScope().getProperties(Name.identifier("increment"), UsageLocation.NO_LOCATION);
loopRangeType.getMemberScope().getProperties(Name.identifier("increment"), LookupLocation.NO_LOCATION);
assert incrementProp.size() == 1 : loopRangeType + " " + incrementProp.size();
incrementType = asmType(incrementProp.iterator().next().getType());
@@ -62,7 +62,7 @@ import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmClassSignature;
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterKind;
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterSignature;
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature;
import org.jetbrains.kotlin.resolve.scopes.UsageLocation;
import org.jetbrains.kotlin.resolve.scopes.LookupLocation;
import org.jetbrains.kotlin.resolve.scopes.receivers.ExtensionReceiver;
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
import org.jetbrains.kotlin.resolve.scopes.receivers.ThisReceiver;
@@ -403,7 +403,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
private boolean isGenericToArrayPresent() {
Collection<FunctionDescriptor> functions =
descriptor.getDefaultType().getMemberScope().getFunctions(Name.identifier("toArray"), UsageLocation.NO_LOCATION);
descriptor.getDefaultType().getMemberScope().getFunctions(Name.identifier("toArray"), LookupLocation.NO_LOCATION);
for (FunctionDescriptor function : functions) {
if (CallResolverUtilPackage.isOrOverridesSynthesized(function)) {
continue;
@@ -817,7 +817,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
Type type = typeMapper.mapType(getBuiltIns(descriptor).getArrayType(INVARIANT, descriptor.getDefaultType()));
FunctionDescriptor valuesFunction =
KotlinPackage.single(descriptor.getStaticScope().getFunctions(ENUM_VALUES, UsageLocation.NO_LOCATION), new Function1<FunctionDescriptor, Boolean>() {
KotlinPackage.single(descriptor.getStaticScope().getFunctions(ENUM_VALUES, LookupLocation.NO_LOCATION), new Function1<FunctionDescriptor, Boolean>() {
@Override
public Boolean invoke(FunctionDescriptor descriptor) {
return CodegenUtil.isEnumValuesMethod(descriptor);
@@ -837,7 +837,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
private void generateEnumValueOfMethod() {
FunctionDescriptor valueOfFunction =
KotlinPackage.single(descriptor.getStaticScope().getFunctions(ENUM_VALUE_OF, UsageLocation.NO_LOCATION), new Function1<FunctionDescriptor, Boolean>() {
KotlinPackage.single(descriptor.getStaticScope().getFunctions(ENUM_VALUE_OF, LookupLocation.NO_LOCATION), new Function1<FunctionDescriptor, Boolean>() {
@Override
public Boolean invoke(FunctionDescriptor descriptor) {
return CodegenUtil.isEnumValueOfMethod(descriptor);
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.psi.JetFile;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.scopes.UsageLocation;
import org.jetbrains.kotlin.resolve.scopes.LookupLocation;
import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.types.expressions.OperatorConventions;
import org.jetbrains.org.objectweb.asm.MethodVisitor;
@@ -149,7 +149,7 @@ public class SamWrapperCodegen {
(ClassDescriptor) erasedInterfaceFunction.getContainingDeclaration(), OwnerKind.IMPLEMENTATION, state), cv, state, parentCodegen);
FunctionDescriptor invokeFunction =
functionJetType.getMemberScope().getFunctions(OperatorConventions.INVOKE, UsageLocation.NO_LOCATION).iterator().next().getOriginal();
functionJetType.getMemberScope().getFunctions(OperatorConventions.INVOKE, LookupLocation.NO_LOCATION).iterator().next().getOriginal();
StackValue functionField = StackValue.field(functionType, ownerType, FUNCTION_FIELD_NAME, false, StackValue.none());
codegen.genDelegate(erasedInterfaceFunction, invokeFunction, functionField);
@@ -44,7 +44,7 @@ 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.resolve.scopes.UsageLocation;
import org.jetbrains.kotlin.resolve.scopes.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, UsageLocation.NO_LOCATION);
Collection<FunctionDescriptor> superFunctionCandidates = supertype.getMemberScope().getFunctions(name, LookupLocation.NO_LOCATION);
for (FunctionDescriptor candidate : superFunctionCandidates) {
JvmMethodSignature candidateSignature = SIGNATURE_MAPPER.mapToJvmMethodSignature(candidate);
if (JvmSignaturePackage.erasedSignaturesEqualIgnoringReturnTypes(autoSignature, candidateSignature)) {
@@ -24,10 +24,7 @@ import org.jetbrains.kotlin.descriptors.impl.PropertyGetterDescriptorImpl
import org.jetbrains.kotlin.descriptors.impl.PropertySetterDescriptorImpl
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.DescriptorUtils
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.UsageLocation
import org.jetbrains.kotlin.resolve.scopes.*
import org.jetbrains.kotlin.storage.StorageManager
import org.jetbrains.kotlin.types.*
import org.jetbrains.kotlin.types.typeUtil.isBoolean
@@ -145,7 +142,7 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager) : JetScopeImp
return null
}
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name, location: UsageLocation): Collection<PropertyDescriptor> {
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
//TODO: use location parameter!
var result: SmartList<PropertyDescriptor>? = null
@@ -301,4 +298,4 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager) : JetScopeImp
initialize(getter, setter)
}
}
}
}
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.descriptorUtil.parentsWithSelf
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
import org.jetbrains.kotlin.resolve.scopes.JetScope
import org.jetbrains.kotlin.resolve.scopes.UsageLocation
import org.jetbrains.kotlin.resolve.scopes.LookupLocation
import org.jetbrains.kotlin.storage.StorageManager
import org.jetbrains.kotlin.types.DescriptorSubstitutor
import org.jetbrains.kotlin.types.JetType
@@ -55,7 +55,7 @@ class SamAdapterFunctionsScope(storageManager: StorageManager) : JetScope by Jet
return MyFunctionDescriptor(enhancedFunction)
}
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name, location: UsageLocation): Collection<FunctionDescriptor> {
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
var result: SmartList<FunctionDescriptor>? = null
for (type in receiverTypes) {
for (function in type.memberScope.getFunctions(name, location)) {
@@ -119,4 +119,4 @@ class SamAdapterFunctionsScope(storageManager: StorageManager) : JetScope by Jet
override fun hasStableParameterNames() = originalFunction.hasStableParameterNames()
override fun hasSynthesizedParameterNames() = originalFunction.hasSynthesizedParameterNames()
}
}
}
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
import org.jetbrains.kotlin.resolve.scopes.JetScope
import org.jetbrains.kotlin.resolve.scopes.UsageLocation
import org.jetbrains.kotlin.resolve.scopes.LookupLocation
import org.jetbrains.kotlin.types.JetType
import org.jetbrains.kotlin.utils.Printer
import java.util.ArrayList
@@ -42,23 +42,23 @@ class AllUnderImportsScope : JetScope {
return scopes.flatMap { it.getDescriptors(kindFilter, nameFilter) }
}
override fun getClassifier(name: Name, location: UsageLocation): ClassifierDescriptor? {
override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
return scopes.asSequence().map { it.getClassifier(name, location) }.filterNotNull().singleOrNull()
}
override fun getProperties(name: Name, location: UsageLocation): Collection<VariableDescriptor> {
override fun getProperties(name: Name, location: LookupLocation): Collection<VariableDescriptor> {
return scopes.flatMap { it.getProperties(name, location) }
}
override fun getFunctions(name: Name, location: UsageLocation): Collection<FunctionDescriptor> {
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
return scopes.flatMap { it.getFunctions(name, location) }
}
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name, location: UsageLocation): Collection<PropertyDescriptor> {
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
return scopes.flatMap { it.getSyntheticExtensionProperties(receiverTypes, name, location) }
}
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name, location: UsageLocation): Collection<FunctionDescriptor> {
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
return scopes.flatMap { it.getSyntheticExtensionFunctions(receiverTypes, name, location) }
}
@@ -519,7 +519,7 @@ public class DescriptorResolver {
Name name = nameExpression.getReferencedNameAsName();
ClassifierDescriptor classifier = scope.getClassifier(name, UsageLocation.NO_LOCATION);
ClassifierDescriptor classifier = scope.getClassifier(name, LookupLocation.NO_LOCATION);
if (classifier instanceof TypeParameterDescriptor && classifier.getContainingDeclaration() == descriptor) continue;
if (classifier != null) {
@@ -38,7 +38,7 @@ 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.resolve.scopes.UsageLocation;
import org.jetbrains.kotlin.resolve.scopes.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(), UsageLocation.NO_LOCATION));
all.addAll(supertype.getMemberScope().getFunctions(declared.getName(), LookupLocation.NO_LOCATION));
//noinspection unchecked
all.addAll((Collection) supertype.getMemberScope().getProperties(declared.getName(), UsageLocation.NO_LOCATION));
all.addAll((Collection) supertype.getMemberScope().getProperties(declared.getName(), LookupLocation.NO_LOCATION));
for (CallableMemberDescriptor fromSuper : all) {
if (OverridingUtil.DEFAULT.isOverridableBy(fromSuper, declared).getResult() == OVERRIDABLE) {
if (Visibilities.isVisible(ReceiverValue.IRRELEVANT_RECEIVER, fromSuper, declared)) {
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.resolve.scopes.AbstractScopeAdapter;
import org.jetbrains.kotlin.resolve.scopes.JetScope;
import org.jetbrains.kotlin.resolve.scopes.UsageLocation;
import org.jetbrains.kotlin.resolve.scopes.LookupLocation;
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
import org.jetbrains.kotlin.resolve.validation.SymbolUsageValidator;
@@ -229,14 +229,14 @@ public class QualifiedExpressionResolver {
descriptors.add(packageDescriptor);
}
ClassifierDescriptor classifierDescriptor = outerScope.getClassifier(referencedName, UsageLocation.NO_LOCATION);
ClassifierDescriptor classifierDescriptor = outerScope.getClassifier(referencedName, LookupLocation.NO_LOCATION);
if (classifierDescriptor != null) {
descriptors.add(classifierDescriptor);
}
if (lookupMode == LookupMode.EVERYTHING) {
descriptors.addAll(outerScope.getFunctions(referencedName, UsageLocation.NO_LOCATION));
descriptors.addAll(outerScope.getProperties(referencedName, UsageLocation.NO_LOCATION));
descriptors.addAll(outerScope.getFunctions(referencedName, LookupLocation.NO_LOCATION));
descriptors.addAll(outerScope.getProperties(referencedName, LookupLocation.NO_LOCATION));
VariableDescriptor localVariable = outerScope.getLocalVariable(referencedName);
if (localVariable != null) {
@@ -20,20 +20,20 @@ import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
import org.jetbrains.kotlin.resolve.scopes.JetScopeImpl
import org.jetbrains.kotlin.resolve.scopes.UsageLocation
import org.jetbrains.kotlin.resolve.scopes.LookupLocation
import org.jetbrains.kotlin.utils.Printer
class SingleImportScope(private val aliasName: Name, private val descriptors: Collection<DeclarationDescriptor>) : JetScopeImpl() {
override fun getClassifier(name: Name, location: UsageLocation)
override fun getClassifier(name: Name, location: LookupLocation)
= if (name == aliasName) descriptors.filterIsInstance<ClassifierDescriptor>().singleOrNull() else null
override fun getPackage(name: Name)
= if (name == aliasName) descriptors.filterIsInstance<PackageViewDescriptor>().singleOrNull() else null
override fun getProperties(name: Name, location: UsageLocation)
override fun getProperties(name: Name, location: LookupLocation)
= if (name == aliasName) descriptors.filterIsInstance<VariableDescriptor>() else emptyList()
override fun getFunctions(name: Name, location: UsageLocation)
override fun getFunctions(name: Name, location: LookupLocation)
= if (name == aliasName) descriptors.filterIsInstance<FunctionDescriptor>() else emptyList()
override fun getContainingDeclaration(): DeclarationDescriptor = throw UnsupportedOperationException()
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.resolve.calls.tasks.collectors.CallableDescriptorCol
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
import org.jetbrains.kotlin.resolve.scopes.JetScope
import org.jetbrains.kotlin.resolve.scopes.JetScopeImpl
import org.jetbrains.kotlin.resolve.scopes.UsageLocation
import org.jetbrains.kotlin.resolve.scopes.LookupLocation
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver
import org.jetbrains.kotlin.types.DynamicType
import org.jetbrains.kotlin.types.JetType
@@ -49,7 +49,7 @@ object DynamicCallableDescriptors {
p.println(javaClass.getSimpleName(), ": dynamic candidates for " + call)
}
override fun getFunctions(name: Name, location: UsageLocation): Collection<FunctionDescriptor> {
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
if (isAugmentedAssignmentConvention(name)) return listOf()
if (call.getCallType() == Call.CallType.INVOKE
&& call.getValueArgumentList() == null && call.getFunctionLiteralArguments().isEmpty()) {
@@ -77,7 +77,7 @@ object DynamicCallableDescriptors {
return false
}
override fun getProperties(name: Name, location: UsageLocation): Collection<VariableDescriptor> {
override fun getProperties(name: Name, location: LookupLocation): Collection<VariableDescriptor> {
return if (call.getValueArgumentList() == null && call.getValueArguments().isEmpty()) {
listOf(createDynamicProperty(owner, name, call))
}
@@ -30,7 +30,7 @@ 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.resolve.scopes.UsageLocation;
import org.jetbrains.kotlin.resolve.scopes.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(), UsageLocation.NO_LOCATION);
ClassifierDescriptor scopeDescriptor = resolutionScope.getClassifier(classOrObject.getNameAsSafeName(), LookupLocation.NO_LOCATION);
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(), UsageLocation.NO_LOCATION);
scopeForDeclaration.getFunctions(function.getNameAsSafeName(), LookupLocation.NO_LOCATION);
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(), UsageLocation.NO_LOCATION);
classDescriptor.getDefaultType().getMemberScope().getProperties(parameter.getNameAsSafeName(), LookupLocation.NO_LOCATION);
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(), UsageLocation.NO_LOCATION);
scopeForDeclaration.getProperties(property.getNameAsSafeName(), LookupLocation.NO_LOCATION);
return getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, property);
}
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.resolve.QualifiedExpressionResolver
import org.jetbrains.kotlin.resolve.QualifiedExpressionResolver.LookupMode
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
import org.jetbrains.kotlin.resolve.scopes.JetScope
import org.jetbrains.kotlin.resolve.scopes.UsageLocation
import org.jetbrains.kotlin.resolve.scopes.LookupLocation
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
import org.jetbrains.kotlin.storage.StorageManager
import org.jetbrains.kotlin.types.JetType
@@ -234,7 +234,7 @@ class LazyImportScope(
return Visibilities.isVisible(ReceiverValue.IRRELEVANT_RECEIVER, descriptor, importResolver.moduleDescriptor) == includeVisible
}
override fun getClassifier(name: Name, location: UsageLocation): ClassifierDescriptor? {
override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
return importResolver.selectSingleFromImports(name, LookupMode.ONLY_CLASSES_AND_PACKAGES) { scope, name ->
val descriptor = scope.getClassifier(name, location)
if (descriptor != null && isClassVisible(descriptor as ClassDescriptor/*no type parameter can be imported*/)) descriptor else null
@@ -246,24 +246,24 @@ class LazyImportScope(
return importResolver.selectSingleFromImports(name, LookupMode.ONLY_CLASSES_AND_PACKAGES) { scope, name -> scope.getPackage(name) }
}
override fun getProperties(name: Name, location: UsageLocation): Collection<VariableDescriptor> {
override fun getProperties(name: Name, location: LookupLocation): Collection<VariableDescriptor> {
if (filteringKind == FilteringKind.INVISIBLE_CLASSES) return listOf()
return importResolver.collectFromImports(name, LookupMode.EVERYTHING) { scope, name -> scope.getProperties(name, location) }
}
override fun getLocalVariable(name: Name) = null
override fun getFunctions(name: Name, location: UsageLocation): Collection<FunctionDescriptor> {
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
if (filteringKind == FilteringKind.INVISIBLE_CLASSES) return listOf()
return importResolver.collectFromImports(name, LookupMode.EVERYTHING) { scope, name -> scope.getFunctions(name, location) }
}
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name, location: UsageLocation): Collection<PropertyDescriptor> {
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
if (filteringKind == FilteringKind.INVISIBLE_CLASSES) return listOf()
return importResolver.collectFromImports(name, LookupMode.EVERYTHING) { scope, name -> scope.getSyntheticExtensionProperties(receiverTypes, name, location) }
}
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name, location: UsageLocation): Collection<FunctionDescriptor> {
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
if (filteringKind == FilteringKind.INVISIBLE_CLASSES) return listOf()
return importResolver.collectFromImports(name, LookupMode.EVERYTHING) { scope, name -> scope.getSyntheticExtensionFunctions(receiverTypes, name, location) }
}
@@ -41,7 +41,7 @@ import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyAnnotationsContextImpl;
import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyPackageDescriptor;
import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyScriptDescriptor;
import org.jetbrains.kotlin.resolve.scopes.JetScope;
import org.jetbrains.kotlin.resolve.scopes.UsageLocation;
import org.jetbrains.kotlin.resolve.scopes.LookupLocation;
import org.jetbrains.kotlin.storage.*;
import javax.inject.Inject;
@@ -289,7 +289,7 @@ public class ResolveSession implements KotlinCodeAnalyzer, LazyClassContext {
public ClassDescriptor getClassDescriptorForScript(@NotNull JetScript script) {
JetScope resolutionScope = lazyDeclarationResolver.resolutionScopeToResolveDeclaration(script);
FqName fqName = ScriptNameUtil.classNameForScript(script);
ClassifierDescriptor classifier = resolutionScope.getClassifier(fqName.shortName(), UsageLocation.NO_LOCATION);
ClassifierDescriptor classifier = resolutionScope.getClassifier(fqName.shortName(), LookupLocation.NO_LOCATION);
assert classifier != null : "No descriptor for " + fqName + " in file " + script.getContainingFile();
return (ClassDescriptor) classifier;
}
@@ -31,7 +31,7 @@ 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.resolve.scopes.UsageLocation;
import org.jetbrains.kotlin.resolve.scopes.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, UsageLocation.NO_LOCATION);
ClassifierDescriptor classifier = scope.getClassifier(name, LookupLocation.NO_LOCATION);
if (!(classifier instanceof ClassDescriptor)) return null;
scope = ((ClassDescriptor) classifier).getUnsubstitutedInnerClassesScope();
}
@@ -17,7 +17,10 @@
package org.jetbrains.kotlin.resolve.lazy.descriptors
import com.google.common.collect.Sets
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.VariableDescriptor
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.BindingTrace
@@ -29,10 +32,9 @@ import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProvider
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.UsageLocation
import org.jetbrains.kotlin.resolve.scopes.LookupLocation
import org.jetbrains.kotlin.storage.MemoizedFunctionToNotNull
import org.jetbrains.kotlin.storage.StorageManager
import org.jetbrains.kotlin.types.JetType
import org.jetbrains.kotlin.utils.Printer
import org.jetbrains.kotlin.utils.toReadOnlyList
import java.util.LinkedHashSet
@@ -62,9 +64,9 @@ protected constructor(
override fun getContainingDeclaration() = thisDescriptor
override fun getClassifier(name: Name, location: UsageLocation): ClassDescriptor? = classDescriptors(name).firstOrNull()
override fun getClassifier(name: Name, location: LookupLocation): ClassDescriptor? = classDescriptors(name).firstOrNull()
override fun getFunctions(name: Name, location: UsageLocation): Collection<FunctionDescriptor> = functionDescriptors(name)
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> = functionDescriptors(name)
private fun doGetFunctions(name: Name): Collection<FunctionDescriptor> {
val result = Sets.newLinkedHashSet<FunctionDescriptor>()
@@ -89,7 +91,7 @@ protected constructor(
protected abstract fun getNonDeclaredFunctions(name: Name, result: MutableSet<FunctionDescriptor>)
override fun getProperties(name: Name, location: UsageLocation): Collection<VariableDescriptor> = propertyDescriptors(name)
override fun getProperties(name: Name, location: LookupLocation): Collection<VariableDescriptor> = propertyDescriptors(name)
public fun doGetProperties(name: Name): Collection<VariableDescriptor> {
val result = LinkedHashSet<VariableDescriptor>()
@@ -369,7 +369,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
}
Name name = ((JetClassOrObjectInfo) companionObjectInfo).getName();
assert name != null;
getUnsubstitutedMemberScope().getClassifier(name, UsageLocation.NO_LOCATION);
getUnsubstitutedMemberScope().getClassifier(name, LookupLocation.NO_LOCATION);
ClassDescriptor companionObjectDescriptor = c.getTrace().get(BindingContext.CLASS, companionObject);
if (companionObjectDescriptor instanceof LazyClassDescriptor) {
assert DescriptorUtils.isCompanionObject(companionObjectDescriptor) : "Not a companion object: " + companionObjectDescriptor;
@@ -34,7 +34,7 @@ import org.jetbrains.kotlin.resolve.lazy.LazyClassContext
import org.jetbrains.kotlin.resolve.lazy.declarations.ClassMemberDeclarationProvider
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
import org.jetbrains.kotlin.resolve.scopes.JetScope
import org.jetbrains.kotlin.resolve.scopes.UsageLocation
import org.jetbrains.kotlin.resolve.scopes.LookupLocation
import org.jetbrains.kotlin.resolve.varianceChecker.VarianceChecker
import org.jetbrains.kotlin.storage.NotNullLazyValue
import org.jetbrains.kotlin.storage.NullableLazyValue
@@ -115,7 +115,7 @@ public open class LazyClassMemberScope(
OverrideResolver.resolveUnknownVisibilities(result, trace)
}
override fun getFunctions(name: Name, location: UsageLocation): Collection<FunctionDescriptor> {
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
// TODO: this should be handled by lazy function descriptors
val functions = super.getFunctions(name, location)
resolveUnknownVisibilitiesForMembers(functions)
@@ -173,7 +173,7 @@ public open class LazyClassMemberScope(
}
}
override fun getProperties(name: Name, location: UsageLocation): Collection<VariableDescriptor> {
override fun getProperties(name: Name, location: LookupLocation): Collection<VariableDescriptor> {
// TODO: this should be handled by lazy property descriptors
val properties = super.getProperties(name, location)
resolveUnknownVisibilitiesForMembers(properties as Collection<CallableMemberDescriptor>)
@@ -16,15 +16,13 @@
package org.jetbrains.kotlin.resolve.scopes
import com.google.common.collect.*
import com.intellij.util.SmartList
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.types.checker.JetTypeChecker
import org.jetbrains.kotlin.utils.Printer
import java.util.*
import com.intellij.util.SmartList
import org.jetbrains.kotlin.util.collectionUtils.concatInOrder
import org.jetbrains.kotlin.utils.Printer
import java.util.ArrayList
import java.util.HashMap
// Reads from:
// 1. Maps
@@ -156,7 +154,7 @@ public class WritableScopeImpl @jvmOverloads constructor(
functionsByName!![name] = functionsByName!![name] + descriptorIndex
}
override fun getFunctions(name: Name, location: UsageLocation): Collection<FunctionDescriptor> {
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
checkMayRead()
return concatInOrder(functionsByName(name), workerScope.getFunctions(name, location))
@@ -166,7 +164,7 @@ public class WritableScopeImpl @jvmOverloads constructor(
addVariableOrClassDescriptor(classifierDescriptor)
}
override fun getClassifier(name: Name, location: UsageLocation): ClassifierDescriptor? {
override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
checkMayRead()
return variableOrClassDescriptorByName(name) as? ClassifierDescriptor
@@ -270,13 +268,13 @@ public class WritableScopeImpl @jvmOverloads constructor(
return workerScope.getLocalVariable(name)
}
override fun getFunctions(name: Name, location: UsageLocation): Collection<FunctionDescriptor> {
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
checkMayRead()
return concatInOrder(functionsByName(name, descriptorLimit), workerScope.getFunctions(name, location))
}
override fun getClassifier(name: Name, location: UsageLocation): ClassifierDescriptor? {
override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
checkMayRead()
return variableOrClassDescriptorByName(name, descriptorLimit) as? ClassifierDescriptor
@@ -38,7 +38,7 @@ import org.jetbrains.kotlin.renderer.DescriptorRendererOptions;
import org.jetbrains.kotlin.renderer.NameShortness;
import org.jetbrains.kotlin.resolve.BindingContext;
import org.jetbrains.kotlin.resolve.scopes.JetScope;
import org.jetbrains.kotlin.resolve.scopes.UsageLocation;
import org.jetbrains.kotlin.resolve.scopes.LookupLocation;
import org.jetbrains.kotlin.test.JetLiteFixture;
import org.jetbrains.kotlin.test.JetTestUtils;
import org.jetbrains.kotlin.types.TypeProjection;
@@ -155,7 +155,7 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends JetLiteFix
protected static FunctionDescriptor getFunctionDescriptor(@NotNull PackageFragmentDescriptor packageView, @NotNull String name) {
Name functionName = Name.identifier(name);
JetScope memberScope = packageView.getMemberScope();
Collection<FunctionDescriptor> functions = memberScope.getFunctions(functionName, UsageLocation.NO_LOCATION);
Collection<FunctionDescriptor> functions = memberScope.getFunctions(functionName, LookupLocation.NO_LOCATION);
assert functions.size() == 1 : "Failed to find function " + functionName + " in class" + "." + packageView.getName();
return functions.iterator().next();
}
@@ -164,7 +164,7 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends JetLiteFix
private static FunctionDescriptor getFunctionDescriptor(@NotNull ClassDescriptor classDescriptor, @NotNull String name) {
Name functionName = Name.identifier(name);
JetScope memberScope = classDescriptor.getMemberScope(Collections.<TypeProjection>emptyList());
Collection<FunctionDescriptor> functions = memberScope.getFunctions(functionName, UsageLocation.NO_LOCATION);
Collection<FunctionDescriptor> functions = memberScope.getFunctions(functionName, LookupLocation.NO_LOCATION);
assert functions.size() == 1 : "Failed to find function " + functionName + " in class" + "." + classDescriptor.getName();
return functions.iterator().next();
}
@@ -173,13 +173,13 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends JetLiteFix
protected static PropertyDescriptor getPropertyDescriptor(@NotNull PackageFragmentDescriptor packageView, @NotNull String name, boolean failOnMissing) {
Name propertyName = Name.identifier(name);
JetScope memberScope = packageView.getMemberScope();
Collection<VariableDescriptor> properties = memberScope.getProperties(propertyName, UsageLocation.NO_LOCATION);
Collection<VariableDescriptor> properties = memberScope.getProperties(propertyName, LookupLocation.NO_LOCATION);
if (properties.isEmpty()) {
for (DeclarationDescriptor descriptor : memberScope.getAllDescriptors()) {
if (descriptor instanceof ClassDescriptor) {
Collection<VariableDescriptor> classProperties =
((ClassDescriptor) descriptor).getMemberScope(Collections.<TypeProjection>emptyList())
.getProperties(propertyName, UsageLocation.NO_LOCATION);
.getProperties(propertyName, LookupLocation.NO_LOCATION);
if (!classProperties.isEmpty()) {
properties = classProperties;
break;
@@ -200,7 +200,7 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends JetLiteFix
private static PropertyDescriptor getPropertyDescriptor(@NotNull ClassDescriptor classDescriptor, @NotNull String name) {
Name propertyName = Name.identifier(name);
JetScope memberScope = classDescriptor.getMemberScope(Collections.<TypeProjection>emptyList());
Collection<VariableDescriptor> properties = memberScope.getProperties(propertyName, UsageLocation.NO_LOCATION);
Collection<VariableDescriptor> properties = memberScope.getProperties(propertyName, LookupLocation.NO_LOCATION);
assert properties.size() == 1 : "Failed to find property " + propertyName + " in class " + classDescriptor.getName();
return (PropertyDescriptor) properties.iterator().next();
}
@@ -208,7 +208,7 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends JetLiteFix
@NotNull
protected static ClassDescriptor getClassDescriptor(@NotNull PackageFragmentDescriptor packageView, @NotNull String name) {
Name className = Name.identifier(name);
ClassifierDescriptor aClass = packageView.getMemberScope().getClassifier(className, UsageLocation.NO_LOCATION);
ClassifierDescriptor aClass = packageView.getMemberScope().getClassifier(className, LookupLocation.NO_LOCATION);
assertNotNull("Failed to find class: " + packageView.getName() + "." + className, aClass);
assert aClass instanceof ClassDescriptor : "Not a class: " + aClass;
return (ClassDescriptor) aClass;
@@ -218,7 +218,7 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends JetLiteFix
private static ClassDescriptor getInnerClassDescriptor(@NotNull ClassDescriptor classDescriptor, @NotNull String name) {
Name propertyName = Name.identifier(name);
JetScope memberScope = classDescriptor.getMemberScope(Collections.<TypeProjection>emptyList());
ClassifierDescriptor innerClass = memberScope.getClassifier(propertyName, UsageLocation.NO_LOCATION);
ClassifierDescriptor innerClass = memberScope.getClassifier(propertyName, LookupLocation.NO_LOCATION);
assert innerClass instanceof ClassDescriptor : "Failed to find inner class " +
propertyName +
" in class " +
@@ -24,7 +24,7 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.resolve.scopes.JetScope;
import org.jetbrains.kotlin.resolve.scopes.UsageLocation;
import org.jetbrains.kotlin.resolve.scopes.LookupLocation;
import org.jetbrains.kotlin.types.JetType;
import org.junit.Assert;
@@ -411,7 +411,7 @@ public class DescriptorValidator {
public Void visitVariableDescriptor(
VariableDescriptor descriptor, JetScope scope
) {
assertFound(scope, descriptor, scope.getProperties(descriptor.getName(), UsageLocation.NO_LOCATION));
assertFound(scope, descriptor, scope.getProperties(descriptor.getName(), LookupLocation.NO_LOCATION));
return null;
}
@@ -419,7 +419,7 @@ public class DescriptorValidator {
public Void visitFunctionDescriptor(
FunctionDescriptor descriptor, JetScope scope
) {
assertFound(scope, descriptor, scope.getFunctions(descriptor.getName(), UsageLocation.NO_LOCATION));
assertFound(scope, descriptor, scope.getFunctions(descriptor.getName(), LookupLocation.NO_LOCATION));
return null;
}
@@ -427,7 +427,7 @@ public class DescriptorValidator {
public Void visitTypeParameterDescriptor(
TypeParameterDescriptor descriptor, JetScope scope
) {
assertFound(scope, descriptor, scope.getClassifier(descriptor.getName(), UsageLocation.NO_LOCATION), true);
assertFound(scope, descriptor, scope.getClassifier(descriptor.getName(), LookupLocation.NO_LOCATION), true);
return null;
}
@@ -435,7 +435,7 @@ public class DescriptorValidator {
public Void visitClassDescriptor(
ClassDescriptor descriptor, JetScope scope
) {
assertFound(scope, descriptor, scope.getClassifier(descriptor.getName(), UsageLocation.NO_LOCATION), true);
assertFound(scope, descriptor, scope.getClassifier(descriptor.getName(), LookupLocation.NO_LOCATION), true);
return null;
}
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.psi.JetFile;
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
import org.jetbrains.kotlin.resolve.lazy.KotlinTestWithEnvironment;
import org.jetbrains.kotlin.resolve.lazy.LazyResolveTestUtil;
import org.jetbrains.kotlin.resolve.scopes.UsageLocation;
import org.jetbrains.kotlin.resolve.scopes.LookupLocation;
import org.jetbrains.kotlin.test.ConfigurationKind;
import java.util.Collection;
@@ -74,7 +74,7 @@ public class BoundsSubstitutorTest extends KotlinTestWithEnvironment {
JetFile jetFile = JetPsiFactory(getProject()).createFile("fun.kt", text);
ModuleDescriptor module = LazyResolveTestUtil.resolveLazily(Collections.singletonList(jetFile), getEnvironment());
Collection<FunctionDescriptor> functions =
module.getPackage(FqName.ROOT).getMemberScope().getFunctions(Name.identifier("f"), UsageLocation.NO_LOCATION);
module.getPackage(FqName.ROOT).getMemberScope().getFunctions(Name.identifier("f"), LookupLocation.NO_LOCATION);
assert functions.size() == 1 : "Many functions defined";
FunctionDescriptor function = ContainerUtil.getFirstItem(functions);
@@ -623,7 +623,7 @@ public class JetTypeCheckerTest extends JetLiteFixture {
else {
Name shortName = fqName.shortName();
assert shortName.equals(defaultImport.getImportedName());
writableScope.addClassifierDescriptor(module.getPackage(fqName.parent()).getMemberScope().getClassifier(shortName, UsageLocation.NO_LOCATION));
writableScope.addClassifierDescriptor(module.getPackage(fqName.parent()).getMemberScope().getClassifier(shortName, LookupLocation.NO_LOCATION));
}
}
scopeChain.add(module.getPackage(FqName.ROOT).getMemberScope());
@@ -85,7 +85,7 @@ public class TypeSubstitutorTest extends KotlinTestWithEnvironment {
JetFile jetFile = JetPsiFactory(getProject()).createFile(text);
ModuleDescriptor module = LazyResolveTestUtil.resolveLazily(Collections.singletonList(jetFile), getEnvironment());
JetScope topLevelDeclarations = module.getPackage(FqName.ROOT).getMemberScope();
ClassifierDescriptor contextClass = topLevelDeclarations.getClassifier(Name.identifier("___Context"), UsageLocation.NO_LOCATION);
ClassifierDescriptor contextClass = topLevelDeclarations.getClassifier(Name.identifier("___Context"), LookupLocation.NO_LOCATION);
assert contextClass instanceof ClassDescriptor;
WritableScopeImpl typeParameters = new WritableScopeImpl(JetScope.Empty.INSTANCE$, module, RedeclarationHandler.THROW_EXCEPTION,
"Type parameter scope");
@@ -124,7 +124,7 @@ public class TypeSubstitutorTest extends KotlinTestWithEnvironment {
String typeParameterName = pair.first;
String replacementProjectionString = pair.second;
ClassifierDescriptor classifier = scope.getClassifier(Name.identifier(typeParameterName), UsageLocation.NO_LOCATION);
ClassifierDescriptor classifier = scope.getClassifier(Name.identifier(typeParameterName), LookupLocation.NO_LOCATION);
assertNotNull("No type parameter named " + typeParameterName, classifier);
assertTrue(typeParameterName + " is not a type parameter: " + classifier, classifier instanceof TypeParameterDescriptor);
@@ -40,7 +40,7 @@ import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.DescriptorFactory
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
import org.jetbrains.kotlin.resolve.scopes.UsageLocation
import org.jetbrains.kotlin.resolve.scopes.LookupLocation
import org.jetbrains.kotlin.types.JetType
import org.jetbrains.kotlin.types.TypeUtils
import org.jetbrains.kotlin.utils.*
@@ -285,7 +285,7 @@ public class LazyJavaClassMemberScope(
override fun getDispatchReceiverParameter(): ReceiverParameterDescriptor? =
DescriptorUtils.getDispatchReceiverParameterIfNeeded(getContainingDeclaration())
override fun getClassifier(name: Name, location: UsageLocation): ClassifierDescriptor? = nestedClasses(name)
override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? = nestedClasses(name)
override fun getClassNames(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<Name>
= nestedClassIndex().keySet() + enumEntryIndex().keySet()
@@ -33,7 +33,7 @@ import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.name.SpecialNames
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
import org.jetbrains.kotlin.resolve.scopes.JetScope
import org.jetbrains.kotlin.resolve.scopes.UsageLocation
import org.jetbrains.kotlin.resolve.scopes.LookupLocation
import org.jetbrains.kotlin.utils.addIfNotNull
public class LazyJavaPackageScope(
@@ -76,11 +76,11 @@ public class LazyJavaPackageScope(
}
}
override fun getClassifier(name: Name, location: UsageLocation): ClassifierDescriptor? =
override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? =
if (SpecialNames.isSafeIdentifier(name)) classes(name) else null
override fun getProperties(name: Name, location: UsageLocation) = deserializedPackageScope().getProperties(name, location)
override fun getFunctions(name: Name, location: UsageLocation) = deserializedPackageScope().getFunctions(name, location) + super.getFunctions(name, location)
override fun getProperties(name: Name, location: LookupLocation) = deserializedPackageScope().getProperties(name, location)
override fun getFunctions(name: Name, location: LookupLocation) = deserializedPackageScope().getFunctions(name, location) + super.getFunctions(name, location)
override fun addExtraDescriptors(result: MutableSet<DeclarationDescriptor>,
kindFilter: DescriptorKindFilter,
@@ -40,7 +40,7 @@ import org.jetbrains.kotlin.resolve.scopes.DescriptorKindExclude.NonExtensions
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.UsageLocation
import org.jetbrains.kotlin.resolve.scopes.LookupLocation
import org.jetbrains.kotlin.storage.NotNullLazyValue
import org.jetbrains.kotlin.types.JetType
import org.jetbrains.kotlin.types.TypeUtils
@@ -210,7 +210,7 @@ public abstract class LazyJavaScope(
return ResolvedValueParameters(descriptors, synthesizedNames)
}
override fun getFunctions(name: Name, location: UsageLocation) = functions(name)
override fun getFunctions(name: Name, location: LookupLocation) = functions(name)
protected open fun getFunctionNames(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<Name>
= memberIndex().getMethodNames(nameFilter)
@@ -289,7 +289,7 @@ public abstract class LazyJavaScope(
return propertyType
}
override fun getProperties(name: Name, location: UsageLocation): Collection<VariableDescriptor> = properties(name)
override fun getProperties(name: Name, location: LookupLocation): Collection<VariableDescriptor> = properties(name)
override fun getOwnDeclaredDescriptors() = getDescriptors()
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.resolve.DescriptorFactory.createEnumValueOfMethod
import org.jetbrains.kotlin.resolve.DescriptorFactory.createEnumValuesMethod
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
import org.jetbrains.kotlin.resolve.scopes.UsageLocation
import org.jetbrains.kotlin.resolve.scopes.LookupLocation
import org.jetbrains.kotlin.utils.addIfNotNull
public class LazyJavaStaticClassScope(
@@ -58,7 +58,7 @@ public class LazyJavaStaticClassScope(
memberIndex().getAllFieldNames()
override fun getClassNames(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<Name> = listOf()
override fun getClassifier(name: Name, location: UsageLocation): ClassifierDescriptor? = null
override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? = null
override fun getSubPackages(): Collection<FqName> = listOf()
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.constants.ConstantValue;
import org.jetbrains.kotlin.resolve.scopes.JetScope;
import org.jetbrains.kotlin.resolve.scopes.UsageLocation;
import org.jetbrains.kotlin.resolve.scopes.LookupLocation;
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
import org.jetbrains.kotlin.types.*;
import org.jetbrains.kotlin.types.checker.JetTypeChecker;
@@ -239,7 +239,7 @@ public class KotlinBuiltIns {
@NotNull
private ClassDescriptor getAnnotationClassByName(@NotNull Name simpleName) {
ClassifierDescriptor classifier = annotationPackageFragment.getMemberScope().getClassifier(simpleName, UsageLocation.NO_LOCATION);
ClassifierDescriptor classifier = annotationPackageFragment.getMemberScope().getClassifier(simpleName, LookupLocation.NO_LOCATION);
assert classifier instanceof ClassDescriptor : "Must be a class descriptor " + simpleName + ", but was " +
(classifier == null ? "null" : classifier.toString());
return (ClassDescriptor) classifier;
@@ -254,7 +254,7 @@ public class KotlinBuiltIns {
@Nullable
public ClassDescriptor getBuiltInClassByNameNullable(@NotNull Name simpleName) {
ClassifierDescriptor classifier = getBuiltInsPackageFragment().getMemberScope().getClassifier(simpleName, UsageLocation.NO_LOCATION);
ClassifierDescriptor classifier = getBuiltInsPackageFragment().getMemberScope().getClassifier(simpleName, LookupLocation.NO_LOCATION);
assert classifier == null ||
classifier instanceof ClassDescriptor : "Must be a class descriptor " + simpleName + ", but was " + classifier;
return (ClassDescriptor) classifier;
@@ -399,7 +399,7 @@ public class KotlinBuiltIns {
@Nullable
public ClassDescriptor getAnnotationTargetEnumEntry(@NotNull KotlinTarget target) {
ClassifierDescriptor result = getAnnotationTargetEnum().getUnsubstitutedInnerClassesScope().getClassifier(
Name.identifier(target.name()), UsageLocation.NO_LOCATION
Name.identifier(target.name()), LookupLocation.NO_LOCATION
);
return result instanceof ClassDescriptor ? (ClassDescriptor) result : null;
}
@@ -412,7 +412,7 @@ public class KotlinBuiltIns {
@Nullable
public ClassDescriptor getAnnotationRetentionEnumEntry(@NotNull KotlinRetention retention) {
ClassifierDescriptor result = getAnnotationRetentionEnum().getUnsubstitutedInnerClassesScope().getClassifier(
Name.identifier(retention.name()), UsageLocation.NO_LOCATION
Name.identifier(retention.name()), LookupLocation.NO_LOCATION
);
return result instanceof ClassDescriptor ? (ClassDescriptor) result : null;
}
@@ -1038,6 +1038,6 @@ public class KotlinBuiltIns {
@NotNull
public FunctionDescriptor getIdentityEquals() {
return KotlinPackage.first(getBuiltInsPackageFragment().getMemberScope().getFunctions(Name.identifier("identityEquals"), UsageLocation.NO_LOCATION));
return KotlinPackage.first(getBuiltInsPackageFragment().getMemberScope().getFunctions(Name.identifier("identityEquals"), LookupLocation.NO_LOCATION));
}
}
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.OverridingUtil
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
import org.jetbrains.kotlin.resolve.scopes.JetScopeImpl
import org.jetbrains.kotlin.resolve.scopes.UsageLocation
import org.jetbrains.kotlin.resolve.scopes.LookupLocation
import org.jetbrains.kotlin.storage.StorageManager
import org.jetbrains.kotlin.utils.Printer
import org.jetbrains.kotlin.utils.toReadOnlyList
@@ -48,11 +48,11 @@ class FunctionClassScope(
return allDescriptors()
}
override fun getFunctions(name: Name, location: UsageLocation): Collection<FunctionDescriptor> {
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
return allDescriptors().filterIsInstance<FunctionDescriptor>().filter { it.getName() == name }
}
override fun getProperties(name: Name, location: UsageLocation): Collection<VariableDescriptor> {
override fun getProperties(name: Name, location: LookupLocation): Collection<VariableDescriptor> {
return allDescriptors().filterIsInstance<PropertyDescriptor>().filter { it.getName() == name }
}
@@ -192,25 +192,25 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
@NotNull
@Override
@SuppressWarnings("unchecked")
public Collection<VariableDescriptor> getProperties(@NotNull Name name, @NotNull UsageLocation location) {
public Collection<VariableDescriptor> getProperties(@NotNull Name name, @NotNull LookupLocation location) {
return (Collection) properties.invoke(name);
}
@NotNull
@SuppressWarnings("unchecked")
private Collection<PropertyDescriptor> computeProperties(@NotNull Name name) {
return resolveFakeOverrides(name, (Collection) getSupertypeScope().getProperties(name, UsageLocation.NO_LOCATION));
return resolveFakeOverrides(name, (Collection) getSupertypeScope().getProperties(name, LookupLocation.NO_LOCATION));
}
@NotNull
@Override
public Collection<FunctionDescriptor> getFunctions(@NotNull Name name, @NotNull UsageLocation location) {
public Collection<FunctionDescriptor> getFunctions(@NotNull Name name, @NotNull LookupLocation location) {
return functions.invoke(name);
}
@NotNull
private Collection<FunctionDescriptor> computeFunctions(@NotNull Name name) {
return resolveFakeOverrides(name, getSupertypeScope().getFunctions(name, UsageLocation.NO_LOCATION));
return resolveFakeOverrides(name, getSupertypeScope().getFunctions(name, LookupLocation.NO_LOCATION));
}
@NotNull
@@ -266,8 +266,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, UsageLocation.NO_LOCATION));
result.addAll(getProperties(name, UsageLocation.NO_LOCATION));
result.addAll(getFunctions(name, LookupLocation.NO_LOCATION));
result.addAll(getProperties(name, LookupLocation.NO_LOCATION));
}
return result;
}
@@ -35,7 +35,7 @@ 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.resolve.scopes.UsageLocation;
import org.jetbrains.kotlin.resolve.scopes.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), UsageLocation.NO_LOCATION);
classDescriptor.getDefaultType().getMemberScope().getClassifier(Name.identifier(innerClassName), LookupLocation.NO_LOCATION);
assert classifier instanceof ClassDescriptor :
"Inner class " + innerClassName + " in " + classDescriptor + " should be instance of ClassDescriptor, but was: "
+ (classifier == null ? "null" : classifier.getClass());
@@ -31,7 +31,7 @@ public abstract class AbstractScopeAdapter : JetScope {
return workerScope.getImplicitReceiversHierarchy()
}
override fun getFunctions(name: Name, location: UsageLocation): Collection<FunctionDescriptor> {
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
return workerScope.getFunctions(name, location)
}
@@ -39,19 +39,19 @@ public abstract class AbstractScopeAdapter : JetScope {
return workerScope.getPackage(name)
}
override fun getClassifier(name: Name, location: UsageLocation): ClassifierDescriptor? {
override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
return workerScope.getClassifier(name, location)
}
override fun getProperties(name: Name, location: UsageLocation): Collection<VariableDescriptor> {
override fun getProperties(name: Name, location: LookupLocation): Collection<VariableDescriptor> {
return workerScope.getProperties(name, location)
}
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name, location: UsageLocation): Collection<PropertyDescriptor> {
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
return workerScope.getSyntheticExtensionProperties(receiverTypes, name, location)
}
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name, location: UsageLocation): Collection<FunctionDescriptor> {
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
return workerScope.getSyntheticExtensionFunctions(receiverTypes, name, location)
}
@@ -49,25 +49,25 @@ public open class ChainedScope(
return result ?: emptySet()
}
override fun getClassifier(name: Name, location: UsageLocation): ClassifierDescriptor?
override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor?
= getFirstMatch { it.getClassifier(name, location) }
override fun getPackage(name: Name): PackageViewDescriptor?
= getFirstMatch { it.getPackage(name) }
override fun getProperties(name: Name, location: UsageLocation): Collection<VariableDescriptor>
override fun getProperties(name: Name, location: LookupLocation): Collection<VariableDescriptor>
= getFromAllScopes { it.getProperties(name, location) }
override fun getLocalVariable(name: Name): VariableDescriptor?
= getFirstMatch { it.getLocalVariable(name) }
override fun getFunctions(name: Name, location: UsageLocation): Collection<FunctionDescriptor>
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor>
= getFromAllScopes { it.getFunctions(name, location) }
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name, location: UsageLocation): Collection<PropertyDescriptor>
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor>
= getFromAllScopes { it.getSyntheticExtensionProperties(receiverTypes, name, location) }
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name, location: UsageLocation): Collection<FunctionDescriptor>
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor>
= getFromAllScopes { it.getSyntheticExtensionFunctions(receiverTypes, name, location) }
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>): Collection<PropertyDescriptor>
@@ -18,18 +18,17 @@ package org.jetbrains.kotlin.resolve.scopes
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.types.JetType
import org.jetbrains.kotlin.utils.Printer
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
public class ExplicitImportsScope(private val descriptors: Collection<DeclarationDescriptor>) : JetScopeImpl() {
override fun getClassifier(name: Name, location: UsageLocation) = descriptors.filter { it.getName() == name }.firstIsInstanceOrNull<ClassifierDescriptor>()
override fun getClassifier(name: Name, location: LookupLocation) = descriptors.filter { it.getName() == name }.firstIsInstanceOrNull<ClassifierDescriptor>()
override fun getPackage(name: Name)= descriptors.filter { it.getName() == name }.firstIsInstanceOrNull<PackageViewDescriptor>()
override fun getProperties(name: Name, location: UsageLocation) = descriptors.filter { it.getName() == name }.filterIsInstance<VariableDescriptor>()
override fun getProperties(name: Name, location: LookupLocation) = descriptors.filter { it.getName() == name }.filterIsInstance<VariableDescriptor>()
override fun getFunctions(name: Name, location: UsageLocation) = descriptors.filter { it.getName() == name }.filterIsInstance<FunctionDescriptor>()
override fun getFunctions(name: Name, location: LookupLocation) = descriptors.filter { it.getName() == name }.filterIsInstance<FunctionDescriptor>()
override fun getContainingDeclaration() = throw UnsupportedOperationException()
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.utils.Printer
public class FilteringScope(private val workerScope: JetScope, private val predicate: (DeclarationDescriptor) -> Boolean) : JetScope {
override fun getFunctions(name: Name, location: UsageLocation) = workerScope.getFunctions(name, location).filter(predicate)
override fun getFunctions(name: Name, location: LookupLocation) = workerScope.getFunctions(name, location).filter(predicate)
override fun getContainingDeclaration() = workerScope.getContainingDeclaration()
@@ -34,14 +34,14 @@ public class FilteringScope(private val workerScope: JetScope, private val predi
override fun getPackage(name: Name) = filterDescriptor(workerScope.getPackage(name))
override fun getClassifier(name: Name, location: UsageLocation) = filterDescriptor(workerScope.getClassifier(name, location))
override fun getClassifier(name: Name, location: LookupLocation) = filterDescriptor(workerScope.getClassifier(name, location))
override fun getProperties(name: Name, location: UsageLocation) = workerScope.getProperties(name, location).filter(predicate)
override fun getProperties(name: Name, location: LookupLocation) = workerScope.getProperties(name, location).filter(predicate)
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name, location: UsageLocation): Collection<PropertyDescriptor>
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor>
= workerScope.getSyntheticExtensionProperties(receiverTypes, name, location).filter(predicate)
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name, location: UsageLocation): Collection<FunctionDescriptor>
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor>
= workerScope.getSyntheticExtensionFunctions(receiverTypes, name, location).filter(predicate)
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>): Collection<PropertyDescriptor>
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor
import org.jetbrains.kotlin.name.Name
public class InnerClassesScopeWrapper(override val workerScope: JetScope) : AbstractScopeAdapter() {
override fun getClassifier(name: Name, location: UsageLocation) = workerScope.getClassifier(name, location) as? ClassDescriptor
override fun getClassifier(name: Name, location: LookupLocation) = workerScope.getClassifier(name, location) as? ClassDescriptor
override fun getDeclarationsByLabel(labelName: Name) = workerScope.getDeclarationsByLabel(labelName).filterIsInstance<ClassDescriptor>()
@@ -25,18 +25,18 @@ import java.lang.reflect.Modifier
public interface JetScope {
public fun getClassifier(name: Name, location: UsageLocation = UsageLocation.NO_LOCATION): ClassifierDescriptor?
public fun getClassifier(name: Name, location: LookupLocation = LookupLocation.NO_LOCATION): ClassifierDescriptor?
public fun getPackage(name: Name): PackageViewDescriptor?
public fun getProperties(name: Name, location: UsageLocation = UsageLocation.NO_LOCATION): Collection<VariableDescriptor>
public fun getProperties(name: Name, location: LookupLocation = LookupLocation.NO_LOCATION): Collection<VariableDescriptor>
public fun getLocalVariable(name: Name): VariableDescriptor?
public fun getFunctions(name: Name, location: UsageLocation = UsageLocation.NO_LOCATION): Collection<FunctionDescriptor>
public fun getFunctions(name: Name, location: LookupLocation = LookupLocation.NO_LOCATION): Collection<FunctionDescriptor>
public fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name, location: UsageLocation = UsageLocation.NO_LOCATION): Collection<PropertyDescriptor>
public fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name, location: UsageLocation = UsageLocation.NO_LOCATION): Collection<FunctionDescriptor>
public fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name, location: LookupLocation = LookupLocation.NO_LOCATION): Collection<PropertyDescriptor>
public fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name, location: LookupLocation = LookupLocation.NO_LOCATION): Collection<FunctionDescriptor>
public fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>): Collection<PropertyDescriptor>
public fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>): Collection<FunctionDescriptor>
@@ -246,8 +246,8 @@ public interface DescriptorKindExclude {
}
}
public interface UsageLocation {
public interface LookupLocation {
companion object {
val NO_LOCATION = object : UsageLocation {}
val NO_LOCATION = object : LookupLocation {}
}
}
@@ -22,18 +22,18 @@ import org.jetbrains.kotlin.types.JetType
import org.jetbrains.kotlin.utils.Printer
public abstract class JetScopeImpl : JetScope {
override fun getClassifier(name: Name, location: UsageLocation): ClassifierDescriptor? = null
override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? = null
override fun getProperties(name: Name, location: UsageLocation): Collection<VariableDescriptor> = emptyList()
override fun getProperties(name: Name, location: LookupLocation): Collection<VariableDescriptor> = emptyList()
override fun getLocalVariable(name: Name): VariableDescriptor? = null
override fun getPackage(name: Name): PackageViewDescriptor? = null
override fun getFunctions(name: Name, location: UsageLocation): Collection<FunctionDescriptor> = emptyList()
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> = emptyList()
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name, location: UsageLocation): Collection<PropertyDescriptor> = emptyList()
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name, location: UsageLocation): Collection<FunctionDescriptor> = emptyList()
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor> = emptyList()
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor> = emptyList()
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>): Collection<PropertyDescriptor> = emptyList()
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>): Collection<FunctionDescriptor> = emptyList()
@@ -28,7 +28,7 @@ import java.util.ArrayList
public class StaticScopeForKotlinClass(
private val containingClass: ClassDescriptor
) : JetScopeImpl() {
override fun getClassifier(name: Name, location: UsageLocation) = null // TODO
override fun getClassifier(name: Name, location: LookupLocation) = null // TODO
private val functions: List<FunctionDescriptor> by lazy {
if (containingClass.getKind() != ClassKind.ENUM_CLASS) {
@@ -44,7 +44,7 @@ public class StaticScopeForKotlinClass(
override fun getOwnDeclaredDescriptors() = functions
override fun getFunctions(name: Name, location: UsageLocation) = functions.filterTo(ArrayList<FunctionDescriptor>(2)) { it.getName() == name }
override fun getFunctions(name: Name, location: LookupLocation) = functions.filterTo(ArrayList<FunctionDescriptor>(2)) { it.getName() == name }
override fun getContainingDeclaration() = containingClass
@@ -62,18 +62,18 @@ public class SubstitutingScope(private val workerScope: JetScope, private val su
return result
}
override fun getProperties(name: Name, location: UsageLocation) = substitute(workerScope.getProperties(name, location))
override fun getProperties(name: Name, location: LookupLocation) = substitute(workerScope.getProperties(name, location))
override fun getLocalVariable(name: Name) = substitute(workerScope.getLocalVariable(name))
override fun getClassifier(name: Name, location: UsageLocation) = substitute(workerScope.getClassifier(name, location))
override fun getClassifier(name: Name, location: LookupLocation) = substitute(workerScope.getClassifier(name, location))
override fun getFunctions(name: Name, location: UsageLocation) = substitute(workerScope.getFunctions(name, location))
override fun getFunctions(name: Name, location: LookupLocation) = substitute(workerScope.getFunctions(name, location))
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name, location: UsageLocation): Collection<PropertyDescriptor>
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor>
= substitute(workerScope.getSyntheticExtensionProperties(receiverTypes, name, location))
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name, location: UsageLocation): Collection<FunctionDescriptor>
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor>
= substitute(workerScope.getSyntheticExtensionFunctions(receiverTypes, name, location))
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>): Collection<PropertyDescriptor>
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.descriptors.impl.*;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter;
import org.jetbrains.kotlin.resolve.scopes.JetScope;
import org.jetbrains.kotlin.resolve.scopes.UsageLocation;
import org.jetbrains.kotlin.resolve.scopes.LookupLocation;
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
import org.jetbrains.kotlin.types.error.ErrorSimpleFunctionDescriptorImpl;
import org.jetbrains.kotlin.utils.Printer;
@@ -83,13 +83,13 @@ public class ErrorUtils {
@Nullable
@Override
public ClassifierDescriptor getClassifier(@NotNull Name name, @NotNull UsageLocation location) {
public ClassifierDescriptor getClassifier(@NotNull Name name, @NotNull LookupLocation location) {
return createErrorClass(name.asString());
}
@NotNull
@Override
public Set<VariableDescriptor> getProperties(@NotNull Name name, @NotNull UsageLocation location) {
public Set<VariableDescriptor> getProperties(@NotNull Name name, @NotNull LookupLocation location) {
return ERROR_VARIABLE_GROUP;
}
@@ -97,7 +97,7 @@ public class ErrorUtils {
@Override
public Collection<PropertyDescriptor> getSyntheticExtensionProperties(
@NotNull Collection<? extends JetType> receiverTypes, @NotNull Name name,
@NotNull UsageLocation location
@NotNull LookupLocation location
) {
return ERROR_PROPERTY_GROUP;
}
@@ -106,7 +106,7 @@ public class ErrorUtils {
@Override
public Collection<FunctionDescriptor> getSyntheticExtensionFunctions(
@NotNull Collection<? extends JetType> receiverTypes, @NotNull Name name,
@NotNull UsageLocation location
@NotNull LookupLocation location
) {
return Collections.<FunctionDescriptor>singleton(createErrorFunction(this));
}
@@ -143,7 +143,7 @@ public class ErrorUtils {
@NotNull
@Override
public Set<FunctionDescriptor> getFunctions(@NotNull Name name, @NotNull UsageLocation location) {
public Set<FunctionDescriptor> getFunctions(@NotNull Name name, @NotNull LookupLocation location) {
return Collections.<FunctionDescriptor>singleton(createErrorFunction(this));
}
@@ -199,7 +199,7 @@ public class ErrorUtils {
@Nullable
@Override
public ClassifierDescriptor getClassifier(@NotNull Name name, @NotNull UsageLocation location) {
public ClassifierDescriptor getClassifier(@NotNull Name name, @NotNull LookupLocation location) {
throw new IllegalStateException();
}
@@ -211,7 +211,7 @@ public class ErrorUtils {
@NotNull
@Override
public Collection<VariableDescriptor> getProperties(@NotNull Name name, @NotNull UsageLocation location) {
public Collection<VariableDescriptor> getProperties(@NotNull Name name, @NotNull LookupLocation location) {
throw new IllegalStateException();
}
@@ -223,7 +223,7 @@ public class ErrorUtils {
@NotNull
@Override
public Collection<FunctionDescriptor> getFunctions(@NotNull Name name, @NotNull UsageLocation location) {
public Collection<FunctionDescriptor> getFunctions(@NotNull Name name, @NotNull LookupLocation location) {
throw new IllegalStateException();
}
@@ -231,7 +231,7 @@ public class ErrorUtils {
@Override
public Collection<PropertyDescriptor> getSyntheticExtensionProperties(
@NotNull Collection<? extends JetType> receiverTypes, @NotNull Name name,
@NotNull UsageLocation location
@NotNull LookupLocation location
) {
throw new IllegalStateException();
}
@@ -240,7 +240,7 @@ public class ErrorUtils {
@Override
public Collection<FunctionDescriptor> getSyntheticExtensionFunctions(
@NotNull Collection<? extends JetType> receiverTypes, @NotNull Name name,
@NotNull UsageLocation location
@NotNull LookupLocation location
) {
throw new IllegalStateException();
}
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
import org.jetbrains.kotlin.resolve.scopes.JetScopeImpl
import org.jetbrains.kotlin.resolve.scopes.UsageLocation
import org.jetbrains.kotlin.resolve.scopes.LookupLocation
import org.jetbrains.kotlin.serialization.Flags
import org.jetbrains.kotlin.serialization.ProtoBuf
import org.jetbrains.kotlin.serialization.ProtoBuf.Callable.CallableKind
@@ -93,7 +93,7 @@ public abstract class DeserializedMemberScope protected constructor(
protected open fun computeNonDeclaredFunctions(name: Name, functions: MutableCollection<FunctionDescriptor>) {
}
override fun getFunctions(name: Name, location: UsageLocation): Collection<FunctionDescriptor> = functions(name)
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> = functions(name)
private fun computeProperties(name: Name): Collection<VariableDescriptor> {
val descriptors = computeMembers<PropertyDescriptor>(name, Kind.PROPERTY)
@@ -104,9 +104,9 @@ public abstract class DeserializedMemberScope protected constructor(
protected open fun computeNonDeclaredProperties(name: Name, descriptors: MutableCollection<PropertyDescriptor>) {
}
override fun getProperties(name: Name, location: UsageLocation): Collection<VariableDescriptor> = properties.invoke(name)
override fun getProperties(name: Name, location: LookupLocation): Collection<VariableDescriptor> = properties.invoke(name)
override fun getClassifier(name: Name, location: UsageLocation) = getClassDescriptor(name)
override fun getClassifier(name: Name, location: LookupLocation) = getClassDescriptor(name)
protected abstract fun getClassDescriptor(name: Name): ClassifierDescriptor?
@@ -60,7 +60,7 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil;
import org.jetbrains.kotlin.resolve.lazy.KotlinCodeAnalyzer;
import org.jetbrains.kotlin.resolve.scopes.JetScope;
import org.jetbrains.kotlin.resolve.scopes.UsageLocation;
import org.jetbrains.kotlin.resolve.scopes.LookupLocation;
import java.io.IOException;
import java.util.*;
@@ -140,7 +140,7 @@ public class IDELightClassGenerationSupport extends LightClassGenerationSupport
if (declaration instanceof JetFunction) {
JetFunction jetFunction = (JetFunction) declaration;
Name name = jetFunction.getNameAsSafeName();
Collection<FunctionDescriptor> functions = packageDescriptor.getMemberScope().getFunctions(name, UsageLocation.NO_LOCATION);
Collection<FunctionDescriptor> functions = packageDescriptor.getMemberScope().getFunctions(name, LookupLocation.NO_LOCATION);
for (FunctionDescriptor descriptor : functions) {
ForceResolveUtil.forceResolveAllContents(descriptor);
}
@@ -148,7 +148,7 @@ public class IDELightClassGenerationSupport extends LightClassGenerationSupport
else if (declaration instanceof JetProperty) {
JetProperty jetProperty = (JetProperty) declaration;
Name name = jetProperty.getNameAsSafeName();
Collection<VariableDescriptor> properties = packageDescriptor.getMemberScope().getProperties(name, UsageLocation.NO_LOCATION);
Collection<VariableDescriptor> properties = packageDescriptor.getMemberScope().getProperties(name, LookupLocation.NO_LOCATION);
for (VariableDescriptor descriptor : properties) {
ForceResolveUtil.forceResolveAllContents(descriptor);
}
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.scopes.JetScope
import org.jetbrains.kotlin.resolve.scopes.JetScopeImpl
import org.jetbrains.kotlin.resolve.scopes.UsageLocation
import org.jetbrains.kotlin.resolve.scopes.LookupLocation
import org.jetbrains.kotlin.types.ErrorUtils.createErrorType
import org.jetbrains.kotlin.types.TypeProjection
import org.jetbrains.kotlin.types.TypeSubstitution
@@ -49,7 +49,7 @@ private class ScopeWithMissingDependencies(val fqName: FqName, val containing: D
p.println("Special scope for decompiler, containing class with any name")
}
override fun getClassifier(name: Name, location: UsageLocation): ClassifierDescriptor? {
override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
return MissingDependencyErrorClassDescriptor(getContainingDeclaration(), fqName.child(name))
}
}
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.resolve.BindingTraceContext
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.scopes.ChainedScope
import org.jetbrains.kotlin.resolve.scopes.JetScope
import org.jetbrains.kotlin.resolve.scopes.UsageLocation
import org.jetbrains.kotlin.resolve.scopes.LookupLocation
import org.jetbrains.kotlin.types.*
import java.util.HashMap
@@ -105,6 +105,6 @@ public object HeuristicSignatures {
private class TypeParametersScope(params: Collection<TypeParameterDescriptor>) : JetScope by JetScope.Empty {
private val paramsByName = params.map { it.getName() to it }.toMap()
override fun getClassifier(name: Name, location: UsageLocation) = paramsByName[name]
override fun getClassifier(name: Name, location: LookupLocation) = paramsByName[name]
}
}
@@ -54,7 +54,7 @@ import org.jetbrains.kotlin.renderer.NameShortness;
import org.jetbrains.kotlin.resolve.FunctionDescriptorUtil;
import org.jetbrains.kotlin.resolve.VisibilityUtil;
import org.jetbrains.kotlin.resolve.scopes.JetScope;
import org.jetbrains.kotlin.resolve.scopes.UsageLocation;
import org.jetbrains.kotlin.resolve.scopes.LookupLocation;
import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.types.TypeUtils;
import org.jetbrains.kotlin.types.checker.JetTypeChecker;
@@ -268,7 +268,7 @@ public class ChangeMemberFunctionSignatureFix extends JetHintAction<JetNamedFunc
Name name = functionDescriptor.getName();
for (JetType type : TypeUtils.getAllSupertypes(classDescriptor.getDefaultType())) {
JetScope scope = type.getMemberScope();
for (FunctionDescriptor function : scope.getFunctions(name, UsageLocation.NO_LOCATION)) {
for (FunctionDescriptor function : scope.getFunctions(name, LookupLocation.NO_LOCATION)) {
if (!function.getKind().isReal()) continue;
if (function.getModality().isOverridable())
superFunctions.add(function);
@@ -74,7 +74,7 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind;
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
import org.jetbrains.kotlin.resolve.scopes.JetScope;
import org.jetbrains.kotlin.resolve.scopes.UsageLocation;
import org.jetbrains.kotlin.resolve.scopes.LookupLocation;
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
import org.jetbrains.kotlin.resolve.scopes.receivers.ThisReceiver;
import org.jetbrains.kotlin.types.JetType;
@@ -615,8 +615,8 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro
if (!kind.getIsConstructor() && callableScope != null && !info.getNewName().isEmpty()) {
Name newName = Name.identifier(info.getNewName());
Collection<? extends CallableDescriptor> conflicts = oldDescriptor instanceof FunctionDescriptor
? callableScope.getFunctions(newName, UsageLocation.NO_LOCATION)
: callableScope.getProperties(newName, UsageLocation.NO_LOCATION);
? callableScope.getFunctions(newName, LookupLocation.NO_LOCATION)
: callableScope.getProperties(newName, LookupLocation.NO_LOCATION);
for (CallableDescriptor conflict : conflicts) {
if (conflict == oldDescriptor) continue;
@@ -639,7 +639,7 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro
}
if (parametersScope != null) {
if (kind == JetMethodDescriptor.Kind.PRIMARY_CONSTRUCTOR && valOrVar != JetValVar.None) {
for (VariableDescriptor property : parametersScope.getProperties(Name.identifier(parameterName), UsageLocation.NO_LOCATION)) {
for (VariableDescriptor property : parametersScope.getProperties(Name.identifier(parameterName), LookupLocation.NO_LOCATION)) {
PsiElement propertyDeclaration = DescriptorToSourceUtils.descriptorToDeclaration(property);
if (propertyDeclaration != null && !(propertyDeclaration.getParent() instanceof JetParameterList)) {
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter;
import org.jetbrains.kotlin.resolve.scopes.JetScope;
import org.jetbrains.kotlin.resolve.scopes.UsageLocation;
import org.jetbrains.kotlin.resolve.scopes.LookupLocation;
import java.util.*;
@@ -249,7 +249,7 @@ public class ManglingUtils {
@NotNull
public static String getStableMangledNameForDescriptor(@NotNull ClassDescriptor descriptor, @NotNull String functionName) {
Collection<FunctionDescriptor> functions =
descriptor.getDefaultType().getMemberScope().getFunctions(Name.identifier(functionName), UsageLocation.NO_LOCATION);
descriptor.getDefaultType().getMemberScope().getFunctions(Name.identifier(functionName), LookupLocation.NO_LOCATION);
assert functions.size() == 1 : "Can't select a single function: " + functionName + " in " + descriptor;
return getSuggestedName((DeclarationDescriptor) functions.iterator().next());
}