Replace function MemberScope.getContainingDeclaration() to property ownerDescriptor

This commit is contained in:
Stanislav Erokhin
2015-11-04 15:29:33 +03:00
parent 52dc23012f
commit c4582d0e0c
32 changed files with 86 additions and 90 deletions
@@ -104,7 +104,7 @@ public fun resolvePossiblyAmbiguousCallableReference(
fun resolveInScope(traceTitle: String, staticScope: MemberScope): OverloadResolutionResults<CallableDescriptor> {
// todo: drop this class when new resolve will be finished
class StaticScopeAsLexicalScope(val staticScope: MemberScope) : BaseLexicalScope(staticScope.memberScopeAsImportingScope(), staticScope.getContainingDeclaration()) {
class StaticScopeAsLexicalScope(val staticScope: MemberScope) : BaseLexicalScope(staticScope.memberScopeAsImportingScope(), staticScope.ownerDescriptor) {
override fun printStructure(p: Printer) {
p.println(toString())
}
@@ -44,7 +44,7 @@ class DynamicCallableDescriptors(private val builtIns: KotlinBuiltIns) {
val dynamicType = createDynamicType(builtIns)
fun createDynamicDescriptorScope(call: Call, owner: DeclarationDescriptor) = object : MemberScopeImpl() {
override fun getContainingDeclaration() = owner
override val ownerDescriptor: DeclarationDescriptor get() = owner
override fun printScopeStructure(p: Printer) {
p.println(javaClass.getSimpleName(), ": dynamic candidates for " + call)
@@ -86,7 +86,7 @@ public class ResolveSessionUtils {
scope = ((ClassDescriptor) classifier).getUnsubstitutedInnerClassesScope();
}
return (ClassDescriptor) scope.getContainingDeclaration();
return (ClassDescriptor) scope.getOwnerDescriptor();
}
@NotNull
@@ -59,7 +59,7 @@ protected constructor(
}.toReadOnlyList()
}
override fun getContainingDeclaration() = thisDescriptor
override val ownerDescriptor: DeclarationDescriptor get() = thisDescriptor
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassDescriptor? {
recordLookup(name, location)
@@ -23,9 +23,10 @@ import org.jetbrains.kotlin.utils.Printer
public class FilteringScope(private val workerScope: MemberScope, private val predicate: (DeclarationDescriptor) -> Boolean) : MemberScope {
override fun getContributedFunctions(name: Name, location: LookupLocation) = workerScope.getContributedFunctions(name, location).filter(predicate)
override val ownerDescriptor: DeclarationDescriptor
get() = workerScope.ownerDescriptor
override fun getContainingDeclaration() = workerScope.getContainingDeclaration()
override fun getContributedFunctions(name: Name, location: LookupLocation) = workerScope.getContributedFunctions(name, location).filter(predicate)
private fun <D : DeclarationDescriptor> filterDescriptor(descriptor: D?): D?
= if (descriptor != null && predicate(descriptor)) descriptor else null
@@ -116,7 +116,7 @@ public fun HierarchicalScope.takeSnapshot(): HierarchicalScope = if (this is Lex
public fun MemberScope.memberScopeAsImportingScope(parentScope: ImportingScope? = null): ImportingScope = MemberScopeToImportingScopeAdapter(parentScope, this)
@Deprecated("Temporary method for scope migration")
public fun MemberScope.memberScopeAsLexicalScope(): LexicalScope = LexicalScope.empty(memberScopeAsImportingScope(), getContainingDeclaration())
public fun MemberScope.memberScopeAsLexicalScope(): LexicalScope = LexicalScope.empty(memberScopeAsImportingScope(), ownerDescriptor)
private class MemberScopeToImportingScopeAdapter(override val parent: ImportingScope?, val memberScope: MemberScope) : ImportingScope {
override fun getContributedPackage(name: Name): PackageViewDescriptor? = memberScope.getPackage(name)
@@ -161,7 +161,7 @@ public class TypeIntersector {
@NotNull
@Override
public DeclarationDescriptor getContainingDeclaration() {
public DeclarationDescriptor getOwnerDescriptor() {
throw new UnsupportedOperationException("Should not call getContainingDeclaration on intersection scope " + this);
}
}