Renamed methods in MemberScope from getSmth to getContributedSmth

This commit is contained in:
Stanislav Erokhin
2015-11-04 14:46:59 +03:00
parent 6f9d9759ce
commit 2c3f58eeb7
104 changed files with 289 additions and 288 deletions
@@ -50,7 +50,7 @@ public class CodegenUtil {
@NotNull ClassifierDescriptor returnedClassifier,
@NotNull ClassifierDescriptor... valueParameterClassifiers
) {
Collection<FunctionDescriptor> functions = owner.getDefaultType().getMemberScope().getFunctions(name, NoLookupLocation.FROM_BACKEND);
Collection<FunctionDescriptor> functions = owner.getDefaultType().getMemberScope().getContributedFunctions(name, NoLookupLocation.FROM_BACKEND);
for (FunctionDescriptor function : functions) {
if (!CallResolverUtilKt.isOrOverridesSynthesized(function)
&& function.getTypeParameters().isEmpty()
@@ -42,7 +42,7 @@ public object CodegenUtilKt {
): Map<CallableMemberDescriptor, CallableDescriptor> {
if (delegateExpressionType?.isDynamic() ?: false) return mapOf();
return descriptor.getDefaultType().getMemberScope().getDescriptors().asSequence()
return descriptor.getDefaultType().getMemberScope().getContributedDescriptors().asSequence()
.filterIsInstance<CallableMemberDescriptor>()
.filter { it.getKind() == CallableMemberDescriptor.Kind.DELEGATION }
.asIterable()
@@ -58,7 +58,7 @@ public object CodegenUtilKt {
val name = overriddenDescriptor.getName()
// this is the actual member of delegateExpressionType that we are delegating to
(scope.getFunctions(name, NoLookupLocation.FROM_BACKEND) + scope.getProperties(name, NoLookupLocation.FROM_BACKEND))
(scope.getContributedFunctions(name, NoLookupLocation.FROM_BACKEND) + scope.getContributedVariables(name, NoLookupLocation.FROM_BACKEND))
.first {
(listOf(it) + DescriptorUtils.getAllOverriddenDescriptors(it)).map { it.getOriginal() }.contains(overriddenDescriptor.getOriginal())
}
@@ -469,6 +469,6 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
? DescriptorUtilsKt.getBuiltIns(elementDescriptor).getFunction(arity)
: DescriptorUtilsKt.getBuiltIns(elementDescriptor).getExtensionFunction(arity);
MemberScope scope = elementClass.getDefaultType().getMemberScope();
return scope.getFunctions(OperatorNameConventions.INVOKE, NoLookupLocation.FROM_BACKEND).iterator().next();
return scope.getContributedFunctions(OperatorNameConventions.INVOKE, NoLookupLocation.FROM_BACKEND).iterator().next();
}
}
@@ -1086,7 +1086,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
Type asmLoopRangeType = asmType(loopRangeType);
Collection<PropertyDescriptor> incrementProp =
loopRangeType.getMemberScope().getProperties(Name.identifier("increment"), NoLookupLocation.FROM_BACKEND);
loopRangeType.getMemberScope().getContributedVariables(Name.identifier("increment"), NoLookupLocation.FROM_BACKEND);
assert incrementProp.size() == 1 : loopRangeType + " " + incrementProp.size();
incrementType = asmType(incrementProp.iterator().next().getType());
@@ -412,7 +412,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
private boolean isGenericToArrayPresent() {
Collection<FunctionDescriptor> functions =
descriptor.getDefaultType().getMemberScope().getFunctions(Name.identifier("toArray"), NoLookupLocation.FROM_BACKEND);
descriptor.getDefaultType().getMemberScope().getContributedFunctions(Name.identifier("toArray"), NoLookupLocation.FROM_BACKEND);
for (FunctionDescriptor function : functions) {
if (CallResolverUtilKt.isOrOverridesSynthesized(function)) {
continue;
@@ -794,7 +794,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
Type type = typeMapper.mapType(DescriptorUtilsKt.getBuiltIns(descriptor).getArrayType(INVARIANT, descriptor.getDefaultType()));
VariableDescriptor valuesProperty =
CollectionsKt.single(descriptor.getStaticScope().getProperties(ENUM_VALUES, NoLookupLocation.FROM_BACKEND), new Function1<VariableDescriptor, Boolean>() {
CollectionsKt.single(descriptor.getStaticScope().getContributedVariables(ENUM_VALUES, NoLookupLocation.FROM_BACKEND), new Function1<VariableDescriptor, Boolean>() {
@Override
public Boolean invoke(VariableDescriptor descriptor) {
return CodegenUtil.isEnumValuesProperty(descriptor);
@@ -814,7 +814,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
private void generateEnumValueOfMethod() {
FunctionDescriptor valueOfFunction =
CollectionsKt.single(descriptor.getStaticScope().getFunctions(ENUM_VALUE_OF, NoLookupLocation.FROM_BACKEND), new Function1<FunctionDescriptor, Boolean>() {
CollectionsKt.single(descriptor.getStaticScope().getContributedFunctions(ENUM_VALUE_OF, NoLookupLocation.FROM_BACKEND), new Function1<FunctionDescriptor, Boolean>() {
@Override
public Boolean invoke(FunctionDescriptor descriptor) {
return CodegenUtil.isEnumValueOfMethod(descriptor);
@@ -70,7 +70,7 @@ public class InterfaceImplBodyCodegen(
}
override fun generateSyntheticParts() {
for (memberDescriptor in descriptor.getDefaultType().getMemberScope().getDescriptors()) {
for (memberDescriptor in descriptor.getDefaultType().getMemberScope().getContributedDescriptors()) {
if (memberDescriptor !is CallableMemberDescriptor) continue
if (memberDescriptor.getKind().isReal()) continue
@@ -70,7 +70,7 @@ public class MultifileClassCodegen(
getDeserializedCallables(compiledPackageFragment)
private fun getDeserializedCallables(compiledPackageFragment: PackageFragmentDescriptor) =
compiledPackageFragment.getMemberScope().getDescriptors(DescriptorKindFilter.CALLABLES, MemberScope.ALL_NAME_FILTER).filterIsInstance<DeserializedCallableMemberDescriptor>()
compiledPackageFragment.getMemberScope().getContributedDescriptors(DescriptorKindFilter.CALLABLES, MemberScope.ALL_NAME_FILTER).filterIsInstance<DeserializedCallableMemberDescriptor>()
public val packageParts = PackageParts(facadeFqName.parent().asString())
@@ -147,7 +147,7 @@ public class SamWrapperCodegen {
(ClassDescriptor) erasedInterfaceFunction.getContainingDeclaration(), OwnerKind.IMPLEMENTATION, state), cv, state, parentCodegen);
FunctionDescriptor invokeFunction =
functionJetType.getMemberScope().getFunctions(OperatorNameConventions.INVOKE, NoLookupLocation.FROM_BACKEND).iterator().next().getOriginal();
functionJetType.getMemberScope().getContributedFunctions(OperatorNameConventions.INVOKE, NoLookupLocation.FROM_BACKEND).iterator().next().getOriginal();
StackValue functionField = StackValue.field(functionType, ownerType, FUNCTION_FIELD_NAME, false, StackValue.none());
codegen.genDelegate(erasedInterfaceFunction, invokeFunction, functionField);
@@ -158,9 +158,9 @@ class BuilderFactoryForDuplicateSignatureDiagnostics(
}
}
descriptor.defaultType.memberScope.getDescriptors().forEach(::processMember)
descriptor.defaultType.memberScope.getContributedDescriptors().forEach(::processMember)
descriptor.getParentJavaStaticClassScope()?.run {
getDescriptors(DescriptorKindFilter.FUNCTIONS)
getContributedDescriptors(DescriptorKindFilter.FUNCTIONS)
.filter {
it is FunctionDescriptor && Visibilities.isVisible(ReceiverValue.IRRELEVANT_RECEIVER, it, descriptor)
}
@@ -118,7 +118,7 @@ public class BuiltInsSerializer(private val dependOnOldBuiltIns: Boolean) {
// TODO: perform some kind of validation? At the moment not possible because DescriptorValidator is in compiler-tests
// DescriptorValidator.validate(packageView)
val classifierDescriptors = DescriptorSerializer.sort(packageView.memberScope.getDescriptors(DescriptorKindFilter.CLASSIFIERS))
val classifierDescriptors = DescriptorSerializer.sort(packageView.memberScope.getContributedDescriptors(DescriptorKindFilter.CLASSIFIERS))
val extension = BuiltInsSerializerExtension()
serializeClasses(classifierDescriptors, extension) {
@@ -160,7 +160,7 @@ public class BuiltInsSerializer(private val dependOnOldBuiltIns: Boolean) {
val classProto = DescriptorSerializer.createTopLevel(serializer).classProto(classDescriptor).build()
writeClass(classDescriptor, classProto)
serializeClasses(classDescriptor.unsubstitutedInnerClassesScope.getDescriptors(), serializer, writeClass)
serializeClasses(classDescriptor.unsubstitutedInnerClassesScope.getContributedDescriptors(), serializer, writeClass)
}
private fun serializeClasses(
@@ -38,7 +38,7 @@ public class BuiltInsSerializerExtension : SerializerExtension() {
override fun serializePackage(packageFragments: Collection<PackageFragmentDescriptor>, proto: ProtoBuf.Package.Builder) {
val classes = packageFragments.flatMap {
it.getMemberScope().getDescriptors(DescriptorKindFilter.CLASSIFIERS).filterIsInstance<ClassDescriptor>()
it.getMemberScope().getContributedDescriptors(DescriptorKindFilter.CLASSIFIERS).filterIsInstance<ClassDescriptor>()
}
for (descriptor in DescriptorSerializer.sort(classes)) {
@@ -127,7 +127,7 @@ public class CliLightClassGenerationSupport(project: Project) : LightClassGenera
override fun getSubPackages(fqn: FqName, scope: GlobalSearchScope): Collection<FqName> {
val packageView = module.getPackage(fqn)
val members = packageView.memberScope.getDescriptors(DescriptorKindFilter.PACKAGES, MemberScope.ALL_NAME_FILTER)
val members = packageView.memberScope.getContributedDescriptors(DescriptorKindFilter.PACKAGES, MemberScope.ALL_NAME_FILTER)
return ContainerUtil.mapNotNull(members, object : Function<DeclarationDescriptor, FqName> {
override fun `fun`(member: DeclarationDescriptor): FqName? {
if (member is PackageViewDescriptor) {
@@ -37,7 +37,7 @@ import java.util.*
public object SamConversionResolverImpl : SamConversionResolver {
override fun resolveSamConstructor(name: Name, scope: MemberScope, location: LookupLocation): SamConstructorDescriptor? {
val classifier = scope.getClassifier(name, location) as? LazyJavaClassDescriptor ?: return null
val classifier = scope.getContributedClassifier(name, location) as? LazyJavaClassDescriptor ?: return null
if (classifier.getFunctionTypeForSamInterface() == null) return null
return SingleAbstractMethodUtils.createSamConstructorFunction(scope.getContainingDeclaration(), classifier)
}
@@ -305,7 +305,7 @@ public class SignaturesPropagationData {
Name name = method.getName();
JvmMethodSignature autoSignature = SIGNATURE_MAPPER.mapToJvmMethodSignature(autoMethodDescriptor);
for (KotlinType supertype : containingClass.getTypeConstructor().getSupertypes()) {
Collection<FunctionDescriptor> superFunctionCandidates = supertype.getMemberScope().getFunctions(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS);
Collection<FunctionDescriptor> superFunctionCandidates = supertype.getMemberScope().getContributedFunctions(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS);
for (FunctionDescriptor candidate : superFunctionCandidates) {
JvmMethodSignature candidateSignature = SIGNATURE_MAPPER.mapToJvmMethodSignature(candidate);
if (KotlinToJvmSignatureMapperKt.erasedSignaturesEqualIgnoringReturnTypes(autoSignature, candidateSignature)) {
@@ -51,7 +51,7 @@ private val DEFAULT_IMPORTS_FOR_JVM = ArrayList<ImportPath>().apply {
add(ImportPath("kotlin.io.*"))
fun addAllClassifiersFromScope(scope: MemberScope) {
for (descriptor in scope.getDescriptors(DescriptorKindFilter.CLASSIFIERS, MemberScope.ALL_NAME_FILTER)) {
for (descriptor in scope.getContributedDescriptors(DescriptorKindFilter.CLASSIFIERS, MemberScope.ALL_NAME_FILTER)) {
add(ImportPath(DescriptorUtils.getFqNameSafe(descriptor), false))
}
}
@@ -111,14 +111,14 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager, private val l
val possibleGetMethodNames = possibleGetMethodNames(name)
val getMethod = possibleGetMethodNames
.flatMap { memberScope.getFunctions(it, NoLookupLocation.FROM_SYNTHETIC_SCOPE) }
.flatMap { memberScope.getContributedFunctions(it, NoLookupLocation.FROM_SYNTHETIC_SCOPE) }
.singleOrNull {
isGoodGetMethod(it) && it.hasJavaOriginInHierarchy()
} ?: return result(null, possibleGetMethodNames)
val setMethodName = setMethodName(getMethod.name)
val setMethod = memberScope.getFunctions(setMethodName, NoLookupLocation.FROM_SYNTHETIC_SCOPE)
val setMethod = memberScope.getContributedFunctions(setMethodName, NoLookupLocation.FROM_SYNTHETIC_SCOPE)
.singleOrNull { isGoodSetMethod(it, getMethod) }
val propertyType = getMethod.returnType!!
@@ -203,7 +203,7 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager, private val l
val classifier = type.declarationDescriptor
if (classifier is ClassDescriptor) {
for (descriptor in classifier.getUnsubstitutedMemberScope().getDescriptors(DescriptorKindFilter.FUNCTIONS)) {
for (descriptor in classifier.getUnsubstitutedMemberScope().getContributedDescriptors(DescriptorKindFilter.FUNCTIONS)) {
if (descriptor is FunctionDescriptor) {
val propertyName = SyntheticJavaPropertyDescriptor.propertyNameByGetMethodName(descriptor.getName()) ?: continue
addIfNotNull(syntheticPropertyInClass(Pair(classifier, propertyName)).descriptor)
@@ -57,7 +57,7 @@ class SamAdapterFunctionsScope(storageManager: StorageManager) : BaseImportingSc
override fun getContributedSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
var result: SmartList<FunctionDescriptor>? = null
for (type in receiverTypes) {
for (function in type.memberScope.getFunctions(name, location)) {
for (function in type.memberScope.getContributedFunctions(name, location)) {
val extension = extensionForFunction(function.original)
if (extension != null) {
if (result == null) {
@@ -76,7 +76,7 @@ class SamAdapterFunctionsScope(storageManager: StorageManager) : BaseImportingSc
override fun getContributedSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>): Collection<FunctionDescriptor> {
return receiverTypes.flatMapTo(LinkedHashSet<FunctionDescriptor>()) { type ->
type.memberScope.getDescriptors(DescriptorKindFilter.FUNCTIONS)
type.memberScope.getContributedDescriptors(DescriptorKindFilter.FUNCTIONS)
.filterIsInstance<FunctionDescriptor>()
.map { extensionForFunction(it.original) }
.filterNotNull()
@@ -37,16 +37,16 @@ class AllUnderImportsScope(descriptor: DeclarationDescriptor) : BaseImportingSco
}
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean)
= scopes.flatMap { it.getDescriptors(kindFilter, nameFilter) }
= scopes.flatMap { it.getContributedDescriptors(kindFilter, nameFilter) }
override fun getContributedClassifier(name: Name, location: LookupLocation)
= scopes.asSequence().map { it.getClassifier(name, location) }.filterNotNull().singleOrNull()
= scopes.asSequence().map { it.getContributedClassifier(name, location) }.filterNotNull().singleOrNull()
override fun getContributedVariables(name: Name, location: LookupLocation)
= scopes.flatMap { it.getProperties(name, location) }
= scopes.flatMap { it.getContributedVariables(name, location) }
override fun getContributedFunctions(name: Name, location: LookupLocation)
= scopes.flatMap { it.getFunctions(name, location) }
= scopes.flatMap { it.getContributedFunctions(name, location) }
override fun printStructure(p: Printer) {
p.println(javaClass.simpleName)
@@ -53,7 +53,7 @@ public class DeclarationResolver(
public fun checkRedeclarations(c: TopDownAnalysisContext) {
for (classDescriptor in c.getDeclaredClasses().values()) {
val descriptorMap = HashMultimap.create<Name, DeclarationDescriptor>()
for (desc in classDescriptor.getUnsubstitutedMemberScope().getDescriptors()) {
for (desc in classDescriptor.getUnsubstitutedMemberScope().getContributedDescriptors()) {
if (desc is ClassDescriptor || desc is PropertyDescriptor) {
descriptorMap.put(desc.getName(), desc)
}
@@ -28,10 +28,10 @@ class NoSubpackagesInPackageScope(packageDescriptor: PackageViewDescriptor) : Ab
override fun getPackage(name: Name): PackageViewDescriptor? = null
override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> {
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> {
val modifiedFilter = kindFilter.withoutKinds(DescriptorKindFilter.PACKAGES_MASK)
if (modifiedFilter.kindMask == 0) return listOf()
return workerScope.getDescriptors(modifiedFilter, nameFilter).filter { it !is PackageViewDescriptor }
return workerScope.getContributedDescriptors(modifiedFilter, nameFilter).filter { it !is PackageViewDescriptor }
}
}
@@ -88,12 +88,12 @@ object OverloadUtil {
collectModulePackageMembersWithSameName(packageMembersByName, c.functions.values) {
scope, name ->
scope.getFunctions(name, NoLookupLocation.WHEN_CHECK_REDECLARATIONS)
scope.getContributedFunctions(name, NoLookupLocation.WHEN_CHECK_REDECLARATIONS)
}
collectModulePackageMembersWithSameName(packageMembersByName, c.properties.values) {
scope, name ->
scope.getProperties(name, NoLookupLocation.WHEN_CHECK_REDECLARATIONS).filterIsInstance<CallableMemberDescriptor>()
scope.getContributedVariables(name, NoLookupLocation.WHEN_CHECK_REDECLARATIONS).filterIsInstance<CallableMemberDescriptor>()
}
// TODO handle constructor redeclarations in modules. See also: https://youtrack.jetbrains.com/issue/KT-3632
@@ -794,9 +794,9 @@ public class OverrideResolver {
) {
for (KotlinType supertype : declaringClass.getTypeConstructor().getSupertypes()) {
Set<CallableMemberDescriptor> all = Sets.newLinkedHashSet();
all.addAll(supertype.getMemberScope().getFunctions(declared.getName(), NoLookupLocation.WHEN_CHECK_OVERRIDES));
all.addAll(supertype.getMemberScope().getContributedFunctions(declared.getName(), NoLookupLocation.WHEN_CHECK_OVERRIDES));
//noinspection unchecked
all.addAll((Collection) supertype.getMemberScope().getProperties(declared.getName(), NoLookupLocation.WHEN_CHECK_OVERRIDES));
all.addAll((Collection) supertype.getMemberScope().getContributedVariables(declared.getName(), NoLookupLocation.WHEN_CHECK_OVERRIDES));
for (CallableMemberDescriptor fromSuper : all) {
if (OverridingUtil.DEFAULT.isOverridableBy(fromSuper, declared).getResult() == OVERRIDABLE) {
if (Visibilities.isVisible(ReceiverValue.IRRELEVANT_RECEIVER, fromSuper, declared)) {
@@ -80,8 +80,8 @@ public class QualifiedExpressionResolver(val symbolUsageValidator: SymbolUsageVa
val lastPart = qualifierPartList.last()
val classifier = when (qualifier) {
is PackageViewDescriptor -> qualifier.memberScope.getClassifier(lastPart.name, lastPart.location)
is ClassDescriptor -> qualifier.unsubstitutedInnerClassesScope.getClassifier(lastPart.name, lastPart.location)
is PackageViewDescriptor -> qualifier.memberScope.getContributedClassifier(lastPart.name, lastPart.location)
is ClassDescriptor -> qualifier.unsubstitutedInnerClassesScope.getContributedClassifier(lastPart.name, lastPart.location)
else -> null
}
storeResult(trace, lastPart.expression, classifier, scope.ownerDescriptor, inImport = false, isQualifier = false)
@@ -183,24 +183,24 @@ public class QualifiedExpressionResolver(val symbolUsageValidator: SymbolUsageVa
when (packageOrClassDescriptor) {
is PackageViewDescriptor -> {
val packageScope = packageOrClassDescriptor.memberScope
descriptors.addIfNotNull(packageScope.getClassifier(lastName, location))
descriptors.addAll(packageScope.getProperties(lastName, location))
descriptors.addAll(packageScope.getFunctions(lastName, location))
descriptors.addIfNotNull(packageScope.getContributedClassifier(lastName, location))
descriptors.addAll(packageScope.getContributedVariables(lastName, location))
descriptors.addAll(packageScope.getContributedFunctions(lastName, location))
}
is ClassDescriptor -> {
descriptors.addIfNotNull(
packageOrClassDescriptor.unsubstitutedInnerClassesScope.getClassifier(lastName, location)
packageOrClassDescriptor.unsubstitutedInnerClassesScope.getContributedClassifier(lastName, location)
)
val staticClassScope = packageOrClassDescriptor.staticScope
descriptors.addAll(staticClassScope.getFunctions(lastName, location))
descriptors.addAll(staticClassScope.getProperties(lastName, location))
descriptors.addAll(staticClassScope.getContributedFunctions(lastName, location))
descriptors.addAll(staticClassScope.getContributedVariables(lastName, location))
if (packageOrClassDescriptor.kind == ClassKind.OBJECT) {
descriptors.addAll(packageOrClassDescriptor.unsubstitutedMemberScope.getFunctions(lastName, location).map {
descriptors.addAll(packageOrClassDescriptor.unsubstitutedMemberScope.getContributedFunctions(lastName, location).map {
FunctionImportedFromObject(it)
})
val properties = packageOrClassDescriptor.unsubstitutedMemberScope.getProperties(lastName, location)
val properties = packageOrClassDescriptor.unsubstitutedMemberScope.getContributedVariables(lastName, location)
.filterIsInstance<PropertyDescriptor>().map { PropertyImportedFromObject(it) }
descriptors.addAll(properties)
}
@@ -230,8 +230,8 @@ public class QualifiedExpressionResolver(val symbolUsageValidator: SymbolUsageVa
is ClassDescriptor -> {
val memberScope = packageOrClassDescriptor.unsubstitutedMemberScope
descriptors.addAll(memberScope.getFunctions(lastName, lastPart.location))
descriptors.addAll(memberScope.getProperties(lastName, lastPart.location))
descriptors.addAll(memberScope.getContributedFunctions(lastName, lastPart.location))
descriptors.addAll(memberScope.getContributedVariables(lastName, lastPart.location))
if (descriptors.isNotEmpty()) {
trace.report(Errors.CANNOT_BE_IMPORTED.on(lastPart.expression, lastName))
}
@@ -304,7 +304,7 @@ public class QualifiedExpressionResolver(val symbolUsageValidator: SymbolUsageVa
val nextDescriptor = when (descriptor) {
// TODO: support inner classes which captured type parameter from outer class
is ClassDescriptor ->
descriptor.unsubstitutedInnerClassesScope.getClassifier(qualifierPart.name, qualifierPart.location)
descriptor.unsubstitutedInnerClassesScope.getContributedClassifier(qualifierPart.name, qualifierPart.location)
is PackageViewDescriptor -> {
val packageView = if (qualifierPart.typeArguments == null) {
moduleDescriptor.getPackage(descriptor.fqName.child(qualifierPart.name))
@@ -314,7 +314,7 @@ public class QualifiedExpressionResolver(val symbolUsageValidator: SymbolUsageVa
if (packageView != null && !packageView.isEmpty()) {
packageView
} else {
descriptor.memberScope.getClassifier(qualifierPart.name, qualifierPart.location)
descriptor.memberScope.getContributedClassifier(qualifierPart.name, qualifierPart.location)
}
}
else -> null
@@ -105,7 +105,7 @@ private object FunctionCollector : CallableDescriptorCollector<FunctionDescripto
override fun getMembersByName(receiver: KotlinType, name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
val receiverScope = receiver.memberScope
val members = receiverScope.getFunctions(name, location)
val members = receiverScope.getContributedFunctions(name, location)
val constructors = getConstructors(receiverScope.memberScopeAsImportingScope(), name, location, { !isStaticNestedClass(it) })
if (name == OperatorNameConventions.INVOKE && KotlinBuiltIns.isExtensionFunctionType(receiver)) {
@@ -194,7 +194,7 @@ private object VariableCollector : CallableDescriptorCollector<VariableDescripto
override fun getMembersByName(receiver: KotlinType, name: Name, location: LookupLocation): Collection<VariableDescriptor> {
val memberScope = receiver.memberScope
val properties = memberScope.getProperties(name, location)
val properties = memberScope.getContributedVariables(name, location)
val fakeDescriptor = getFakeDescriptorForObject(memberScope.memberScopeAsImportingScope(), name, location)
return if (fakeDescriptor != null) properties + fakeDescriptor else properties
}
@@ -50,7 +50,7 @@ class DynamicCallableDescriptors(private val builtIns: KotlinBuiltIns) {
p.println(javaClass.getSimpleName(), ": dynamic candidates for " + call)
}
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
override fun getContributedFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
if (isAugmentedAssignmentConvention(name)) return listOf()
if (call.getCallType() == Call.CallType.INVOKE
&& call.getValueArgumentList() == null && call.getFunctionLiteralArguments().isEmpty()) {
@@ -78,7 +78,7 @@ class DynamicCallableDescriptors(private val builtIns: KotlinBuiltIns) {
return false
}
override fun getProperties(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
override fun getContributedVariables(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
return if (call.getValueArgumentList() == null && call.getValueArguments().isEmpty()) {
listOf(createDynamicProperty(owner, name, call))
}
@@ -72,7 +72,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 = scope.getClassifier(classOrObject.getNameAsSafeName(), location);
ClassifierDescriptor scopeDescriptor = scope.getContributedClassifier(classOrObject.getNameAsSafeName(), location);
DeclarationDescriptor descriptor = getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, classOrObject);
if (descriptor == null) {
@@ -148,7 +148,7 @@ public class LazyDeclarationResolver {
public DeclarationDescriptor visitNamedFunction(@NotNull KtNamedFunction function, Void data) {
LookupLocation location = lookupLocationFor(function, function.isTopLevel());
MemberScope scopeForDeclaration = getMemberScopeDeclaredIn(function, location);
scopeForDeclaration.getFunctions(function.getNameAsSafeName(), location);
scopeForDeclaration.getContributedFunctions(function.getNameAsSafeName(), location);
return getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, function);
}
@@ -160,7 +160,7 @@ public class LazyDeclarationResolver {
// This is a primary constructor parameter
ClassDescriptor classDescriptor = getClassDescriptor(jetClass, lookupLocationFor(jetClass, false));
if (parameter.hasValOrVar()) {
classDescriptor.getDefaultType().getMemberScope().getProperties(parameter.getNameAsSafeName(), lookupLocationFor(parameter, false));
classDescriptor.getDefaultType().getMemberScope().getContributedVariables(parameter.getNameAsSafeName(), lookupLocationFor(parameter, false));
return getBindingContext().get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, parameter);
}
else {
@@ -204,7 +204,7 @@ public class LazyDeclarationResolver {
public DeclarationDescriptor visitProperty(@NotNull KtProperty property, Void data) {
LookupLocation location = lookupLocationFor(property, property.isTopLevel());
MemberScope scopeForDeclaration = getMemberScopeDeclaredIn(property, location);
scopeForDeclaration.getProperties(property.getNameAsSafeName(), location);
scopeForDeclaration.getContributedVariables(property.getNameAsSafeName(), location);
return getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, property);
}
@@ -288,7 +288,7 @@ public class ResolveSession implements KotlinCodeAnalyzer, LazyClassContext {
public ClassDescriptor getClassDescriptorForScript(@NotNull KtScript script) {
MemberScope memberScope = lazyDeclarationResolver.getMemberScopeDeclaredIn(script, NoLookupLocation.FOR_SCRIPT);
FqName fqName = ScriptNameUtil.classNameForScript(script);
ClassifierDescriptor classifier = memberScope.getClassifier(fqName.shortName(), NoLookupLocation.FOR_SCRIPT);
ClassifierDescriptor classifier = memberScope.getContributedClassifier(fqName.shortName(), NoLookupLocation.FOR_SCRIPT);
assert classifier != null : "No descriptor for " + fqName + " in file " + script.getContainingFile();
return (ClassDescriptor) classifier;
}
@@ -81,7 +81,7 @@ public class ResolveSessionUtils {
MemberScope scope = outerScope;
for (Name name : path.pathSegments()) {
ClassifierDescriptor classifier = scope.getClassifier(name, NoLookupLocation.WHEN_FIND_BY_FQNAME);
ClassifierDescriptor classifier = scope.getContributedClassifier(name, NoLookupLocation.WHEN_FIND_BY_FQNAME);
if (!(classifier instanceof ClassDescriptor)) return null;
scope = ((ClassDescriptor) classifier).getUnsubstitutedInnerClassesScope();
}
@@ -61,12 +61,12 @@ protected constructor(
override fun getContainingDeclaration() = thisDescriptor
override fun getClassifier(name: Name, location: LookupLocation): ClassDescriptor? {
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassDescriptor? {
recordLookup(name, location)
return classDescriptors(name).firstOrNull()
}
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
override fun getContributedFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
recordLookup(name, location)
return functionDescriptors(name)
}
@@ -94,7 +94,7 @@ protected constructor(
protected abstract fun getNonDeclaredFunctions(name: Name, result: MutableSet<FunctionDescriptor>)
override fun getProperties(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
override fun getContributedVariables(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
recordLookup(name, location)
return propertyDescriptors(name)
}
@@ -138,19 +138,19 @@ protected constructor(
else if (declaration is KtFunction) {
val name = declaration.nameAsSafeName
if (nameFilter(name)) {
result.addAll(getFunctions(name, location))
result.addAll(getContributedFunctions(name, location))
}
}
else if (declaration is KtProperty) {
val name = declaration.nameAsSafeName
if (nameFilter(name)) {
result.addAll(getProperties(name, location))
result.addAll(getContributedVariables(name, location))
}
}
else if (declaration is KtParameter) {
val name = declaration.nameAsSafeName
if (nameFilter(name)) {
result.addAll(getProperties(name, location))
result.addAll(getContributedVariables(name, location))
}
}
else if (declaration is KtScript) {
@@ -361,7 +361,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
}
Name name = ((JetClassOrObjectInfo) companionObjectInfo).getName();
assert name != null;
getUnsubstitutedMemberScope().getClassifier(name, NoLookupLocation.WHEN_GET_COMPANION_OBJECT);
getUnsubstitutedMemberScope().getContributedClassifier(name, NoLookupLocation.WHEN_GET_COMPANION_OBJECT);
ClassDescriptor companionObjectDescriptor = c.getTrace().get(BindingContext.CLASS, companionObject);
if (companionObjectDescriptor instanceof LazyClassDescriptor) {
assert DescriptorUtils.isCompanionObject(companionObjectDescriptor) : "Not a companion object: " + companionObjectDescriptor;
@@ -57,8 +57,8 @@ public open class LazyClassMemberScope(
computeExtraDescriptors(NoLookupLocation.FOR_ALREADY_TRACKED)
}
override fun getDescriptors(kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> {
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> {
val result = LinkedHashSet(descriptorsFromDeclaredElements())
result.addAll(extraDescriptors())
return result
@@ -67,12 +67,12 @@ public open class LazyClassMemberScope(
protected open fun computeExtraDescriptors(location: LookupLocation): Collection<DeclarationDescriptor> {
val result = ArrayList<DeclarationDescriptor>()
for (supertype in thisDescriptor.typeConstructor.supertypes) {
for (descriptor in supertype.memberScope.getDescriptors()) {
for (descriptor in supertype.memberScope.getContributedDescriptors()) {
if (descriptor is FunctionDescriptor) {
result.addAll(getFunctions(descriptor.name, location))
result.addAll(getContributedFunctions(descriptor.name, location))
}
else if (descriptor is PropertyDescriptor) {
result.addAll(getProperties(descriptor.name, location))
result.addAll(getContributedVariables(descriptor.name, location))
}
// Nothing else is inherited
}
@@ -115,9 +115,9 @@ public open class LazyClassMemberScope(
OverrideResolver.resolveUnknownVisibilities(result, trace)
}
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
override fun getContributedFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
// TODO: this should be handled by lazy function descriptors
val functions = super.getFunctions(name, location)
val functions = super.getContributedFunctions(name, location)
resolveUnknownVisibilitiesForMembers(functions)
return functions
}
@@ -127,7 +127,7 @@ public open class LazyClassMemberScope(
val fromSupertypes = Lists.newArrayList<FunctionDescriptor>()
for (supertype in thisDescriptor.typeConstructor.supertypes) {
fromSupertypes.addAll(supertype.memberScope.getFunctions(name, location))
fromSupertypes.addAll(supertype.memberScope.getContributedFunctions(name, location))
}
result.addAll(generateDelegatingDescriptors(name, EXTRACT_FUNCTIONS, result))
generateDataClassMethods(result, name, location)
@@ -149,7 +149,7 @@ public open class LazyClassMemberScope(
if (parameter.getType().isError()) continue
if (!primaryConstructorParameters.get(parameter.index).hasValOrVar()) continue
val properties = getProperties(parameter.name, location)
val properties = getContributedVariables(parameter.name, location)
if (properties.isEmpty()) continue
val property = properties.iterator().next()
@@ -167,7 +167,7 @@ public open class LazyClassMemberScope(
if (name == DescriptorResolver.COPY_METHOD_NAME) {
for (parameter in constructor.getValueParameters()) {
// force properties resolution to fill BindingContext.VALUE_PARAMETER_AS_PROPERTY slice
getProperties(parameter.name, location)
getContributedVariables(parameter.name, location)
}
val copyFunctionDescriptor = DescriptorResolver.createCopyFunctionDescriptor(constructor.getValueParameters(), thisDescriptor, trace)
@@ -175,9 +175,9 @@ public open class LazyClassMemberScope(
}
}
override fun getProperties(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
override fun getContributedVariables(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
// TODO: this should be handled by lazy property descriptors
val properties = super.getProperties(name, location)
val properties = super.getContributedVariables(name, location)
resolveUnknownVisibilitiesForMembers(properties as Collection<CallableMemberDescriptor>)
return properties
}
@@ -197,7 +197,7 @@ public open class LazyClassMemberScope(
// Members from supertypes
val fromSupertypes = ArrayList<PropertyDescriptor>()
for (supertype in thisDescriptor.typeConstructor.supertypes) {
fromSupertypes.addAll(supertype.memberScope.getProperties(name, NoLookupLocation.FOR_ALREADY_TRACKED))
fromSupertypes.addAll(supertype.memberScope.getContributedVariables(name, NoLookupLocation.FOR_ALREADY_TRACKED))
}
result.addAll(generateDelegatingDescriptors(name, EXTRACT_PROPERTIES, result))
generateFakeOverrides(name, fromSupertypes, result, javaClass<PropertyDescriptor>())
@@ -249,14 +249,14 @@ public open class LazyClassMemberScope(
var n = 1
while (true) {
val componentName = createComponentName(n)
val functions = getFunctions(componentName, location)
val functions = getContributedFunctions(componentName, location)
if (functions.isEmpty()) break
result.addAll(functions)
n++
}
result.addAll(getFunctions(Name.identifier("copy"), location))
result.addAll(getContributedFunctions(Name.identifier("copy"), location))
}
override fun getPackage(name: Name): PackageViewDescriptor? = null
@@ -315,13 +315,13 @@ public open class LazyClassMemberScope(
companion object {
private val EXTRACT_FUNCTIONS: MemberExtractor<FunctionDescriptor> = object : MemberExtractor<FunctionDescriptor> {
override fun extract(extractFrom: KotlinType, name: Name): Collection<FunctionDescriptor> {
return extractFrom.memberScope.getFunctions(name, NoLookupLocation.FOR_ALREADY_TRACKED)
return extractFrom.memberScope.getContributedFunctions(name, NoLookupLocation.FOR_ALREADY_TRACKED)
}
}
private val EXTRACT_PROPERTIES: MemberExtractor<PropertyDescriptor> = object : MemberExtractor<PropertyDescriptor> {
override fun extract(extractFrom: KotlinType, name: Name): Collection<PropertyDescriptor> {
return extractFrom.memberScope.getProperties(name, NoLookupLocation.FOR_ALREADY_TRACKED)
return extractFrom.memberScope.getContributedVariables(name, NoLookupLocation.FOR_ALREADY_TRACKED)
}
}
}
@@ -30,7 +30,7 @@ public class LazyPackageMemberScope(
thisPackage: PackageFragmentDescriptor)
: AbstractLazyMemberScope<PackageFragmentDescriptor, PackageMemberDeclarationProvider>(resolveSession, declarationProvider, thisPackage, resolveSession.trace) {
override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> {
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> {
return computeDescriptorsFromDeclaredElements(kindFilter, nameFilter, NoLookupLocation.WHEN_GET_ALL_DESCRIPTORS)
}
@@ -44,11 +44,11 @@ public class LazyScriptClassMemberScope protected constructor(
override fun computeExtraDescriptors(location: LookupLocation): Collection<DeclarationDescriptor> {
return (super.computeExtraDescriptors(location)
+ getProperties(Name.identifier(ScriptDescriptor.LAST_EXPRESSION_VALUE_FIELD_NAME), location)
+ getContributedVariables(Name.identifier(ScriptDescriptor.LAST_EXPRESSION_VALUE_FIELD_NAME), location)
+ getPropertiesForScriptParameters()).toReadOnlyList()
}
private fun getPropertiesForScriptParameters() = getPrimaryConstructor()!!.valueParameters.flatMap { getProperties(it.name, NoLookupLocation.FOR_SCRIPT) }
private fun getPropertiesForScriptParameters() = getPrimaryConstructor()!!.valueParameters.flatMap { getContributedVariables(it.name, NoLookupLocation.FOR_SCRIPT) }
override fun getNonDeclaredProperties(name: Name, result: MutableSet<PropertyDescriptor>) {
super.getNonDeclaredProperties(name, result)
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.utils.Printer
public class FilteringScope(private val workerScope: MemberScope, private val predicate: (DeclarationDescriptor) -> Boolean) : MemberScope {
override fun getFunctions(name: Name, location: LookupLocation) = workerScope.getFunctions(name, location).filter(predicate)
override fun getContributedFunctions(name: Name, location: LookupLocation) = workerScope.getContributedFunctions(name, location).filter(predicate)
override fun getContainingDeclaration() = workerScope.getContainingDeclaration()
@@ -32,12 +32,12 @@ public class FilteringScope(private val workerScope: MemberScope, private val pr
override fun getPackage(name: Name) = filterDescriptor(workerScope.getPackage(name))
override fun getClassifier(name: Name, location: LookupLocation) = filterDescriptor(workerScope.getClassifier(name, location))
override fun getContributedClassifier(name: Name, location: LookupLocation) = filterDescriptor(workerScope.getContributedClassifier(name, location))
override fun getProperties(name: Name, location: LookupLocation) = workerScope.getProperties(name, location).filter(predicate)
override fun getContributedVariables(name: Name, location: LookupLocation) = workerScope.getContributedVariables(name, location).filter(predicate)
override fun getDescriptors(kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean) = workerScope.getDescriptors(kindFilter, nameFilter).filter(predicate)
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean) = workerScope.getContributedDescriptors(kindFilter, nameFilter).filter(predicate)
override fun printScopeStructure(p: Printer) {
p.println(javaClass.getSimpleName(), " {")
@@ -39,13 +39,13 @@ public class LexicalChainedScope @JvmOverloads constructor(
private val scopeChain = memberScopes.clone()
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean)
= getFromAllScopes(scopeChain) { it.getDescriptors() }
= getFromAllScopes(scopeChain) { it.getContributedDescriptors() }
override fun getContributedClassifier(name: Name, location: LookupLocation) = getFirstMatch(scopeChain) { it.getClassifier(name, location) }
override fun getContributedClassifier(name: Name, location: LookupLocation) = getFirstMatch(scopeChain) { it.getContributedClassifier(name, location) }
override fun getContributedVariables(name: Name, location: LookupLocation) = getFromAllScopes(scopeChain) { it.getProperties(name, location) }
override fun getContributedVariables(name: Name, location: LookupLocation) = getFromAllScopes(scopeChain) { it.getContributedVariables(name, location) }
override fun getContributedFunctions(name: Name, location: LookupLocation) = getFromAllScopes(scopeChain) { it.getFunctions(name, location) }
override fun getContributedFunctions(name: Name, location: LookupLocation) = getFromAllScopes(scopeChain) { it.getContributedFunctions(name, location) }
override fun toString(): String = debugName
@@ -134,13 +134,13 @@ private class MemberScopeToImportingScopeAdapter(override val parent: ImportingS
= emptyList<FunctionDescriptor>()
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean)
= memberScope.getDescriptors(kindFilter, nameFilter)
= memberScope.getContributedDescriptors(kindFilter, nameFilter)
override fun getContributedClassifier(name: Name, location: LookupLocation) = memberScope.getClassifier(name, location)
override fun getContributedClassifier(name: Name, location: LookupLocation) = memberScope.getContributedClassifier(name, location)
override fun getContributedVariables(name: Name, location: LookupLocation) = memberScope.getProperties(name, location)
override fun getContributedVariables(name: Name, location: LookupLocation) = memberScope.getContributedVariables(name, location)
override fun getContributedFunctions(name: Name, location: LookupLocation) = memberScope.getFunctions(name, location)
override fun getContributedFunctions(name: Name, location: LookupLocation) = memberScope.getContributedFunctions(name, location)
override fun equals(other: Any?) = other is MemberScopeToImportingScopeAdapter && other.memberScope == memberScope
@@ -135,10 +135,10 @@ private inline fun resolveSupertypesByMembers(
}
private fun getFunctionMembers(type: KotlinType, name: Name, location: LookupLocation): Collection<MemberDescriptor> =
type.memberScope.getFunctions(name, location)
type.memberScope.getContributedFunctions(name, location)
private fun getPropertyMembers(type: KotlinType, name: Name, location: LookupLocation): Collection<MemberDescriptor> =
type.memberScope.getProperties(name, location).filterIsInstanceTo(SmartList<MemberDescriptor>())
type.memberScope.getContributedVariables(name, location).filterIsInstanceTo(SmartList<MemberDescriptor>())
private fun isConcreteMember(supertype: KotlinType, memberDescriptor: MemberDescriptor): Boolean {
// "Concrete member" is a function or a property that is not abstract,
@@ -37,7 +37,7 @@ class DeserializedScopeValidationVisitor : ValidationVisitor() {
private fun validateDeserializedScope(scope: MemberScope) {
val isPackageViewScope = scope.safeGetContainingDeclaration() is PackageViewDescriptor
if (scope is DeserializedMemberScope || isPackageViewScope) {
val relevantDescriptors = scope.getDescriptors().filter { member ->
val relevantDescriptors = scope.getContributedDescriptors().filter { member ->
member is CallableMemberDescriptor && member.getKind().isReal() || (!isPackageViewScope && member is ClassDescriptor)
}
checkSorted(relevantDescriptors, scope.getContainingDeclaration())
@@ -118,12 +118,12 @@ public class MultiModuleJavaAnalysisCustomTest : UsefulTestCase() {
private fun checkClassInPackage(moduleDescriptor: ModuleDescriptor, packageName: String, className: String) {
val kotlinPackage = moduleDescriptor.getPackage(FqName(packageName))
val kotlinClassName = Name.identifier(className)
val kotlinClass = kotlinPackage.memberScope.getClassifier(kotlinClassName, NoLookupLocation.FROM_TEST) as ClassDescriptor
val kotlinClass = kotlinPackage.memberScope.getContributedClassifier(kotlinClassName, NoLookupLocation.FROM_TEST) as ClassDescriptor
checkClass(kotlinClass)
}
private fun checkClass(classDescriptor: ClassDescriptor) {
classDescriptor.getDefaultType().getMemberScope().getDescriptors().filterIsInstance<CallableDescriptor>().forEach {
classDescriptor.getDefaultType().getMemberScope().getContributedDescriptors().filterIsInstance<CallableDescriptor>().forEach {
checkCallable(it)
}
@@ -228,9 +228,9 @@ public abstract class AbstractJvmRuntimeDescriptorLoaderTest : TestCaseWithTmpdi
}
}
override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? = classifierMap[name]
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? = classifierMap[name]
override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> = classifierMap.values
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> = classifierMap.values
override fun printScopeStructure(p: Printer) {
p.println("runtime descriptor loader test")
@@ -169,7 +169,7 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends KotlinLite
protected static FunctionDescriptor getFunctionDescriptor(@NotNull PackageFragmentDescriptor packageView, @NotNull String name) {
Name functionName = Name.identifier(name);
MemberScope memberScope = packageView.getMemberScope();
Collection<FunctionDescriptor> functions = memberScope.getFunctions(functionName, NoLookupLocation.FROM_TEST);
Collection<FunctionDescriptor> functions = memberScope.getContributedFunctions(functionName, NoLookupLocation.FROM_TEST);
assert functions.size() == 1 : "Failed to find function " + functionName + " in class" + "." + packageView.getName();
return functions.iterator().next();
}
@@ -178,7 +178,7 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends KotlinLite
private static FunctionDescriptor getFunctionDescriptor(@NotNull ClassDescriptor classDescriptor, @NotNull String name) {
Name functionName = Name.identifier(name);
MemberScope memberScope = classDescriptor.getMemberScope(Collections.<TypeProjection>emptyList());
Collection<FunctionDescriptor> functions = memberScope.getFunctions(functionName, NoLookupLocation.FROM_TEST);
Collection<FunctionDescriptor> functions = memberScope.getContributedFunctions(functionName, NoLookupLocation.FROM_TEST);
assert functions.size() == 1 : "Failed to find function " + functionName + " in class" + "." + classDescriptor.getName();
return functions.iterator().next();
}
@@ -187,13 +187,13 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends KotlinLite
protected static PropertyDescriptor getPropertyDescriptor(@NotNull PackageFragmentDescriptor packageView, @NotNull String name, boolean failOnMissing) {
Name propertyName = Name.identifier(name);
MemberScope memberScope = packageView.getMemberScope();
Collection<PropertyDescriptor> properties = memberScope.getProperties(propertyName, NoLookupLocation.FROM_TEST);
Collection<PropertyDescriptor> properties = memberScope.getContributedVariables(propertyName, NoLookupLocation.FROM_TEST);
if (properties.isEmpty()) {
for (DeclarationDescriptor descriptor : DescriptorUtils.getAllDescriptors(memberScope)) {
if (descriptor instanceof ClassDescriptor) {
Collection<PropertyDescriptor> classProperties =
((ClassDescriptor) descriptor).getMemberScope(Collections.<TypeProjection>emptyList())
.getProperties(propertyName, NoLookupLocation.FROM_TEST);
.getContributedVariables(propertyName, NoLookupLocation.FROM_TEST);
if (!classProperties.isEmpty()) {
properties = classProperties;
break;
@@ -214,7 +214,7 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends KotlinLite
private static PropertyDescriptor getPropertyDescriptor(@NotNull ClassDescriptor classDescriptor, @NotNull String name) {
Name propertyName = Name.identifier(name);
MemberScope memberScope = classDescriptor.getMemberScope(Collections.<TypeProjection>emptyList());
Collection<PropertyDescriptor> properties = memberScope.getProperties(propertyName, NoLookupLocation.FROM_TEST);
Collection<PropertyDescriptor> properties = memberScope.getContributedVariables(propertyName, NoLookupLocation.FROM_TEST);
assert properties.size() == 1 : "Failed to find property " + propertyName + " in class " + classDescriptor.getName();
return properties.iterator().next();
}
@@ -222,7 +222,7 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends KotlinLite
@NotNull
protected static ClassDescriptor getClassDescriptor(@NotNull PackageFragmentDescriptor packageView, @NotNull String name) {
Name className = Name.identifier(name);
ClassifierDescriptor aClass = packageView.getMemberScope().getClassifier(className, NoLookupLocation.FROM_TEST);
ClassifierDescriptor aClass = packageView.getMemberScope().getContributedClassifier(className, NoLookupLocation.FROM_TEST);
assertNotNull("Failed to find class: " + packageView.getName() + "." + className, aClass);
assert aClass instanceof ClassDescriptor : "Not a class: " + aClass;
return (ClassDescriptor) aClass;
@@ -232,7 +232,7 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends KotlinLite
private static ClassDescriptor getInnerClassDescriptor(@NotNull ClassDescriptor classDescriptor, @NotNull String name) {
Name propertyName = Name.identifier(name);
MemberScope memberScope = classDescriptor.getMemberScope(Collections.<TypeProjection>emptyList());
ClassifierDescriptor innerClass = memberScope.getClassifier(propertyName, NoLookupLocation.FROM_TEST);
ClassifierDescriptor innerClass = memberScope.getContributedClassifier(propertyName, NoLookupLocation.FROM_TEST);
assert innerClass instanceof ClassDescriptor : "Failed to find inner class " +
propertyName +
" in class " +
@@ -412,7 +412,7 @@ public class DescriptorValidator {
public Void visitVariableDescriptor(
VariableDescriptor descriptor, MemberScope scope
) {
assertFound(scope, descriptor, scope.getProperties(descriptor.getName(), NoLookupLocation.FROM_TEST));
assertFound(scope, descriptor, scope.getContributedVariables(descriptor.getName(), NoLookupLocation.FROM_TEST));
return null;
}
@@ -420,7 +420,7 @@ public class DescriptorValidator {
public Void visitFunctionDescriptor(
FunctionDescriptor descriptor, MemberScope scope
) {
assertFound(scope, descriptor, scope.getFunctions(descriptor.getName(), NoLookupLocation.FROM_TEST));
assertFound(scope, descriptor, scope.getContributedFunctions(descriptor.getName(), NoLookupLocation.FROM_TEST));
return null;
}
@@ -428,7 +428,7 @@ public class DescriptorValidator {
public Void visitTypeParameterDescriptor(
TypeParameterDescriptor descriptor, MemberScope scope
) {
assertFound(scope, descriptor, scope.getClassifier(descriptor.getName(), NoLookupLocation.FROM_TEST), true);
assertFound(scope, descriptor, scope.getContributedClassifier(descriptor.getName(), NoLookupLocation.FROM_TEST), true);
return null;
}
@@ -436,7 +436,7 @@ public class DescriptorValidator {
public Void visitClassDescriptor(
ClassDescriptor descriptor, MemberScope scope
) {
assertFound(scope, descriptor, scope.getClassifier(descriptor.getName(), NoLookupLocation.FROM_TEST), true);
assertFound(scope, descriptor, scope.getContributedClassifier(descriptor.getName(), NoLookupLocation.FROM_TEST), true);
return null;
}
@@ -73,7 +73,7 @@ public class BoundsSubstitutorTest extends KotlinTestWithEnvironment {
KtFile jetFile = KtPsiFactoryKt.KtPsiFactory(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"), NoLookupLocation.FROM_TEST);
module.getPackage(FqName.ROOT).getMemberScope().getContributedFunctions(Name.identifier("f"), NoLookupLocation.FROM_TEST);
assert functions.size() == 1 : "Many functions defined";
FunctionDescriptor function = ContainerUtil.getFirstItem(functions);