From 2791d99f9d3ea10496703149f31fd6f2220ab614 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Tue, 19 Jan 2016 16:04:01 +0300 Subject: [PATCH] Direct implementation of ImportingScope --- .../resolve/lazy/FileScopeProviderImpl.kt | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/FileScopeProviderImpl.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/FileScopeProviderImpl.kt index 9759a6f3df4..c3a941ababa 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/FileScopeProviderImpl.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/FileScopeProviderImpl.kt @@ -95,8 +95,7 @@ open class FileScopeProviderImpl( scope = LazyImportScope(scope, allUnderImportResolver, LazyImportScope.FilteringKind.INVISIBLE_CLASSES, "All under imports in $debugName (invisible classes only)") - scope = currentPackageScope(packageView, aliasImportNames, dummyContainerDescriptor, FilteringKind.INVISIBLE_CLASSES) - .memberScopeAsImportingScope(scope) + scope = currentPackageScope(packageView, aliasImportNames, dummyContainerDescriptor, FilteringKind.INVISIBLE_CLASSES, scope) scope = LazyImportScope(scope, defaultAllUnderImportResolver, LazyImportScope.FilteringKind.VISIBLE_CLASSES, "Default all under imports in $debugName (visible classes)") @@ -109,8 +108,7 @@ open class FileScopeProviderImpl( scope = SubpackagesImportingScope(scope, moduleDescriptor, FqName.ROOT) - scope = currentPackageScope(packageView, aliasImportNames, dummyContainerDescriptor, FilteringKind.VISIBLE_CLASSES) - .memberScopeAsImportingScope(scope) + scope = currentPackageScope(packageView, aliasImportNames, dummyContainerDescriptor, FilteringKind.VISIBLE_CLASSES, scope) scope = LazyImportScope(scope, explicitImportResolver, LazyImportScope.FilteringKind.ALL, "Explicit imports in $debugName") @@ -145,13 +143,18 @@ open class FileScopeProviderImpl( packageView: PackageViewDescriptor, aliasImportNames: Collection, fromDescriptor: DummyContainerDescriptor, - filteringKind: FilteringKind - ): MemberScope { + filteringKind: FilteringKind, + parentScope: ImportingScope + ): ImportingScope { val scope = packageView.memberScope val packageName = packageView.fqName val excludedNames = aliasImportNames.mapNotNull { if (it.parent() == packageName) it.shortName() else null } - return object: MemberScope { + return object: ImportingScope { + override val parent: ImportingScope? = parentScope + + override fun getContributedPackage(name: Name) = null + override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? { if (name in excludedNames) return null val classifier = scope.getContributedClassifier(name, location) ?: return null @@ -179,7 +182,7 @@ open class FileScopeProviderImpl( override fun toString() = "Scope for current package (${filteringKind.name})" - override fun printScopeStructure(p: Printer) { + override fun printStructure(p: Printer) { p.println(this.toString()) } }