diff --git a/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/CodegenUtil.java b/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/CodegenUtil.java index f47317365dd..b113f2cbd46 100644 --- a/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/CodegenUtil.java +++ b/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/CodegenUtil.java @@ -50,7 +50,7 @@ public class CodegenUtil { @NotNull ClassifierDescriptor returnedClassifier, @NotNull ClassifierDescriptor... valueParameterClassifiers ) { - Collection functions = owner.getDefaultType().getMemberScope().getFunctions(name, NoLookupLocation.FROM_BACKEND); + Collection functions = owner.getDefaultType().getMemberScope().getContributedFunctions(name, NoLookupLocation.FROM_BACKEND); for (FunctionDescriptor function : functions) { if (!CallResolverUtilKt.isOrOverridesSynthesized(function) && function.getTypeParameters().isEmpty() diff --git a/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/CodegenUtilKt.kt b/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/CodegenUtilKt.kt index 86d71b543eb..4bd60e3c7e2 100644 --- a/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/CodegenUtilKt.kt +++ b/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/CodegenUtilKt.kt @@ -42,7 +42,7 @@ public object CodegenUtilKt { ): Map { if (delegateExpressionType?.isDynamic() ?: false) return mapOf(); - return descriptor.getDefaultType().getMemberScope().getDescriptors().asSequence() + return descriptor.getDefaultType().getMemberScope().getContributedDescriptors().asSequence() .filterIsInstance() .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()) } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ClosureCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ClosureCodegen.java index e7d37fdb57c..4de6487587f 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ClosureCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ClosureCodegen.java @@ -469,6 +469,6 @@ public class ClosureCodegen extends MemberCodegen { ? 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(); } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index d11e2826d44..85757c40b7c 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -1086,7 +1086,7 @@ public class ExpressionCodegen extends KtVisitor impleme Type asmLoopRangeType = asmType(loopRangeType); Collection 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()); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java index 4accf1afd56..b9a5f71f1e7 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java @@ -412,7 +412,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { private boolean isGenericToArrayPresent() { Collection 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() { + CollectionsKt.single(descriptor.getStaticScope().getContributedVariables(ENUM_VALUES, NoLookupLocation.FROM_BACKEND), new Function1() { @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() { + CollectionsKt.single(descriptor.getStaticScope().getContributedFunctions(ENUM_VALUE_OF, NoLookupLocation.FROM_BACKEND), new Function1() { @Override public Boolean invoke(FunctionDescriptor descriptor) { return CodegenUtil.isEnumValueOfMethod(descriptor); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/InterfaceImplBodyCodegen.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/InterfaceImplBodyCodegen.kt index d3066d1956b..d2cc722b29f 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/InterfaceImplBodyCodegen.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/InterfaceImplBodyCodegen.kt @@ -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 diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/MultifileClassCodegen.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/MultifileClassCodegen.kt index c7de026bdb8..89a29034dfb 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/MultifileClassCodegen.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/MultifileClassCodegen.kt @@ -70,7 +70,7 @@ public class MultifileClassCodegen( getDeserializedCallables(compiledPackageFragment) private fun getDeserializedCallables(compiledPackageFragment: PackageFragmentDescriptor) = - compiledPackageFragment.getMemberScope().getDescriptors(DescriptorKindFilter.CALLABLES, MemberScope.ALL_NAME_FILTER).filterIsInstance() + compiledPackageFragment.getMemberScope().getContributedDescriptors(DescriptorKindFilter.CALLABLES, MemberScope.ALL_NAME_FILTER).filterIsInstance() public val packageParts = PackageParts(facadeFqName.parent().asString()) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/SamWrapperCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/SamWrapperCodegen.java index 3ba918ef726..c479c290cbf 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/SamWrapperCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/SamWrapperCodegen.java @@ -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); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/BuilderFactoryForDuplicateSignatureDiagnostics.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/BuilderFactoryForDuplicateSignatureDiagnostics.kt index 9541bdbb5cc..83f43b33e23 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/BuilderFactoryForDuplicateSignatureDiagnostics.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/BuilderFactoryForDuplicateSignatureDiagnostics.kt @@ -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) } diff --git a/compiler/builtins-serializer/src/org/jetbrains/kotlin/serialization/builtins/BuiltInsSerializer.kt b/compiler/builtins-serializer/src/org/jetbrains/kotlin/serialization/builtins/BuiltInsSerializer.kt index 308830ba456..606dfcd4f26 100644 --- a/compiler/builtins-serializer/src/org/jetbrains/kotlin/serialization/builtins/BuiltInsSerializer.kt +++ b/compiler/builtins-serializer/src/org/jetbrains/kotlin/serialization/builtins/BuiltInsSerializer.kt @@ -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( diff --git a/compiler/builtins-serializer/src/org/jetbrains/kotlin/serialization/builtins/BuiltInsSerializerExtension.kt b/compiler/builtins-serializer/src/org/jetbrains/kotlin/serialization/builtins/BuiltInsSerializerExtension.kt index a4fdec68992..c17c1e3cd1a 100644 --- a/compiler/builtins-serializer/src/org/jetbrains/kotlin/serialization/builtins/BuiltInsSerializerExtension.kt +++ b/compiler/builtins-serializer/src/org/jetbrains/kotlin/serialization/builtins/BuiltInsSerializerExtension.kt @@ -38,7 +38,7 @@ public class BuiltInsSerializerExtension : SerializerExtension() { override fun serializePackage(packageFragments: Collection, proto: ProtoBuf.Package.Builder) { val classes = packageFragments.flatMap { - it.getMemberScope().getDescriptors(DescriptorKindFilter.CLASSIFIERS).filterIsInstance() + it.getMemberScope().getContributedDescriptors(DescriptorKindFilter.CLASSIFIERS).filterIsInstance() } for (descriptor in DescriptorSerializer.sort(classes)) { diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/CliLightClassGenerationSupport.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/CliLightClassGenerationSupport.kt index 107a1df32c1..17225522d7a 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/CliLightClassGenerationSupport.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/CliLightClassGenerationSupport.kt @@ -127,7 +127,7 @@ public class CliLightClassGenerationSupport(project: Project) : LightClassGenera override fun getSubPackages(fqn: FqName, scope: GlobalSearchScope): Collection { 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 { override fun `fun`(member: DeclarationDescriptor): FqName? { if (member is PackageViewDescriptor) { diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamConversionResolverImpl.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamConversionResolverImpl.kt index e0f20094e71..71eb3d32247 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamConversionResolverImpl.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamConversionResolverImpl.kt @@ -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) } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/kotlinSignature/SignaturesPropagationData.java b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/kotlinSignature/SignaturesPropagationData.java index 31a4febc47e..a46a4f9f719 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/kotlinSignature/SignaturesPropagationData.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/kotlinSignature/SignaturesPropagationData.java @@ -305,7 +305,7 @@ public class SignaturesPropagationData { Name name = method.getName(); JvmMethodSignature autoSignature = SIGNATURE_MAPPER.mapToJvmMethodSignature(autoMethodDescriptor); for (KotlinType supertype : containingClass.getTypeConstructor().getSupertypes()) { - Collection superFunctionCandidates = supertype.getMemberScope().getFunctions(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS); + Collection 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)) { diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JvmPlatform.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JvmPlatform.kt index ec01d023ceb..7dc312ceed4 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JvmPlatform.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JvmPlatform.kt @@ -51,7 +51,7 @@ private val DEFAULT_IMPORTS_FOR_JVM = ArrayList().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)) } } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticPropertiesScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticPropertiesScope.kt index 7362f20237e..f238e045a94 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticPropertiesScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticPropertiesScope.kt @@ -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) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SamAdapterFunctionsScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SamAdapterFunctionsScope.kt index 711ca2b5776..b7edf204101 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SamAdapterFunctionsScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SamAdapterFunctionsScope.kt @@ -57,7 +57,7 @@ class SamAdapterFunctionsScope(storageManager: StorageManager) : BaseImportingSc override fun getContributedSyntheticExtensionFunctions(receiverTypes: Collection, name: Name, location: LookupLocation): Collection { var result: SmartList? = 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): Collection { return receiverTypes.flatMapTo(LinkedHashSet()) { type -> - type.memberScope.getDescriptors(DescriptorKindFilter.FUNCTIONS) + type.memberScope.getContributedDescriptors(DescriptorKindFilter.FUNCTIONS) .filterIsInstance() .map { extensionForFunction(it.original) } .filterNotNull() diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AllUnderImportsScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AllUnderImportsScope.kt index cc23c22dadf..32a6de08be9 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AllUnderImportsScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AllUnderImportsScope.kt @@ -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) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationResolver.kt index 7c6e975212c..41a5f806bcd 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationResolver.kt @@ -53,7 +53,7 @@ public class DeclarationResolver( public fun checkRedeclarations(c: TopDownAnalysisContext) { for (classDescriptor in c.getDeclaredClasses().values()) { val descriptorMap = HashMultimap.create() - for (desc in classDescriptor.getUnsubstitutedMemberScope().getDescriptors()) { + for (desc in classDescriptor.getUnsubstitutedMemberScope().getContributedDescriptors()) { if (desc is ClassDescriptor || desc is PropertyDescriptor) { descriptorMap.put(desc.getName(), desc) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/NoSubpackagesInPackageScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/NoSubpackagesInPackageScope.kt index e9f8ee8c476..ca06e644d57 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/NoSubpackagesInPackageScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/NoSubpackagesInPackageScope.kt @@ -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 { + override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection { 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 } } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/OverloadUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/OverloadUtil.kt index b2f7162435f..9a49773f512 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/OverloadUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/OverloadUtil.kt @@ -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() + scope.getContributedVariables(name, NoLookupLocation.WHEN_CHECK_REDECLARATIONS).filterIsInstance() } // TODO handle constructor redeclarations in modules. See also: https://youtrack.jetbrains.com/issue/KT-3632 diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/OverrideResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/OverrideResolver.java index 293d66e4d43..d007a673826 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/OverrideResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/OverrideResolver.java @@ -794,9 +794,9 @@ public class OverrideResolver { ) { for (KotlinType supertype : declaringClass.getTypeConstructor().getSupertypes()) { Set 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)) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/QualifiedExpressionResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/QualifiedExpressionResolver.kt index fd82987dd6f..ae1d0dea8b3 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/QualifiedExpressionResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/QualifiedExpressionResolver.kt @@ -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().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 diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/CallableDescriptorCollectors.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/CallableDescriptorCollectors.kt index f9b3e45cf35..7ca83739c7d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/CallableDescriptorCollectors.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/CallableDescriptorCollectors.kt @@ -105,7 +105,7 @@ private object FunctionCollector : CallableDescriptorCollector { 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 { 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 } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/dynamicCalls.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/dynamicCalls.kt index bf4ddbb8835..d86c35d9d2d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/dynamicCalls.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/dynamicCalls.kt @@ -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 { + override fun getContributedFunctions(name: Name, location: LookupLocation): Collection { 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 { + override fun getContributedVariables(name: Name, location: LookupLocation): Collection { return if (call.getValueArgumentList() == null && call.getValueArguments().isEmpty()) { listOf(createDynamicProperty(owner, name, call)) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyDeclarationResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyDeclarationResolver.java index 51f0831a9bd..2f9b91d8753 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyDeclarationResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyDeclarationResolver.java @@ -72,7 +72,7 @@ public class LazyDeclarationResolver { // class A {} class A { fun foo(): A} // 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); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/ResolveSession.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/ResolveSession.java index b78547b880e..b54c07844be 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/ResolveSession.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/ResolveSession.java @@ -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; } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/ResolveSessionUtils.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/ResolveSessionUtils.java index fdc89dad5fb..bc5d62d8401 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/ResolveSessionUtils.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/ResolveSessionUtils.java @@ -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(); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/AbstractLazyMemberScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/AbstractLazyMemberScope.kt index 324d2959401..3f0367d474c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/AbstractLazyMemberScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/AbstractLazyMemberScope.kt @@ -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 { + override fun getContributedFunctions(name: Name, location: LookupLocation): Collection { recordLookup(name, location) return functionDescriptors(name) } @@ -94,7 +94,7 @@ protected constructor( protected abstract fun getNonDeclaredFunctions(name: Name, result: MutableSet) - override fun getProperties(name: Name, location: LookupLocation): Collection { + override fun getContributedVariables(name: Name, location: LookupLocation): Collection { 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) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java index 43bf123ad83..67283a6924d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java @@ -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; diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassMemberScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassMemberScope.kt index 81bc279d159..ef39bb82342 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassMemberScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassMemberScope.kt @@ -57,8 +57,8 @@ public open class LazyClassMemberScope( computeExtraDescriptors(NoLookupLocation.FOR_ALREADY_TRACKED) } - override fun getDescriptors(kindFilter: DescriptorKindFilter, - nameFilter: (Name) -> Boolean): Collection { + override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, + nameFilter: (Name) -> Boolean): Collection { val result = LinkedHashSet(descriptorsFromDeclaredElements()) result.addAll(extraDescriptors()) return result @@ -67,12 +67,12 @@ public open class LazyClassMemberScope( protected open fun computeExtraDescriptors(location: LookupLocation): Collection { val result = ArrayList() 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 { + override fun getContributedFunctions(name: Name, location: LookupLocation): Collection { // 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() 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 { + override fun getContributedVariables(name: Name, location: LookupLocation): Collection { // 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) return properties } @@ -197,7 +197,7 @@ public open class LazyClassMemberScope( // Members from supertypes val fromSupertypes = ArrayList() 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()) @@ -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 = object : MemberExtractor { override fun extract(extractFrom: KotlinType, name: Name): Collection { - return extractFrom.memberScope.getFunctions(name, NoLookupLocation.FOR_ALREADY_TRACKED) + return extractFrom.memberScope.getContributedFunctions(name, NoLookupLocation.FOR_ALREADY_TRACKED) } } private val EXTRACT_PROPERTIES: MemberExtractor = object : MemberExtractor { override fun extract(extractFrom: KotlinType, name: Name): Collection { - return extractFrom.memberScope.getProperties(name, NoLookupLocation.FOR_ALREADY_TRACKED) + return extractFrom.memberScope.getContributedVariables(name, NoLookupLocation.FOR_ALREADY_TRACKED) } } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyPackageMemberScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyPackageMemberScope.kt index 83da6cda2eb..cf23a844591 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyPackageMemberScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyPackageMemberScope.kt @@ -30,7 +30,7 @@ public class LazyPackageMemberScope( thisPackage: PackageFragmentDescriptor) : AbstractLazyMemberScope(resolveSession, declarationProvider, thisPackage, resolveSession.trace) { - override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection { + override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection { return computeDescriptorsFromDeclaredElements(kindFilter, nameFilter, NoLookupLocation.WHEN_GET_ALL_DESCRIPTORS) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyScriptClassMemberScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyScriptClassMemberScope.kt index ec82c12e7c5..c484e44013c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyScriptClassMemberScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyScriptClassMemberScope.kt @@ -44,11 +44,11 @@ public class LazyScriptClassMemberScope protected constructor( override fun computeExtraDescriptors(location: LookupLocation): Collection { 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) { super.getNonDeclaredProperties(name, result) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/FilteringScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/FilteringScope.kt index 011d963b914..b2f80d8bb6e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/FilteringScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/FilteringScope.kt @@ -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(), " {") diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/LexicalChainedScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/LexicalChainedScope.kt index 77e4df62320..550cec66f55 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/LexicalChainedScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/LexicalChainedScope.kt @@ -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 diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/utils/ScopeUtils.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/utils/ScopeUtils.kt index b3dd5adc0d3..6fc9985148f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/utils/ScopeUtils.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/utils/ScopeUtils.kt @@ -134,13 +134,13 @@ private class MemberScopeToImportingScopeAdapter(override val parent: ImportingS = emptyList() 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 diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/unqualifiedSuper/unqualifiedSuper.kt b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/unqualifiedSuper/unqualifiedSuper.kt index a06af73da4f..2beda40d309 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/unqualifiedSuper/unqualifiedSuper.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/unqualifiedSuper/unqualifiedSuper.kt @@ -135,10 +135,10 @@ private inline fun resolveSupertypesByMembers( } private fun getFunctionMembers(type: KotlinType, name: Name, location: LookupLocation): Collection = - type.memberScope.getFunctions(name, location) + type.memberScope.getContributedFunctions(name, location) private fun getPropertyMembers(type: KotlinType, name: Name, location: LookupLocation): Collection = - type.memberScope.getProperties(name, location).filterIsInstanceTo(SmartList()) + type.memberScope.getContributedVariables(name, location).filterIsInstanceTo(SmartList()) private fun isConcreteMember(supertype: KotlinType, memberDescriptor: MemberDescriptor): Boolean { // "Concrete member" is a function or a property that is not abstract, diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/DeserializedScopeValidationVisitor.kt b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/DeserializedScopeValidationVisitor.kt index 7152e8dc88d..e491a26b9e5 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/DeserializedScopeValidationVisitor.kt +++ b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/DeserializedScopeValidationVisitor.kt @@ -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()) diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/MultiModuleJavaAnalysisCustomTest.kt b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/MultiModuleJavaAnalysisCustomTest.kt index 4054b290b4a..d055bc6747f 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/MultiModuleJavaAnalysisCustomTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/MultiModuleJavaAnalysisCustomTest.kt @@ -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().forEach { + classDescriptor.getDefaultType().getMemberScope().getContributedDescriptors().filterIsInstance().forEach { checkCallable(it) } diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/runtime/AbstractJvmRuntimeDescriptorLoaderTest.kt b/compiler/tests/org/jetbrains/kotlin/jvm/runtime/AbstractJvmRuntimeDescriptorLoaderTest.kt index 01f14522f61..e3d68979175 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/runtime/AbstractJvmRuntimeDescriptorLoaderTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/jvm/runtime/AbstractJvmRuntimeDescriptorLoaderTest.kt @@ -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 = classifierMap.values + override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection = classifierMap.values override fun printScopeStructure(p: Printer) { p.println("runtime descriptor loader test") diff --git a/compiler/tests/org/jetbrains/kotlin/resolve/annotation/AbstractAnnotationDescriptorResolveTest.java b/compiler/tests/org/jetbrains/kotlin/resolve/annotation/AbstractAnnotationDescriptorResolveTest.java index b71ee11021d..9a57526e828 100644 --- a/compiler/tests/org/jetbrains/kotlin/resolve/annotation/AbstractAnnotationDescriptorResolveTest.java +++ b/compiler/tests/org/jetbrains/kotlin/resolve/annotation/AbstractAnnotationDescriptorResolveTest.java @@ -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 functions = memberScope.getFunctions(functionName, NoLookupLocation.FROM_TEST); + Collection 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.emptyList()); - Collection functions = memberScope.getFunctions(functionName, NoLookupLocation.FROM_TEST); + Collection 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 properties = memberScope.getProperties(propertyName, NoLookupLocation.FROM_TEST); + Collection properties = memberScope.getContributedVariables(propertyName, NoLookupLocation.FROM_TEST); if (properties.isEmpty()) { for (DeclarationDescriptor descriptor : DescriptorUtils.getAllDescriptors(memberScope)) { if (descriptor instanceof ClassDescriptor) { Collection classProperties = ((ClassDescriptor) descriptor).getMemberScope(Collections.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.emptyList()); - Collection properties = memberScope.getProperties(propertyName, NoLookupLocation.FROM_TEST); + Collection 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.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 " + diff --git a/compiler/tests/org/jetbrains/kotlin/test/util/DescriptorValidator.java b/compiler/tests/org/jetbrains/kotlin/test/util/DescriptorValidator.java index 5cc9783bd05..42f2325df6b 100644 --- a/compiler/tests/org/jetbrains/kotlin/test/util/DescriptorValidator.java +++ b/compiler/tests/org/jetbrains/kotlin/test/util/DescriptorValidator.java @@ -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; } diff --git a/compiler/tests/org/jetbrains/kotlin/types/BoundsSubstitutorTest.java b/compiler/tests/org/jetbrains/kotlin/types/BoundsSubstitutorTest.java index 05caa489b10..8ac2a6083ae 100644 --- a/compiler/tests/org/jetbrains/kotlin/types/BoundsSubstitutorTest.java +++ b/compiler/tests/org/jetbrains/kotlin/types/BoundsSubstitutorTest.java @@ -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 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); diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/LazyJavaPackageFragmentProvider.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/LazyJavaPackageFragmentProvider.kt index 825c94c9dd7..e1dab435b09 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/LazyJavaPackageFragmentProvider.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/LazyJavaPackageFragmentProvider.kt @@ -65,7 +65,7 @@ public class LazyJavaPackageFragmentProvider( javaClass.outerClass?.let { outerClass -> val outerClassScope = resolveClass(outerClass)?.unsubstitutedInnerClassesScope - return outerClassScope?.getClassifier(javaClass.name, NoLookupLocation.FROM_JAVA_LOADER) as? ClassDescriptor + return outerClassScope?.getContributedClassifier(javaClass.name, NoLookupLocation.FROM_JAVA_LOADER) as? ClassDescriptor } val kotlinResult = c.resolveKotlinBinaryClass(c.components.kotlinClassFinder.findKotlinClass(javaClass)) diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt index 717bb25cc84..11719459b18 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt @@ -129,7 +129,7 @@ class LazyJavaAnnotationDescriptor( //TODO: (module refactoring) moduleClassResolver should be used here val enumClass = c.javaClassResolver.resolveClass(containingJavaClass) ?: return null - val classifier = enumClass.getUnsubstitutedInnerClassesScope().getClassifier(element.getName(), NoLookupLocation.FROM_JAVA_LOADER) + val classifier = enumClass.getUnsubstitutedInnerClassesScope().getContributedClassifier(element.getName(), NoLookupLocation.FROM_JAVA_LOADER) if (classifier !is ClassDescriptor) return null return factory.createEnumValue(classifier) diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt index 756b7e331e9..dc1bb29ce48 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt @@ -302,7 +302,7 @@ public class LazyJavaClassMemberScope( private fun getFunctionsFromSupertypes(name: Name): Set { return getContainingDeclaration().typeConstructor.supertypes.flatMap { - it.memberScope.getFunctions(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS).map { f -> f as SimpleFunctionDescriptor } + it.memberScope.getContributedFunctions(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS).map { f -> f as SimpleFunctionDescriptor } }.toSet() } @@ -414,7 +414,7 @@ public class LazyJavaClassMemberScope( private fun getPropertiesFromSupertypes(name: Name): Set { return getContainingDeclaration().typeConstructor.supertypes.flatMap { - it.memberScope.getProperties(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS).map { p -> p } + it.memberScope.getContributedVariables(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS).map { p -> p } }.toSet() } @@ -615,7 +615,7 @@ public class LazyJavaClassMemberScope( override fun getDispatchReceiverParameter(): ReceiverParameterDescriptor? = DescriptorUtils.getDispatchReceiverParameterIfNeeded(getContainingDeclaration()) - override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? { + override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? { recordLookup(name, location) return nestedClasses(name) } @@ -628,7 +628,7 @@ public class LazyJavaClassMemberScope( return memberIndex().getAllFieldNames() + getContainingDeclaration().getTypeConstructor().getSupertypes().flatMapTo(LinkedHashSet()) { supertype -> - supertype.getMemberScope().getDescriptors(kindFilter, nameFilter).map { variable -> + supertype.getMemberScope().getContributedDescriptors(kindFilter, nameFilter).map { variable -> variable.getName() } } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaPackageScope.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaPackageScope.kt index 7bc806c9124..0680628e2e6 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaPackageScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaPackageScope.kt @@ -99,29 +99,29 @@ public class LazyJavaPackageScope( } } - override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? { + override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? { if (!SpecialNames.isSafeIdentifier(name)) return null recordLookup(name, location) return classes(name) } - override fun getProperties(name: Name, location: LookupLocation): Collection { + override fun getContributedVariables(name: Name, location: LookupLocation): Collection { // We should track lookups here because this scope can be used for kotlin packages too (if it doesn't contain toplevel properties nor functions). recordLookup(name, location) - return deserializedPackageScope().getProperties(name, NoLookupLocation.FOR_ALREADY_TRACKED) + return deserializedPackageScope().getContributedVariables(name, NoLookupLocation.FOR_ALREADY_TRACKED) } - override fun getFunctions(name: Name, location: LookupLocation): List { + override fun getContributedFunctions(name: Name, location: LookupLocation): List { // We should track lookups here because this scope can be used for kotlin packages too (if it doesn't contain toplevel properties nor functions). recordLookup(name, location) - return deserializedPackageScope().getFunctions(name, NoLookupLocation.FOR_ALREADY_TRACKED) + super.getFunctions(name, NoLookupLocation.FOR_ALREADY_TRACKED) + return deserializedPackageScope().getContributedFunctions(name, NoLookupLocation.FOR_ALREADY_TRACKED) + super.getContributedFunctions(name, NoLookupLocation.FOR_ALREADY_TRACKED) } override fun addExtraDescriptors(result: MutableSet, kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean) { - result.addAll(deserializedPackageScope().getDescriptors(kindFilter, nameFilter)) + result.addAll(deserializedPackageScope().getContributedDescriptors(kindFilter, nameFilter)) } override fun computeMemberIndex(): MemberIndex = object : MemberIndex by EMPTY_MEMBER_INDEX { @@ -162,7 +162,7 @@ public class LazyJavaPackageScope( override fun getPropertyNames(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean) = listOf() // we don't use implementation from super which caches all descriptors and does not use filters - override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection { + override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection { return computeDescriptors(kindFilter, nameFilter, NoLookupLocation.WHEN_GET_ALL_DESCRIPTORS) } } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaScope.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaScope.kt index 9fbdc29103e..4ab252a6fef 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaScope.kt @@ -214,7 +214,7 @@ public abstract class LazyJavaScope( return ResolvedValueParameters(descriptors, synthesizedNames) } - override fun getFunctions(name: Name, location: LookupLocation): Collection { + override fun getContributedFunctions(name: Name, location: LookupLocation): Collection { recordLookup(name, location) return functions(name) } @@ -298,13 +298,13 @@ public abstract class LazyJavaScope( return propertyType } - override fun getProperties(name: Name, location: LookupLocation): Collection { + override fun getContributedVariables(name: Name, location: LookupLocation): Collection { recordLookup(name, location) return properties(name) } - override fun getDescriptors(kindFilter: DescriptorKindFilter, - nameFilter: (Name) -> Boolean) = allDescriptors() + override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, + nameFilter: (Name) -> Boolean) = allDescriptors() protected fun computeDescriptors( kindFilter: DescriptorKindFilter, @@ -317,7 +317,7 @@ public abstract class LazyJavaScope( for (name in getClassNames(kindFilter, nameFilter)) { if (nameFilter(name)) { // Null signifies that a class found in Java is not present in Kotlin (e.g. package class) - result.addIfNotNull(getClassifier(name, location)) + result.addIfNotNull(getContributedClassifier(name, location)) } } } @@ -325,7 +325,7 @@ public abstract class LazyJavaScope( if (kindFilter.acceptsKinds(DescriptorKindFilter.FUNCTIONS_MASK) && !kindFilter.excludes.contains(NonExtensions)) { for (name in getFunctionNames(kindFilter, nameFilter)) { if (nameFilter(name)) { - result.addAll(getFunctions(name, location)) + result.addAll(getContributedFunctions(name, location)) } } } @@ -333,7 +333,7 @@ public abstract class LazyJavaScope( if (kindFilter.acceptsKinds(DescriptorKindFilter.VARIABLES_MASK) && !kindFilter.excludes.contains(NonExtensions)) { for (name in getPropertyNames(kindFilter, nameFilter)) { if (nameFilter(name)) { - result.addAll(getProperties(name, location)) + result.addAll(getContributedVariables(name, location)) } } } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaStaticClassScope.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaStaticClassScope.kt index 507308a46f3..dc950d52f79 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaStaticClassScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaStaticClassScope.kt @@ -63,7 +63,8 @@ public class LazyJavaStaticClassScope( memberIndex().getAllFieldNames() + (if (jClass.isEnum) listOf(DescriptorUtils.ENUM_VALUES) else emptyList()) override fun getClassNames(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection = listOf() - override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? { + + override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? { // We don't need to track lookups here because we find nested/inner classes in LazyJavaClassMemberScope return null } @@ -113,7 +114,7 @@ public class LazyJavaStaticClassScope( private fun getStaticFunctionsFromJavaSuperClasses(name: Name, descriptor: ClassDescriptor): Set { val staticScope = descriptor.getParentJavaStaticClassScope() ?: return emptySet() - return staticScope.getFunctions(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS).map { it as SimpleFunctionDescriptor }.toSet() + return staticScope.getContributedFunctions(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS).map { it as SimpleFunctionDescriptor }.toSet() } private fun getStaticPropertiesFromJavaSupertypes(name: Name, descriptor: ClassDescriptor): Set { @@ -125,7 +126,7 @@ public class LazyJavaStaticClassScope( if (staticScope !is LazyJavaStaticClassScope) return getStaticPropertiesFromJavaSupertypes(name, superTypeDescriptor) - return staticScope.getProperties(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS).map { it } + return staticScope.getContributedVariables(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS).map { it } } return descriptor.typeConstructor.supertypes.flatMap(::getStaticProperties).toSet() diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/BinaryClassAnnotationAndConstantLoaderImpl.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/BinaryClassAnnotationAndConstantLoaderImpl.kt index c990feb0380..54d199a31e7 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/BinaryClassAnnotationAndConstantLoaderImpl.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/BinaryClassAnnotationAndConstantLoaderImpl.kt @@ -152,7 +152,7 @@ public class BinaryClassAnnotationAndConstantLoaderImpl( private fun enumEntryValue(enumClassId: ClassId, name: Name): ConstantValue<*> { val enumClass = resolveClass(enumClassId) if (enumClass.getKind() == ClassKind.ENUM_CLASS) { - val classifier = enumClass.getUnsubstitutedInnerClassesScope().getClassifier(name, NoLookupLocation.FROM_JAVA_LOADER) + val classifier = enumClass.getUnsubstitutedInnerClassesScope().getContributedClassifier(name, NoLookupLocation.FROM_JAVA_LOADER) if (classifier is ClassDescriptor) { return factory.createEnumValue(classifier) } diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java b/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java index b6f68f5ec94..b06b221dae4 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java @@ -219,8 +219,8 @@ public abstract class KotlinBuiltIns { @NotNull public ClassDescriptor getAnnotationClassByName(@NotNull Name simpleName) { - ClassifierDescriptor classifier = annotationPackageFragment.getMemberScope().getClassifier(simpleName, - NoLookupLocation.FROM_BUILTINS); + ClassifierDescriptor classifier = annotationPackageFragment.getMemberScope().getContributedClassifier(simpleName, + NoLookupLocation.FROM_BUILTINS); assert classifier instanceof ClassDescriptor : "Must be a class descriptor " + simpleName + ", but was " + (classifier == null ? "null" : classifier.toString()); return (ClassDescriptor) classifier; @@ -235,8 +235,8 @@ public abstract class KotlinBuiltIns { @Nullable public ClassDescriptor getBuiltInClassByNameNullable(@NotNull Name simpleName) { - ClassifierDescriptor classifier = getBuiltInsPackageFragment().getMemberScope().getClassifier(simpleName, - NoLookupLocation.FROM_BUILTINS); + ClassifierDescriptor classifier = getBuiltInsPackageFragment().getMemberScope().getContributedClassifier(simpleName, + NoLookupLocation.FROM_BUILTINS); assert classifier == null || classifier instanceof ClassDescriptor : "Must be a class descriptor " + simpleName + ", but was " + classifier; return (ClassDescriptor) classifier; @@ -405,7 +405,7 @@ public abstract class KotlinBuiltIns { @Nullable public ClassDescriptor getAnnotationTargetEnumEntry(@NotNull KotlinTarget target) { - ClassifierDescriptor result = getAnnotationTargetEnum().getUnsubstitutedInnerClassesScope().getClassifier( + ClassifierDescriptor result = getAnnotationTargetEnum().getUnsubstitutedInnerClassesScope().getContributedClassifier( Name.identifier(target.name()), NoLookupLocation.FROM_BUILTINS ); return result instanceof ClassDescriptor ? (ClassDescriptor) result : null; @@ -418,7 +418,7 @@ public abstract class KotlinBuiltIns { @Nullable public ClassDescriptor getAnnotationRetentionEnumEntry(@NotNull KotlinRetention retention) { - ClassifierDescriptor result = getAnnotationRetentionEnum().getUnsubstitutedInnerClassesScope().getClassifier( + ClassifierDescriptor result = getAnnotationRetentionEnum().getUnsubstitutedInnerClassesScope().getContributedClassifier( Name.identifier(retention.name()), NoLookupLocation.FROM_BUILTINS ); return result instanceof ClassDescriptor ? (ClassDescriptor) result : null; @@ -1072,7 +1072,7 @@ public abstract class KotlinBuiltIns { @NotNull public FunctionDescriptor getIdentityEquals() { - return first(getBuiltInsPackageFragment().getMemberScope().getFunctions(Name.identifier("identityEquals"), - NoLookupLocation.FROM_BUILTINS)); + return first(getBuiltInsPackageFragment().getMemberScope().getContributedFunctions(Name.identifier("identityEquals"), + NoLookupLocation.FROM_BUILTINS)); } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/ReflectionTypes.kt b/core/descriptors/src/org/jetbrains/kotlin/builtins/ReflectionTypes.kt index a08783997bc..b1e098dff32 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/ReflectionTypes.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/ReflectionTypes.kt @@ -38,7 +38,7 @@ public class ReflectionTypes(private val module: ModuleDescriptor) { fun find(className: String): ClassDescriptor { val name = Name.identifier(className) - return kotlinReflectScope.getClassifier(name, NoLookupLocation.FROM_REFLECTION) as? ClassDescriptor + return kotlinReflectScope.getContributedClassifier(name, NoLookupLocation.FROM_REFLECTION) as? ClassDescriptor ?: ErrorUtils.createErrorClass(KOTLIN_REFLECT_FQ_NAME.child(name).asString()) } diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassDescriptor.kt b/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassDescriptor.kt index db5cbdd29cd..54d1f22fd2b 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassDescriptor.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassDescriptor.kt @@ -111,7 +111,7 @@ public class FunctionClassDescriptor( val result = ArrayList(2) fun add(packageFragment: PackageFragmentDescriptor, name: Name) { - val descriptor = packageFragment.getMemberScope().getClassifier(name, NoLookupLocation.FROM_BUILTINS) as? ClassDescriptor + val descriptor = packageFragment.getMemberScope().getContributedClassifier(name, NoLookupLocation.FROM_BUILTINS) as? ClassDescriptor ?: error("Class $name not found in $packageFragment") val typeConstructor = descriptor.getTypeConstructor() diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassScope.kt b/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassScope.kt index 4ee7c78a6d0..77127dac79f 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassScope.kt @@ -43,23 +43,23 @@ class FunctionClassScope( override fun getContainingDeclaration() = functionClass - override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection { + override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection { if (!kindFilter.acceptsKinds(DescriptorKindFilter.CALLABLES.kindMask)) return listOf() return allDescriptors() } - override fun getFunctions(name: Name, location: LookupLocation): Collection { + override fun getContributedFunctions(name: Name, location: LookupLocation): Collection { return allDescriptors().filterIsInstance().filter { it.getName() == name } } - override fun getProperties(name: Name, location: LookupLocation): Collection { + override fun getContributedVariables(name: Name, location: LookupLocation): Collection { return allDescriptors().filterIsInstance().filter { it.getName() == name } } private fun createFakeOverrides(invoke: FunctionDescriptor?): List { val result = ArrayList(3) val allSuperDescriptors = functionClass.getTypeConstructor().getSupertypes() - .flatMap { it.getMemberScope().getDescriptors() } + .flatMap { it.getMemberScope().getContributedDescriptors() } .filterIsInstance() for ((name, group) in allSuperDescriptors.groupBy { it.getName() }) { for ((isFunction, descriptors) in group.groupBy { it is FunctionDescriptor }) { diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/EnumEntrySyntheticClassDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/EnumEntrySyntheticClassDescriptor.java index a09d34da9b0..afc92c74557 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/EnumEntrySyntheticClassDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/EnumEntrySyntheticClassDescriptor.java @@ -201,25 +201,25 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase { @NotNull @Override - public Collection getProperties(@NotNull Name name, @NotNull LookupLocation location) { + public Collection getContributedVariables(@NotNull Name name, @NotNull LookupLocation location) { return properties.invoke(name); } @NotNull @SuppressWarnings("unchecked") private Collection computeProperties(@NotNull Name name) { - return resolveFakeOverrides(name, (Collection) getSupertypeScope().getProperties(name, NoLookupLocation.FOR_NON_TRACKED_SCOPE)); + return resolveFakeOverrides(name, (Collection) getSupertypeScope().getContributedVariables(name, NoLookupLocation.FOR_NON_TRACKED_SCOPE)); } @NotNull @Override - public Collection getFunctions(@NotNull Name name, @NotNull LookupLocation location) { + public Collection getContributedFunctions(@NotNull Name name, @NotNull LookupLocation location) { return functions.invoke(name); } @NotNull private Collection computeFunctions(@NotNull Name name) { - return resolveFakeOverrides(name, getSupertypeScope().getFunctions(name, NoLookupLocation.FOR_NON_TRACKED_SCOPE)); + return resolveFakeOverrides(name, getSupertypeScope().getContributedFunctions(name, NoLookupLocation.FOR_NON_TRACKED_SCOPE)); } @NotNull @@ -264,7 +264,7 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase { @NotNull @Override - public Collection getDescriptors( + public Collection getContributedDescriptors( @NotNull DescriptorKindFilter kindFilter, @NotNull Function1 nameFilter ) { @@ -275,8 +275,8 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase { private Collection computeAllDeclarations() { Collection result = new HashSet(); for (Name name : enumMemberNames.invoke()) { - result.addAll(getFunctions(name, NoLookupLocation.FOR_NON_TRACKED_SCOPE)); - result.addAll(getProperties(name, NoLookupLocation.FOR_NON_TRACKED_SCOPE)); + result.addAll(getContributedFunctions(name, NoLookupLocation.FOR_NON_TRACKED_SCOPE)); + result.addAll(getContributedVariables(name, NoLookupLocation.FOR_NON_TRACKED_SCOPE)); } return result; } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/SubpackagesScope.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/SubpackagesScope.kt index 2e26a3eab72..88d8bd113be 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/SubpackagesScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/SubpackagesScope.kt @@ -45,8 +45,8 @@ public class SubpackagesScope(private val moduleDescriptor: ModuleDescriptor, pr return packageViewDescriptor } - override fun getDescriptors(kindFilter: DescriptorKindFilter, - nameFilter: (Name) -> Boolean): Collection { + override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, + nameFilter: (Name) -> Boolean): Collection { if (!kindFilter.acceptsKinds(DescriptorKindFilter.PACKAGES_MASK)) return listOf() if (fqName.isRoot() && kindFilter.excludes.contains(DescriptorKindExclude.TopLevelPackages)) return listOf() diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.java index 88a5850dbfa..18d708de678 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.java +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.java @@ -383,7 +383,7 @@ public class DescriptorUtils { @Nullable public static ClassDescriptor getInnerClassByName(@NotNull ClassDescriptor classDescriptor, @NotNull String innerClassName, @NotNull LookupLocation location) { ClassifierDescriptor classifier = - classDescriptor.getDefaultType().getMemberScope().getClassifier(Name.identifier(innerClassName), location); + classDescriptor.getDefaultType().getMemberScope().getContributedClassifier(Name.identifier(innerClassName), location); assert classifier instanceof ClassDescriptor : "Inner class " + innerClassName + " in " + classDescriptor + " should be instance of ClassDescriptor, but was: " + (classifier == null ? "null" : classifier.getClass()); @@ -551,6 +551,6 @@ public class DescriptorUtils { @NotNull public static Collection getAllDescriptors(@NotNull MemberScope scope) { - return scope.getDescriptors(DescriptorKindFilter.ALL, MemberScope.Companion.getALL_NAME_FILTER()); + return scope.getContributedDescriptors(DescriptorKindFilter.ALL, MemberScope.Companion.getALL_NAME_FILTER()); } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.kt index f5e1ed3c0c7..aaf90ed26cf 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.kt @@ -56,7 +56,7 @@ public val DeclarationDescriptor.module: ModuleDescriptor public fun ModuleDescriptor.resolveTopLevelClass(topLevelClassFqName: FqName, location: LookupLocation): ClassDescriptor? { assert(!topLevelClassFqName.isRoot()) - return getPackage(topLevelClassFqName.parent()).memberScope.getClassifier(topLevelClassFqName.shortName(), location) as? ClassDescriptor + return getPackage(topLevelClassFqName.parent()).memberScope.getContributedClassifier(topLevelClassFqName.shortName(), location) as? ClassDescriptor } public val ClassDescriptor.classId: ClassId diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/AbstractScopeAdapter.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/AbstractScopeAdapter.kt index b26a52f3aa5..46794578415 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/AbstractScopeAdapter.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/AbstractScopeAdapter.kt @@ -33,29 +33,29 @@ public abstract class AbstractScopeAdapter : MemberScope { else workerScope - override fun getFunctions(name: Name, location: LookupLocation): Collection { - return workerScope.getFunctions(name, location) + override fun getContributedFunctions(name: Name, location: LookupLocation): Collection { + return workerScope.getContributedFunctions(name, location) } override fun getPackage(name: Name): PackageViewDescriptor? { return workerScope.getPackage(name) } - override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? { - return workerScope.getClassifier(name, location) + override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? { + return workerScope.getContributedClassifier(name, location) } - override fun getProperties(name: Name, location: LookupLocation): Collection { - return workerScope.getProperties(name, location) + override fun getContributedVariables(name: Name, location: LookupLocation): Collection { + return workerScope.getContributedVariables(name, location) } override fun getContainingDeclaration(): DeclarationDescriptor { return workerScope.getContainingDeclaration() } - override fun getDescriptors(kindFilter: DescriptorKindFilter, - nameFilter: (Name) -> Boolean): Collection { - return workerScope.getDescriptors(kindFilter, nameFilter) + override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, + nameFilter: (Name) -> Boolean): Collection { + return workerScope.getContributedDescriptors(kindFilter, nameFilter) } override fun printScopeStructure(p: Printer) { diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ChainedScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ChainedScope.kt index daaa9d7c2de..97fa1b6d930 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ChainedScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ChainedScope.kt @@ -30,22 +30,22 @@ public open class ChainedScope( ) : MemberScope { private val scopeChain = scopes.clone() - override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? - = getFirstMatch(scopeChain) { it.getClassifier(name, location) } + override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? + = getFirstMatch(scopeChain) { it.getContributedClassifier(name, location) } override fun getPackage(name: Name): PackageViewDescriptor? = getFirstMatch(scopeChain) { it.getPackage(name) } - override fun getProperties(name: Name, location: LookupLocation): Collection - = getFromAllScopes(scopeChain) { it.getProperties(name, location) } + override fun getContributedVariables(name: Name, location: LookupLocation): Collection + = getFromAllScopes(scopeChain) { it.getContributedVariables(name, location) } - override fun getFunctions(name: Name, location: LookupLocation): Collection - = getFromAllScopes(scopeChain) { it.getFunctions(name, location) } + override fun getContributedFunctions(name: Name, location: LookupLocation): Collection + = getFromAllScopes(scopeChain) { it.getContributedFunctions(name, location) } override fun getContainingDeclaration(): DeclarationDescriptor = containingDeclaration!! - override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean) - = getFromAllScopes(scopeChain) { it.getDescriptors(kindFilter, nameFilter) } + override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean) + = getFromAllScopes(scopeChain) { it.getContributedDescriptors(kindFilter, nameFilter) } override fun toString() = debugName diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/InnerClassesScopeWrapper.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/InnerClassesScopeWrapper.kt index 620d610b21b..8f2c13aa3de 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/InnerClassesScopeWrapper.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/InnerClassesScopeWrapper.kt @@ -27,11 +27,11 @@ public class InnerClassesScopeWrapper(val workerScope: MemberScope) : MemberScop return workerScope.getContainingDeclaration() } - override fun getClassifier(name: Name, location: LookupLocation) = workerScope.getClassifier(name, location) as? ClassDescriptor + override fun getContributedClassifier(name: Name, location: LookupLocation) = workerScope.getContributedClassifier(name, location) as? ClassDescriptor - override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): List { + override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): List { val restrictedFilter = kindFilter.restrictedToKindsOrNull(DescriptorKindFilter.CLASSIFIERS_MASK) ?: return listOf() - return workerScope.getDescriptors(restrictedFilter, nameFilter).filterIsInstance() + return workerScope.getContributedDescriptors(restrictedFilter, nameFilter).filterIsInstance() } override fun printScopeStructure(p: Printer) { diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/MemberScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/MemberScope.kt index 38e8a44dc8f..ac5bfb5bd8a 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/MemberScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/MemberScope.kt @@ -25,14 +25,14 @@ import java.lang.reflect.Modifier public interface MemberScope { - public fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? + public fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? @Deprecated("Should be removed soon") public fun getPackage(name: Name): PackageViewDescriptor? - public fun getProperties(name: Name, location: LookupLocation): Collection + public fun getContributedVariables(name: Name, location: LookupLocation): Collection - public fun getFunctions(name: Name, location: LookupLocation): Collection + public fun getContributedFunctions(name: Name, location: LookupLocation): Collection public fun getContainingDeclaration(): DeclarationDescriptor @@ -40,7 +40,7 @@ public interface MemberScope { * All visible descriptors from current scope possibly filtered by the given name and kind filters * (that means that the implementation is not obliged to use the filters but may do so when it gives any performance advantage). */ - public fun getDescriptors( + public fun getContributedDescriptors( kindFilter: DescriptorKindFilter = DescriptorKindFilter.ALL, nameFilter: (Name) -> Boolean = ALL_NAME_FILTER ): Collection @@ -75,7 +75,7 @@ public fun MemberScope.getDescriptorsFiltered( nameFilter: (Name) -> Boolean = { true } ): Collection { if (kindFilter.kindMask == 0) return listOf() - return getDescriptors(kindFilter, nameFilter).filter { kindFilter.accepts(it) && nameFilter(it.getName()) } + return getContributedDescriptors(kindFilter, nameFilter).filter { kindFilter.accepts(it) && nameFilter(it.getName()) } } public class DescriptorKindFilter( diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/MemberScopeImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/MemberScopeImpl.kt index f435ca4c0ca..ec23af4fc24 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/MemberScopeImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/MemberScopeImpl.kt @@ -22,16 +22,16 @@ import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.utils.Printer abstract class MemberScopeImpl : MemberScope { - override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? = null + override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? = null - override fun getProperties(name: Name, location: LookupLocation): Collection = emptyList() + override fun getContributedVariables(name: Name, location: LookupLocation): Collection = emptyList() override fun getPackage(name: Name): PackageViewDescriptor? = null - override fun getFunctions(name: Name, location: LookupLocation): Collection = emptyList() + override fun getContributedFunctions(name: Name, location: LookupLocation): Collection = emptyList() - override fun getDescriptors(kindFilter: DescriptorKindFilter, - nameFilter: (Name) -> Boolean): Collection = emptyList() + override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, + nameFilter: (Name) -> Boolean): Collection = emptyList() // This method should not be implemented here by default: every scope class has its unique structure pattern abstract override fun printScopeStructure(p: Printer) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/StaticScopeForKotlinClass.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/StaticScopeForKotlinClass.kt index 85163d79ed1..7f25d069cb8 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/StaticScopeForKotlinClass.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/StaticScopeForKotlinClass.kt @@ -30,7 +30,7 @@ import java.util.* public class StaticScopeForKotlinClass( private val containingClass: ClassDescriptor ) : MemberScopeImpl() { - override fun getClassifier(name: Name, location: LookupLocation) = null // TODO + override fun getContributedClassifier(name: Name, location: LookupLocation) = null // TODO private val functions: List by lazy { if (containingClass.getKind() != ClassKind.ENUM_CLASS) { @@ -50,12 +50,12 @@ public class StaticScopeForKotlinClass( } } - override fun getDescriptors(kindFilter: DescriptorKindFilter, - nameFilter: (Name) -> Boolean) = functions + properties + override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, + nameFilter: (Name) -> Boolean) = functions + properties - override fun getProperties(name: Name, location: LookupLocation) = properties.filterTo(ArrayList(1)) { it.name == name } + override fun getContributedVariables(name: Name, location: LookupLocation) = properties.filterTo(ArrayList(1)) { it.name == name } - override fun getFunctions(name: Name, location: LookupLocation) = functions.filterTo(ArrayList(2)) { it.getName() == name } + override fun getContributedFunctions(name: Name, location: LookupLocation) = functions.filterTo(ArrayList(2)) { it.getName() == name } override fun getContainingDeclaration() = containingClass diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt index 0537d6f7a1c..9fb24785da5 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt @@ -28,7 +28,7 @@ public class SubstitutingScope(private val workerScope: MemberScope, private val private var substitutedDescriptors: MutableMap? = null - private val _allDescriptors by lazy { substitute(workerScope.getDescriptors()) } + private val _allDescriptors by lazy { substitute(workerScope.getContributedDescriptors()) } private fun substitute(descriptor: D?): D? { if (descriptor == null) return null @@ -59,18 +59,18 @@ public class SubstitutingScope(private val workerScope: MemberScope, private val return result } - override fun getProperties(name: Name, location: LookupLocation) = substitute(workerScope.getProperties(name, location)) + override fun getContributedVariables(name: Name, location: LookupLocation) = substitute(workerScope.getContributedVariables(name, location)) - override fun getClassifier(name: Name, location: LookupLocation) = substitute(workerScope.getClassifier(name, location)) + override fun getContributedClassifier(name: Name, location: LookupLocation) = substitute(workerScope.getContributedClassifier(name, location)) - override fun getFunctions(name: Name, location: LookupLocation) = substitute(workerScope.getFunctions(name, location)) + override fun getContributedFunctions(name: Name, location: LookupLocation) = substitute(workerScope.getContributedFunctions(name, location)) override fun getPackage(name: Name) = workerScope.getPackage(name) override fun getContainingDeclaration() = workerScope.getContainingDeclaration() - override fun getDescriptors(kindFilter: DescriptorKindFilter, - nameFilter: (Name) -> Boolean) = _allDescriptors + override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, + nameFilter: (Name) -> Boolean) = _allDescriptors override fun printScopeStructure(p: Printer) { p.println(javaClass.getSimpleName(), " {") diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java b/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java index a9c68110d23..15f1b4e79a3 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java @@ -169,13 +169,13 @@ public class ErrorUtils { @Nullable @Override - public ClassifierDescriptor getClassifier(@NotNull Name name, @NotNull LookupLocation location) { + public ClassifierDescriptor getContributedClassifier(@NotNull Name name, @NotNull LookupLocation location) { return createErrorClass(name.asString()); } @NotNull @Override - public Set getProperties(@NotNull Name name, @NotNull LookupLocation location) { + public Set getContributedVariables(@NotNull Name name, @NotNull LookupLocation location) { return ERROR_PROPERTY_GROUP; } @@ -186,7 +186,7 @@ public class ErrorUtils { @NotNull @Override - public Set getFunctions(@NotNull Name name, @NotNull LookupLocation location) { + public Set getContributedFunctions(@NotNull Name name, @NotNull LookupLocation location) { return Collections.singleton(createErrorFunction(this)); } @@ -198,7 +198,7 @@ public class ErrorUtils { @NotNull @Override - public Collection getDescriptors( + public Collection getContributedDescriptors( @NotNull DescriptorKindFilter kindFilter, @NotNull Function1 nameFilter ) { return Collections.emptyList(); @@ -224,7 +224,7 @@ public class ErrorUtils { @Nullable @Override - public ClassifierDescriptor getClassifier(@NotNull Name name, @NotNull LookupLocation location) { + public ClassifierDescriptor getContributedClassifier(@NotNull Name name, @NotNull LookupLocation location) { throw new IllegalStateException(); } @@ -236,13 +236,13 @@ public class ErrorUtils { @NotNull @Override - public Collection getProperties(@NotNull Name name, @NotNull LookupLocation location) { + public Collection getContributedVariables(@NotNull Name name, @NotNull LookupLocation location) { throw new IllegalStateException(); } @NotNull @Override - public Collection getFunctions(@NotNull Name name, @NotNull LookupLocation location) { + public Collection getContributedFunctions(@NotNull Name name, @NotNull LookupLocation location) { throw new IllegalStateException(); } @@ -254,7 +254,7 @@ public class ErrorUtils { @NotNull @Override - public Collection getDescriptors( + public Collection getContributedDescriptors( @NotNull DescriptorKindFilter kindFilter, @NotNull Function1 nameFilter ) { throw new IllegalStateException(); diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationDeserializer.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationDeserializer.kt index f5797af5422..d5f92ba28dc 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationDeserializer.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationDeserializer.kt @@ -135,7 +135,7 @@ public class AnnotationDeserializer(private val module: ModuleDescriptor) { private fun resolveEnumValue(enumClassId: ClassId, enumEntryName: Name): ConstantValue<*> { val enumClass = resolveClass(enumClassId) if (enumClass.getKind() == ClassKind.ENUM_CLASS) { - val enumEntry = enumClass.getUnsubstitutedInnerClassesScope().getClassifier(enumEntryName, NoLookupLocation.FROM_DESERIALIZATION) + val enumEntry = enumClass.getUnsubstitutedInnerClassesScope().getContributedClassifier(enumEntryName, NoLookupLocation.FROM_DESERIALIZATION) if (enumEntry is ClassDescriptor) { return factory.createEnumValue(enumEntry) } diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt index 037be2bc7af..b9c6a0fc704 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt @@ -130,7 +130,7 @@ public class DeserializedClassDescriptor( if (!classProto.hasCompanionObjectName()) return null val companionObjectName = c.nameResolver.getName(classProto.getCompanionObjectName()) - return memberScope.getClassifier(companionObjectName, NoLookupLocation.FROM_DESERIALIZATION) as? ClassDescriptor + return memberScope.getContributedClassifier(companionObjectName, NoLookupLocation.FROM_DESERIALIZATION) as? ClassDescriptor } override fun getCompanionObjectDescriptor(): ClassDescriptor? = companionObjectDescriptor() @@ -192,13 +192,13 @@ public class DeserializedClassDescriptor( computeDescriptors(DescriptorKindFilter.ALL, MemberScope.ALL_NAME_FILTER, NoLookupLocation.WHEN_GET_ALL_DESCRIPTORS) } - override fun getDescriptors(kindFilter: DescriptorKindFilter, - nameFilter: (Name) -> Boolean): Collection = allDescriptors() + override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, + nameFilter: (Name) -> Boolean): Collection = allDescriptors() override fun computeNonDeclaredFunctions(name: Name, functions: MutableCollection) { val fromSupertypes = ArrayList() for (supertype in classDescriptor.getTypeConstructor().supertypes) { - fromSupertypes.addAll(supertype.memberScope.getFunctions(name, NoLookupLocation.FOR_ALREADY_TRACKED)) + fromSupertypes.addAll(supertype.memberScope.getContributedFunctions(name, NoLookupLocation.FOR_ALREADY_TRACKED)) } generateFakeOverrides(name, fromSupertypes, functions) } @@ -206,7 +206,7 @@ public class DeserializedClassDescriptor( override fun computeNonDeclaredProperties(name: Name, descriptors: MutableCollection) { val fromSupertypes = ArrayList() for (supertype in classDescriptor.getTypeConstructor().supertypes) { - fromSupertypes.addAll(supertype.memberScope.getProperties(name, NoLookupLocation.FOR_ALREADY_TRACKED)) + fromSupertypes.addAll(supertype.memberScope.getContributedVariables(name, NoLookupLocation.FOR_ALREADY_TRACKED)) } generateFakeOverrides(name, fromSupertypes, descriptors) } @@ -229,12 +229,12 @@ public class DeserializedClassDescriptor( override fun addNonDeclaredDescriptors(result: MutableCollection, location: LookupLocation) { for (supertype in classDescriptor.getTypeConstructor().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 } @@ -312,7 +312,7 @@ public class DeserializedClassDescriptor( val result = HashSet() for (supertype in getTypeConstructor().getSupertypes()) { - for (descriptor in supertype.getMemberScope().getDescriptors()) { + for (descriptor in supertype.getMemberScope().getContributedDescriptors()) { if (descriptor is SimpleFunctionDescriptor || descriptor is PropertyDescriptor) { result.add(descriptor.getName()) } diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedMemberScope.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedMemberScope.kt index 8577a1aa979..25643e66977 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedMemberScope.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedMemberScope.kt @@ -82,7 +82,7 @@ public abstract class DeserializedMemberScope protected constructor( protected open fun computeNonDeclaredFunctions(name: Name, functions: MutableCollection) { } - override fun getFunctions(name: Name, location: LookupLocation): Collection { + override fun getContributedFunctions(name: Name, location: LookupLocation): Collection { recordLookup(name, location) return functions(name) } @@ -102,12 +102,12 @@ public abstract class DeserializedMemberScope protected constructor( protected open fun computeNonDeclaredProperties(name: Name, descriptors: MutableCollection) { } - override fun getProperties(name: Name, location: LookupLocation): Collection { + override fun getContributedVariables(name: Name, location: LookupLocation): Collection { recordLookup(name, location) return properties.invoke(name) } - override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? { + override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? { recordLookup(name, location) return getClassDescriptor(name) } @@ -150,12 +150,12 @@ public abstract class DeserializedMemberScope protected constructor( ) { if (kindFilter.acceptsKinds(DescriptorKindFilter.VARIABLES_MASK)) { val keys = propertyProtos().keySet().filter { nameFilter(it.name) } - addMembers(result, keys) { getProperties(it, location) } + addMembers(result, keys) { getContributedVariables(it, location) } } if (kindFilter.acceptsKinds(DescriptorKindFilter.FUNCTIONS_MASK)) { val keys = functionProtos().keySet().filter { nameFilter(it.name) } - addMembers(result, keys) { getFunctions(it, location) } + addMembers(result, keys) { getContributedFunctions(it, location) } } } diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedPackageMemberScope.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedPackageMemberScope.kt index edd98b21391..c50ac705892 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedPackageMemberScope.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedPackageMemberScope.kt @@ -46,7 +46,7 @@ public open class DeserializedPackageMemberScope( internal val classNames by c.storageManager.createLazyValue { classNames().toSet() } - override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean) + override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean) = computeDescriptors(kindFilter, nameFilter, NoLookupLocation.WHEN_GET_ALL_DESCRIPTORS) override fun getClassDescriptor(name: Name): ClassDescriptor? = diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/findClassInModule.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/findClassInModule.kt index b8b695bf63f..b392ee85d77 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/findClassInModule.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/findClassInModule.kt @@ -24,10 +24,10 @@ import org.jetbrains.kotlin.name.ClassId public fun ModuleDescriptor.findClassAcrossModuleDependencies(classId: ClassId): ClassDescriptor? { val packageViewDescriptor = getPackage(classId.packageFqName) val segments = classId.relativeClassName.pathSegments() - val topLevelClass = packageViewDescriptor.memberScope.getClassifier(segments.first(), NoLookupLocation.FROM_DESERIALIZATION) as? ClassDescriptor ?: return null + val topLevelClass = packageViewDescriptor.memberScope.getContributedClassifier(segments.first(), NoLookupLocation.FROM_DESERIALIZATION) as? ClassDescriptor ?: return null var result = topLevelClass for (name in segments.subList(1, segments.size())) { - result = result.unsubstitutedInnerClassesScope.getClassifier(name, NoLookupLocation.FROM_DESERIALIZATION) as? ClassDescriptor ?: return null + result = result.unsubstitutedInnerClassesScope.getContributedClassifier(name, NoLookupLocation.FROM_DESERIALIZATION) as? ClassDescriptor ?: return null } return result } diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KClassImpl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KClassImpl.kt index 1e01a698882..fc05f54055d 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KClassImpl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KClassImpl.kt @@ -75,12 +75,12 @@ internal class KClassImpl(override val jClass: Class) : KDeclaration @Suppress("UNCHECKED_CAST") override fun getProperties(name: Name): Collection = - (memberScope.getProperties(name, NoLookupLocation.FROM_REFLECTION) + - staticScope.getProperties(name, NoLookupLocation.FROM_REFLECTION)) as Collection + (memberScope.getContributedVariables(name, NoLookupLocation.FROM_REFLECTION) + + staticScope.getContributedVariables(name, NoLookupLocation.FROM_REFLECTION)) as Collection override fun getFunctions(name: Name): Collection = - memberScope.getFunctions(name, NoLookupLocation.FROM_REFLECTION) + - staticScope.getFunctions(name, NoLookupLocation.FROM_REFLECTION) + memberScope.getContributedFunctions(name, NoLookupLocation.FROM_REFLECTION) + + staticScope.getContributedFunctions(name, NoLookupLocation.FROM_REFLECTION) override val simpleName: String? get() { if (jClass.isAnonymousClass()) return null @@ -120,7 +120,7 @@ internal class KClassImpl(override val jClass: Class) : KDeclaration } override val nestedClasses: Collection> - get() = descriptor.unsubstitutedInnerClassesScope.getDescriptors().map { nestedClass -> + get() = descriptor.unsubstitutedInnerClassesScope.getContributedDescriptors().map { nestedClass -> val source = (nestedClass as DeclarationDescriptorWithSource).source when (source) { is KotlinJvmBinarySourceElement -> diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KDeclarationContainerImpl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KDeclarationContainerImpl.kt index 31ad837c7df..4917f6e10ca 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KDeclarationContainerImpl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KDeclarationContainerImpl.kt @@ -78,7 +78,7 @@ internal abstract class KDeclarationContainerImpl : ClassBasedDeclarationContain } } - return scope.getDescriptors().asSequence() + return scope.getContributedDescriptors().asSequence() .filter { descriptor -> descriptor !is MemberDescriptor || descriptor.getVisibility() != Visibilities.INVISIBLE_FAKE } diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KPackageImpl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KPackageImpl.kt index 7235c528fab..1e8192ab0d5 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KPackageImpl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KPackageImpl.kt @@ -45,10 +45,10 @@ internal class KPackageImpl(override val jClass: Class<*>, val moduleName: Strin @Suppress("UNCHECKED_CAST") override fun getProperties(name: Name): Collection = - scope.getProperties(name, NoLookupLocation.FROM_REFLECTION) as Collection + scope.getContributedVariables(name, NoLookupLocation.FROM_REFLECTION) as Collection override fun getFunctions(name: Name): Collection = - scope.getFunctions(name, NoLookupLocation.FROM_REFLECTION) + scope.getContributedFunctions(name, NoLookupLocation.FROM_REFLECTION) override fun equals(other: Any?): Boolean = other is KPackageImpl && jClass == other.jClass diff --git a/generators/src/org/jetbrains/kotlin/generators/evaluate/GenerateOperationsMap.kt b/generators/src/org/jetbrains/kotlin/generators/evaluate/GenerateOperationsMap.kt index 7050aa739ce..630edf603ef 100644 --- a/generators/src/org/jetbrains/kotlin/generators/evaluate/GenerateOperationsMap.kt +++ b/generators/src/org/jetbrains/kotlin/generators/evaluate/GenerateOperationsMap.kt @@ -52,12 +52,12 @@ fun generate(): String { val builtIns = TargetPlatform.Default.builtIns @Suppress("UNCHECKED_CAST") - val allPrimitiveTypes = builtIns.getBuiltInsPackageScope().getDescriptors() + val allPrimitiveTypes = builtIns.getBuiltInsPackageScope().getContributedDescriptors() .filter { it is ClassDescriptor && KotlinBuiltIns.isPrimitiveType(it.getDefaultType()) } as List for (descriptor in allPrimitiveTypes + builtIns.getString()) { @Suppress("UNCHECKED_CAST") - val functions = descriptor.getMemberScope(listOf()).getDescriptors() + val functions = descriptor.getMemberScope(listOf()).getContributedDescriptors() .filter { it is CallableDescriptor && !EXCLUDED_FUNCTIONS.contains(it.getName().asString()) } as List for (function in functions) { diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/scopeUtils.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/scopeUtils.kt index a01b8e8ed2c..aaee0e747af 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/scopeUtils.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/scopeUtils.kt @@ -42,17 +42,17 @@ public fun LexicalScope.getAllAccessibleVariables(name: Name): Collection { - return getImplicitReceiversWithInstance().flatMap { it.type.memberScope.getFunctions(name, NoLookupLocation.FROM_IDE) } + - collectFunctions(name, NoLookupLocation.FROM_IDE) + return getImplicitReceiversWithInstance().flatMap { it.type.memberScope.getContributedFunctions(name, NoLookupLocation.FROM_IDE) } + + collectFunctions(name, NoLookupLocation.FROM_IDE) } public fun LexicalScope.getVariablesFromImplicitReceivers(name: Name): Collection = getImplicitReceiversWithInstance().flatMap { - it.type.memberScope.getProperties(name, NoLookupLocation.FROM_IDE) + it.type.memberScope.getContributedVariables(name, NoLookupLocation.FROM_IDE) } public fun LexicalScope.getVariableFromImplicitReceivers(name: Name): VariableDescriptor? { getImplicitReceiversWithInstance().forEach { - it.type.memberScope.getProperties(name, NoLookupLocation.FROM_IDE).singleOrNull()?.let { return it } + it.type.memberScope.getContributedVariables(name, NoLookupLocation.FROM_IDE).singleOrNull()?.let { return it } } return null } diff --git a/idea/ide-common/src/org/jetbrains/kotlin/util/descriptorUtils.kt b/idea/ide-common/src/org/jetbrains/kotlin/util/descriptorUtils.kt index 19f5c76ac27..badc7092a8d 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/util/descriptorUtils.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/util/descriptorUtils.kt @@ -61,7 +61,7 @@ public fun descriptorsEqualWithSubstitution(descriptor1: DeclarationDescriptor?, public fun ClassDescriptor.findCallableMemberBySignature(signature: CallableMemberDescriptor): CallableMemberDescriptor? { val descriptorKind = if (signature is FunctionDescriptor) DescriptorKindFilter.FUNCTIONS else DescriptorKindFilter.VARIABLES return getDefaultType().getMemberScope() - .getDescriptors(descriptorKind) + .getContributedDescriptors(descriptorKind) .filterIsInstance() .firstOrNull { it.getContainingDeclaration() == this diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IDELightClassGenerationSupport.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IDELightClassGenerationSupport.kt index e326039759b..61284c09b54 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IDELightClassGenerationSupport.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IDELightClassGenerationSupport.kt @@ -239,14 +239,14 @@ public class IDELightClassGenerationSupport(private val project: Project) : Ligh for (declaration in file.declarations) { if (declaration is KtFunction) { val name = declaration.nameAsSafeName - val functions = packageDescriptor.memberScope.getFunctions(name, NoLookupLocation.FROM_IDE) + val functions = packageDescriptor.memberScope.getContributedFunctions(name, NoLookupLocation.FROM_IDE) for (descriptor in functions) { ForceResolveUtil.forceResolveAllContents(descriptor) } } else if (declaration is KtProperty) { val name = declaration.nameAsSafeName - val properties = packageDescriptor.memberScope.getProperties(name, NoLookupLocation.FROM_IDE) + val properties = packageDescriptor.memberScope.getContributedVariables(name, NoLookupLocation.FROM_IDE) for (descriptor in properties) { ForceResolveUtil.forceResolveAllContents(descriptor) } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/JavaResolveExtension.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/JavaResolveExtension.kt index 176a7740da6..1ec4fe8c227 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/JavaResolveExtension.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/JavaResolveExtension.kt @@ -67,7 +67,7 @@ fun PsiMember.getJavaMemberDescriptor(): DeclarationDescriptor? { } public fun JavaDescriptorResolver.resolveMethod(method: JavaMethod): FunctionDescriptor? { - return getContainingScope(method)?.getFunctions(method.name, NoLookupLocation.FROM_IDE)?.findByJavaElement(method) + return getContainingScope(method)?.getContributedFunctions(method.name, NoLookupLocation.FROM_IDE)?.findByJavaElement(method) } public fun JavaDescriptorResolver.resolveConstructor(constructor: JavaConstructor): ConstructorDescriptor? { @@ -75,7 +75,7 @@ public fun JavaDescriptorResolver.resolveConstructor(constructor: JavaConstructo } public fun JavaDescriptorResolver.resolveField(field: JavaField): PropertyDescriptor? { - return getContainingScope(field)?.getProperties(field.name, NoLookupLocation.FROM_IDE)?.findByJavaElement(field) as? PropertyDescriptor + return getContainingScope(field)?.getContributedVariables(field.name, NoLookupLocation.FROM_IDE)?.findByJavaElement(field) as? PropertyDescriptor } private fun JavaDescriptorResolver.getContainingScope(member: JavaMember): MemberScope? { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextFactory.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextFactory.kt index 9b0fac5606c..f36df70457b 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextFactory.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextFactory.kt @@ -199,7 +199,7 @@ public fun buildDecompiledText( } } - val allDescriptors = descriptor.secondaryConstructors + descriptor.defaultType.memberScope.getDescriptors() + val allDescriptors = descriptor.secondaryConstructors + descriptor.defaultType.memberScope.getContributedDescriptors() val (enumEntries, members) = allDescriptors.partition(::isEnumEntry) for ((index, enumEntry) in enumEntries.withIndex()) { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/DeserializerForClassfileDecompiler.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/DeserializerForClassfileDecompiler.kt index 60151d1914c..2d80f6f7075 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/DeserializerForClassfileDecompiler.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/DeserializerForClassfileDecompiler.kt @@ -77,7 +77,7 @@ public class DeserializerForClassfileDecompiler( val membersScope = DeserializedPackageMemberScope( createDummyPackageFragment(packageFqName), packageProto, nameResolver, deserializationComponents ) { emptyList() } - return membersScope.getDescriptors() + return membersScope.getContributedDescriptors() } companion object { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/KotlinJavaScriptDeserializerForDecompiler.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/KotlinJavaScriptDeserializerForDecompiler.kt index 7cb1551ec9b..2d55be008eb 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/KotlinJavaScriptDeserializerForDecompiler.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/KotlinJavaScriptDeserializerForDecompiler.kt @@ -75,7 +75,7 @@ public class KotlinJavaScriptDeserializerForDecompiler( val membersScope = DeserializedPackageMemberScope( createDummyPackageFragment(packageFqName), packageProto, nameResolver, deserializationComponents ) { emptyList() } - return membersScope.getDescriptors() + return membersScope.getContributedDescriptors() } companion object { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/missingDependencies.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/missingDependencies.kt index e1edc0d8574..7c172faaa9e 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/missingDependencies.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/missingDependencies.kt @@ -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: LookupLocation): ClassifierDescriptor? { + override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? { return MissingDependencyErrorClassDescriptor(getContainingDeclaration(), fqName.child(name)) } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/BuiltInsReferenceResolver.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/BuiltInsReferenceResolver.kt index 898bec5f6d9..c2bbd9a386e 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/BuiltInsReferenceResolver.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/BuiltInsReferenceResolver.kt @@ -108,7 +108,7 @@ public class BuiltInsReferenceResolver(val project: Project, val startupManager: containingDeclaration.getConstructors() } else { - memberScope.getDescriptors() + memberScope.getContributedDescriptors() } return descriptors.firstOrNull { renderedOriginal == DescriptorRenderer.FQ_NAMES_IN_TYPES.render(it) } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/structureView/KotlinInheritedMembersNodeProvider.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/structureView/KotlinInheritedMembersNodeProvider.kt index 30c72030f16..e9c3c008c2e 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/structureView/KotlinInheritedMembersNodeProvider.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/structureView/KotlinInheritedMembersNodeProvider.kt @@ -45,7 +45,7 @@ public class KotlinInheritedMembersNodeProvider: InheritedMembersNodeProvider() val defaultType = descriptor.getDefaultType() - for (memberDescriptor in defaultType.getMemberScope().getDescriptors()) { + for (memberDescriptor in defaultType.getMemberScope().getContributedDescriptors()) { if (memberDescriptor !is CallableMemberDescriptor) continue when (memberDescriptor.getKind()) { diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/PackageDirectiveCompletion.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/PackageDirectiveCompletion.kt index 258352f895f..49825352a5e 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/PackageDirectiveCompletion.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/PackageDirectiveCompletion.kt @@ -54,7 +54,7 @@ object PackageDirectiveCompletion { val packageMemberScope = resolutionFacade.moduleDescriptor.getPackage(file.packageFqName.parent()).memberScope - val variants = packageMemberScope.getDescriptors(DescriptorKindFilter.PACKAGES, prefixMatcher.asNameFilter()) + val variants = packageMemberScope.getContributedDescriptors(DescriptorKindFilter.PACKAGES, prefixMatcher.asNameFilter()) val lookupElementFactory = BasicLookupElementFactory(resolutionFacade.project, InsertHandlerProvider(callType = CallType.PACKAGE_DIRECTIVE, expectedInfosCalculator = { emptyList() })) for (variant in variants) { val lookupElement = lookupElementFactory.createLookupElement(variant) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/StaticMembers.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/StaticMembers.kt index 2047ee517d7..dc477b0543c 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/StaticMembers.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/StaticMembers.kt @@ -90,16 +90,16 @@ class StaticMembers( } } - classDescriptor.getStaticScope().getDescriptors().forEach(::processMember) + classDescriptor.getStaticScope().getContributedDescriptors().forEach(::processMember) val companionObject = classDescriptor.getCompanionObjectDescriptor() if (companionObject != null) { - companionObject.getDefaultType().getMemberScope().getDescriptors() + companionObject.getDefaultType().getMemberScope().getContributedDescriptors() .filter { !it.isExtension } .forEach(::processMember) } - var members = classDescriptor.getDefaultType().getMemberScope().getDescriptors() + var members = classDescriptor.getDefaultType().getMemberScope().getContributedDescriptors() if (classDescriptor.getKind() != ClassKind.ENUM_CLASS) { members = members.filter { DescriptorUtils.isNonCompanionObject(it) } } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypeInstantiationItems.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypeInstantiationItems.kt index 10a6626d7c3..3d17366c0be 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypeInstantiationItems.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypeInstantiationItems.kt @@ -278,7 +278,7 @@ class TypeInstantiationItems( is ClassDescriptor -> container.getStaticScope() else -> return } - val samConstructor = scope.getFunctions(`class`.name, NoLookupLocation.FROM_IDE) + val samConstructor = scope.getContributedFunctions(`class`.name, NoLookupLocation.FROM_IDE) .filterIsInstance() .singleOrNull() ?: return lookupElementFactory.createLookupElementsInSmartCompletion(samConstructor, bindingContext, useReceiverTypes = false) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypesWithContainsDetector.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypesWithContainsDetector.kt index d6933667e24..56ceed4c4e0 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypesWithContainsDetector.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypesWithContainsDetector.kt @@ -53,7 +53,7 @@ class TypesWithContainsDetector( private fun hasContainsNoCache(type: FuzzyType): Boolean { return type.nullability() != TypeNullability.NULLABLE && - type.type.memberScope.getFunctions(containsName, NoLookupLocation.FROM_IDE).any { isGoodContainsFunction(it, type.freeParameters) } + type.type.memberScope.getContributedFunctions(containsName, NoLookupLocation.FROM_IDE).any { isGoodContainsFunction(it, type.freeParameters) } || typesWithExtensionContains.any { type.checkIsSubtypeOf(it) != null } } diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/IterableTypesDetection.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/IterableTypesDetection.kt index 709176d28d1..8f75333a51e 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/IterableTypesDetection.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/IterableTypesDetection.kt @@ -79,7 +79,7 @@ public class IterableTypesDetection( } private fun canBeIterable(type: FuzzyType): Boolean { - return type.type.memberScope.getFunctions(iteratorName, NoLookupLocation.FROM_IDE).isNotEmpty() || + return type.type.memberScope.getContributedFunctions(iteratorName, NoLookupLocation.FROM_IDE).isNotEmpty() || typesWithExtensionIterator.any { type.checkIsSubtypeOf(it) != null } } } diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/overrideImplement/OverrideMembersHandler.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/overrideImplement/OverrideMembersHandler.kt index c8b91df8359..7b3968c1bc8 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/overrideImplement/OverrideMembersHandler.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/overrideImplement/OverrideMembersHandler.kt @@ -26,7 +26,7 @@ import java.util.* public class OverrideMembersHandler : OverrideImplementMembersHandler() { override fun collectMembersToGenerate(descriptor: ClassDescriptor, project: Project): Collection { val result = ArrayList() - for (member in descriptor.unsubstitutedMemberScope.getDescriptors()) { + for (member in descriptor.unsubstitutedMemberScope.getContributedDescriptors()) { if (member is CallableMemberDescriptor && (member.kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE || member.kind == CallableMemberDescriptor.Kind.DELEGATION)) { val overridden = member.overriddenDescriptors diff --git a/idea/src/org/jetbrains/kotlin/idea/actions/generate/KotlinGenerateEqualsAndHashcodeAction.kt b/idea/src/org/jetbrains/kotlin/idea/actions/generate/KotlinGenerateEqualsAndHashcodeAction.kt index 495d4a55d9d..1c65166da71 100644 --- a/idea/src/org/jetbrains/kotlin/idea/actions/generate/KotlinGenerateEqualsAndHashcodeAction.kt +++ b/idea/src/org/jetbrains/kotlin/idea/actions/generate/KotlinGenerateEqualsAndHashcodeAction.kt @@ -56,7 +56,7 @@ private tailrec fun ClassDescriptor.findDeclaredFunction ( filter: (FunctionDescriptor) -> Boolean ): FunctionDescriptor? { unsubstitutedMemberScope - .getFunctions(Name.identifier(name), NoLookupLocation.FROM_IDE) + .getContributedFunctions(Name.identifier(name), NoLookupLocation.FROM_IDE) .firstOrNull { it.containingDeclaration == this && it.kind == CallableMemberDescriptor.Kind.DECLARATION && filter(it) } ?.let { return it } diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantSamConstructorInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantSamConstructorInspection.kt index bd42b2ef1c3..3f0cbe47ad2 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantSamConstructorInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantSamConstructorInspection.kt @@ -174,7 +174,7 @@ public class RedundantSamConstructorInspection : AbstractKotlinInspection() { val containingClass = originalFunctionDescriptor.containingDeclaration as? ClassDescriptor ?: return emptyList() // SAM adapters for static functions - for (staticFunWithSameName in containingClass.staticScope.getFunctions(functionResolvedCall.resultingDescriptor.name, NoLookupLocation.FROM_IDE)) { + for (staticFunWithSameName in containingClass.staticScope.getContributedFunctions(functionResolvedCall.resultingDescriptor.name, NoLookupLocation.FROM_IDE)) { if (staticFunWithSameName is SamAdapterDescriptor<*>) { if (isSamAdapterSuitableForCall(staticFunWithSameName, originalFunctionDescriptor, samConstructorCallArguments.size())) { return samConstructorCallArguments.check { canBeReplaced(functionCall, it) } ?: emptyList() diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeMemberFunctionSignatureFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeMemberFunctionSignatureFix.kt index 76325d76ff0..a981bcf10b1 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeMemberFunctionSignatureFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeMemberFunctionSignatureFix.kt @@ -179,7 +179,7 @@ class ChangeMemberFunctionSignatureFix private constructor( val name = functionDescriptor.name return containingClass.defaultType.supertypes() - .flatMap { supertype -> supertype.memberScope.getFunctions(name, NoLookupLocation.FROM_IDE) } + .flatMap { supertype -> supertype.memberScope.getContributedFunctions(name, NoLookupLocation.FROM_IDE) } .filter { it.kind.isReal && it.modality.isOverridable } } } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/ExclExclCallFixes.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/ExclExclCallFixes.kt index ffcc5538b15..36d4f78564d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/ExclExclCallFixes.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/ExclExclCallFixes.kt @@ -126,7 +126,7 @@ object MissingIteratorExclExclFixFactory : KotlinSingleIntentionActionFactory() if (descriptor !is ClassDescriptor) return false val memberScope = descriptor.unsubstitutedMemberScope - val functions = memberScope.getFunctions(OperatorNameConventions.ITERATOR, NoLookupLocation.FROM_IDE) + val functions = memberScope.getContributedFunctions(OperatorNameConventions.ITERATOR, NoLookupLocation.FROM_IDE) return functions.any { it.isOperator() && OperatorChecks.canBeOperator(it) } } diff --git a/idea/src/org/jetbrains/kotlin/idea/util/ImportInsertHelperImpl.kt b/idea/src/org/jetbrains/kotlin/idea/util/ImportInsertHelperImpl.kt index a06edaf61b2..97c19aedf0d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/util/ImportInsertHelperImpl.kt +++ b/idea/src/org/jetbrains/kotlin/idea/util/ImportInsertHelperImpl.kt @@ -237,7 +237,7 @@ public class ImportInsertHelperImpl(private val project: Project) : ImportInsert val topLevelScope = resolutionFacade.getFileResolutionScope(file) val conflictCandidates: List = classNamesToImport .flatMap { - importedScopes.map { scope -> scope.getClassifier(it, NoLookupLocation.FROM_IDE) }.filterNotNull() + importedScopes.map { scope -> scope.getContributedClassifier(it, NoLookupLocation.FROM_IDE) }.filterNotNull() } .filter { importedClass -> isVisible(importedClass) @@ -272,7 +272,7 @@ public class ImportInsertHelperImpl(private val project: Project) : ImportInsert } val parentScope = getMemberScope(fqName.parent(), moduleDescriptor) ?: return null - val classifier = parentScope.getClassifier(fqName.shortName(), NoLookupLocation.FROM_IDE) + val classifier = parentScope.getContributedClassifier(fqName.shortName(), NoLookupLocation.FROM_IDE) val classDescriptor = classifier as? ClassDescriptor ?: return null return classDescriptor.getDefaultType().getMemberScope() } diff --git a/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/TextConsistencyBaseTest.kt b/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/TextConsistencyBaseTest.kt index 25a6c88b632..cac65cf6775 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/TextConsistencyBaseTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/TextConsistencyBaseTest.kt @@ -79,7 +79,7 @@ public abstract class TextConsistencyBaseTest : KotlinLightCodeInsightFixtureTes module.resolveTopLevelClass(classId.asSingleFqName(), NoLookupLocation.FROM_TEST) override fun resolveDeclarationsInFacade(facadeFqName: FqName): Collection = - module.getPackage(facadeFqName.parent()).memberScope.getDescriptors().filter { + module.getPackage(facadeFqName.parent()).memberScope.getContributedDescriptors().filter { it is CallableMemberDescriptor && it.module != module.builtIns.builtInsModule && isFromFacade(it, facadeFqName) diff --git a/idea/tests/org/jetbrains/kotlin/idea/kdoc/KDocFinderTest.kt b/idea/tests/org/jetbrains/kotlin/idea/kdoc/KDocFinderTest.kt index ad4a83be57a..4ea3f08c587 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/kdoc/KDocFinderTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/kdoc/KDocFinderTest.kt @@ -43,7 +43,7 @@ public class KDocFinderTest() : LightPlatformCodeInsightFixtureTestCase() { myFixture.configureByFile(getTestName(false) + ".kt") val declaration = (myFixture.getFile() as KtFile).getDeclarations().single { it.getName() == "Bar" } val descriptor = declaration.resolveToDescriptor() as ClassDescriptor - val overriddenFunctionDescriptor = descriptor.defaultType.memberScope.getFunctions(Name.identifier("xyzzy"), NoLookupLocation.FROM_TEST).single() + val overriddenFunctionDescriptor = descriptor.defaultType.memberScope.getContributedFunctions(Name.identifier("xyzzy"), NoLookupLocation.FROM_TEST).single() val doc = KDocFinder.findKDoc(overriddenFunctionDescriptor) Assert.assertEquals("Doc for method xyzzy", doc!!.getContent()) } @@ -52,7 +52,7 @@ public class KDocFinderTest() : LightPlatformCodeInsightFixtureTestCase() { myFixture.configureByFile(getTestName(false) + ".kt") val declaration = (myFixture.getFile() as KtFile).getDeclarations().single { it.getName() == "Bar" } val descriptor = declaration.resolveToDescriptor() as ClassDescriptor - val overriddenFunctionDescriptor = descriptor.defaultType.memberScope.getFunctions(Name.identifier("xyzzy"), NoLookupLocation.FROM_TEST).single() + val overriddenFunctionDescriptor = descriptor.defaultType.memberScope.getContributedFunctions(Name.identifier("xyzzy"), NoLookupLocation.FROM_TEST).single() val doc = KDocFinder.findKDoc(overriddenFunctionDescriptor) Assert.assertEquals("Doc for method xyzzy", doc!!.getContent()) } @@ -61,7 +61,7 @@ public class KDocFinderTest() : LightPlatformCodeInsightFixtureTestCase() { myFixture.configureByFile(getTestName(false) + ".kt") val declaration = (myFixture.getFile() as KtFile).getDeclarations().single { it.getName() == "Foo" } val descriptor = declaration.resolveToDescriptor() as ClassDescriptor - val propertyDescriptor = descriptor.defaultType.memberScope.getProperties(Name.identifier("xyzzy"), NoLookupLocation.FROM_TEST).single() + val propertyDescriptor = descriptor.defaultType.memberScope.getContributedVariables(Name.identifier("xyzzy"), NoLookupLocation.FROM_TEST).single() val doc = KDocFinder.findKDoc(propertyDescriptor) Assert.assertEquals("Doc for property xyzzy", doc!!.getContent()) } diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/AbstractRenameTest.kt b/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/AbstractRenameTest.kt index b05bd221229..f6bad0a5a22 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/AbstractRenameTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/AbstractRenameTest.kt @@ -198,13 +198,13 @@ public abstract class AbstractRenameTest : KotlinMultiFileTestCase() { private fun renameKotlinFunctionTest(renameParamsObject: JsonObject, context: TestContext) { val oldMethodName = Name.identifier(renameParamsObject.getString("oldName")) - doRenameInKotlinClassOrPackage(renameParamsObject, context) { it.getFunctions(oldMethodName, NoLookupLocation.FROM_TEST).first() } + doRenameInKotlinClassOrPackage(renameParamsObject, context) { it.getContributedFunctions(oldMethodName, NoLookupLocation.FROM_TEST).first() } } private fun renameKotlinPropertyTest(renameParamsObject: JsonObject, context: TestContext) { val oldPropertyName = Name.identifier(renameParamsObject.getString("oldName")) - doRenameInKotlinClassOrPackage(renameParamsObject, context) { it.getProperties(oldPropertyName, NoLookupLocation.FROM_TEST).first() } + doRenameInKotlinClassOrPackage(renameParamsObject, context) { it.getContributedVariables(oldPropertyName, NoLookupLocation.FROM_TEST).first() } } private fun renameKotlinClassTest(renameParamsObject: JsonObject, context: TestContext) { diff --git a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/ClassSerializationUtil.kt b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/ClassSerializationUtil.kt index efa03d072ed..1389cf6ce09 100644 --- a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/ClassSerializationUtil.kt +++ b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/ClassSerializationUtil.kt @@ -32,7 +32,7 @@ public object ClassSerializationUtil { val classProto = serializer.classProto(classDescriptor).build() ?: error("Class not serialized: $classDescriptor") sink.writeClass(classDescriptor, classProto) - serializeClasses(classDescriptor.getUnsubstitutedInnerClassesScope().getDescriptors(), serializer, sink, skip) + serializeClasses(classDescriptor.getUnsubstitutedInnerClassesScope().getContributedDescriptors(), serializer, sink, skip) } public fun serializeClasses(descriptors: Collection, serializer: DescriptorSerializer, sink: Sink, skip: (DeclarationDescriptor) -> Boolean) { diff --git a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptSerializationUtil.kt b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptSerializationUtil.kt index 51882a083a1..7128b3f2bbf 100644 --- a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptSerializationUtil.kt +++ b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptSerializationUtil.kt @@ -108,7 +108,7 @@ public object KotlinJavascriptSerializationUtil { val serializerExtension = KotlinJavascriptSerializerExtension() val serializer = DescriptorSerializer.createTopLevel(serializerExtension) - val classifierDescriptors = DescriptorSerializer.sort(packageView.memberScope.getDescriptors(DescriptorKindFilter.CLASSIFIERS)) + val classifierDescriptors = DescriptorSerializer.sort(packageView.memberScope.getContributedDescriptors(DescriptorKindFilter.CLASSIFIERS)) ClassSerializationUtil.serializeClasses(classifierDescriptors, serializer, object : ClassSerializationUtil.Sink { override fun writeClass(classDescriptor: ClassDescriptor, classProto: ProtoBuf.Class) { @@ -146,7 +146,7 @@ public object KotlinJavascriptSerializationUtil { writeFun: (String, ByteArray) -> Unit ) { val classes = packageFragments.flatMap { - it.getMemberScope().getDescriptors(DescriptorKindFilter.CLASSIFIERS).filterIsInstance() + it.getMemberScope().getContributedDescriptors(DescriptorKindFilter.CLASSIFIERS).filterIsInstance() }.filter { !skip(it) } val builder = JsProtoBuf.Classes.newBuilder() @@ -193,7 +193,7 @@ public object KotlinJavascriptSerializationUtil { result.add(fqName) } - for (descriptor in packageView.memberScope.getDescriptors(DescriptorKindFilter.PACKAGES, MemberScope.ALL_NAME_FILTER)) { + for (descriptor in packageView.memberScope.getContributedDescriptors(DescriptorKindFilter.PACKAGES, MemberScope.ALL_NAME_FILTER)) { if (descriptor is PackageViewDescriptor) { getSubPackagesFqNames(descriptor, result) } diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/ClassTranslator.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/ClassTranslator.kt index 611ea1676a6..0ba5cda844b 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/ClassTranslator.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/ClassTranslator.kt @@ -240,7 +240,7 @@ public class ClassTranslator private constructor( } private fun generateOtherBridges(properties: MutableList) { - for (memberDescriptor in descriptor.getDefaultType().getMemberScope().getDescriptors()) { + for (memberDescriptor in descriptor.getDefaultType().getMemberScope().getContributedDescriptors()) { if (memberDescriptor is FunctionDescriptor) { val bridgesToGenerate = generateBridgesForFunctionDescriptor(memberDescriptor, identity()) diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/ManglingUtils.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/ManglingUtils.java index f8be8c13184..4798229a8f3 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/ManglingUtils.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/ManglingUtils.java @@ -245,7 +245,7 @@ public class ManglingUtils { @NotNull public static String getStableMangledNameForDescriptor(@NotNull ClassDescriptor descriptor, @NotNull String functionName) { Collection functions = - descriptor.getDefaultType().getMemberScope().getFunctions(Name.identifier(functionName), NoLookupLocation.FROM_BACKEND); + descriptor.getDefaultType().getMemberScope().getContributedFunctions(Name.identifier(functionName), NoLookupLocation.FROM_BACKEND); assert functions.size() == 1 : "Can't select a single function: " + functionName + " in " + descriptor; return getSuggestedName((DeclarationDescriptor) functions.iterator().next()); } diff --git a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/codegen/AndroidExpressionCodegenExtension.kt b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/codegen/AndroidExpressionCodegenExtension.kt index 88f05e4c745..18c7dd9f06c 100644 --- a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/codegen/AndroidExpressionCodegenExtension.kt +++ b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/codegen/AndroidExpressionCodegenExtension.kt @@ -248,7 +248,7 @@ public class AndroidExpressionCodegenExtension : ExpressionCodegenExtension { context.generateClearCacheFunction() if (androidClassType.fragment) { - val classMembers = descriptor.unsubstitutedMemberScope.getDescriptors() + val classMembers = descriptor.unsubstitutedMemberScope.getContributedDescriptors() val onDestroy = classMembers.firstOrNull { it is FunctionDescriptor && it.isOnDestroyFunction() } if (onDestroy == null) { context.generateOnDestroyFunctionForFragment()