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 13e06126e32..6a11e244f72 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/LexicalChainedScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/LexicalChainedScope.kt @@ -38,7 +38,8 @@ public class LexicalChainedScope( override val parent = parent.takeSnapshot() private val scopeChain = memberScopes.clone() - override fun getContributedDescriptors() = getFromAllScopes(scopeChain) { it.getAllDescriptors() } + override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean) + = getFromAllScopes(scopeChain) { it.getAllDescriptors() } override fun getContributedClassifier(name: Name, location: LookupLocation) = getFirstMatch(scopeChain) { it.getClassifier(name, location) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/LexicalScopeImpl.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/LexicalScopeImpl.kt index a13ed5524ee..c3c1b7d166f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/LexicalScopeImpl.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/LexicalScopeImpl.kt @@ -44,7 +44,7 @@ public class LexicalScopeImpl @JvmOverloads constructor( InitializeHandler(redeclarationHandler).initialize() } - override fun getContributedDescriptors() = addedDescriptors + override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean) = addedDescriptors override fun getContributedClassifier(name: Name, location: LookupLocation) = getDeclaredClassifier(name) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/LexicalWritableScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/LexicalWritableScope.kt index 756077b3a5d..6cebf02c255 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/LexicalWritableScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/LexicalWritableScope.kt @@ -70,7 +70,8 @@ class LexicalWritableScope( addVariableOrClassDescriptor(classifierDescriptor) } - override fun getContributedDescriptors() = checkMayRead().addedDescriptors + override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean) + = checkMayRead().addedDescriptors override fun getContributedClassifier(name: Name, location: LookupLocation) = checkMayRead().getDeclaredClassifier(name) @@ -101,7 +102,8 @@ class LexicalWritableScope( override val implicitReceiver: ReceiverParameterDescriptor? get() = this@LexicalWritableScope.implicitReceiver - override fun getContributedDescriptors() = this@LexicalWritableScope.addedDescriptors.subList(0, descriptorLimit) + override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean) + = this@LexicalWritableScope.addedDescriptors.subList(0, descriptorLimit) override fun getContributedClassifier(name: Name, location: LookupLocation) = this@LexicalWritableScope.getDeclaredClassifier(name, descriptorLimit) 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 4b499b1d384..7aec4e67828 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 @@ -226,8 +226,6 @@ private class MemberScopeToImportingScopeAdapter(override val parent: ImportingS override val ownerDescriptor: DeclarationDescriptor get() = memberScope.getContainingDeclaration() - override fun getContributedDescriptors() = memberScope.getOwnDeclaredDescriptors() - override fun getContributedClassifier(name: Name, location: LookupLocation) = memberScope.getClassifier(name, location) override fun getContributedVariables(name: Name, location: LookupLocation) = memberScope.getProperties(name, location) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/Scopes.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/Scopes.kt index 271fe812ee6..1dd7f9c1f4c 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/Scopes.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/Scopes.kt @@ -36,12 +36,10 @@ interface LexicalScope { * 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). */ - open fun getContributedDescriptors( + fun getContributedDescriptors( kindFilter: DescriptorKindFilter = DescriptorKindFilter.ALL, nameFilter: (Name) -> Boolean = KtScope.ALL_NAME_FILTER - ): Collection = getContributedDescriptors() - - fun getContributedDescriptors(): Collection + ): Collection fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? @@ -64,7 +62,7 @@ interface LexicalScope { override val implicitReceiver: ReceiverParameterDescriptor? get() = null - override fun getContributedDescriptors(): Collection = emptyList() + override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection = emptyList() override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? = null @@ -96,13 +94,6 @@ interface ImportingScope : LexicalScope { fun getContributedSyntheticExtensionProperties(receiverTypes: Collection): Collection fun getContributedSyntheticExtensionFunctions(receiverTypes: Collection): Collection - // please, do not override this method - override fun getContributedDescriptors(): Collection { - return getContributedDescriptors(DescriptorKindFilter.ALL, { true }) - } - - override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection - object Empty : ImportingScope, LexicalScope by LexicalScope.Empty { override fun getContributedPackage(name: Name) = null