Refactoring: don't register scopes explicitly, get them from scope provider on demand

This commit is contained in:
Nikolay Krasko
2015-05-18 15:03:45 +03:00
parent b81d8eb484
commit 980a0d19be
6 changed files with 28 additions and 39 deletions
@@ -319,11 +319,9 @@ public abstract class ElementResolver protected constructor(
bodyResolver.resolvePropertyDelegate(DataFlowInfo.EMPTY, jetProperty, descriptor, propertyDelegate, propertyResolutionScope, propertyResolutionScope)
}
val bodyResolveContext = BodyResolveContextForLazy(TopDownAnalysisMode.LocalDeclarations, object : Function<JetDeclaration, JetScope> {
override fun apply(declaration: JetDeclaration?): JetScope? {
assert(declaration!!.getParent() == jetProperty) { "Must be called only for property accessors, but called for " + declaration }
return resolveSession.getScopeProvider().getResolutionScopeForDeclaration(declaration)
}
val bodyResolveContext = BodyResolveContextForLazy(TopDownAnalysisMode.LocalDeclarations, { declaration ->
assert(declaration.getParent() == jetProperty) { "Must be called only for property accessors, but called for $declaration" }
resolveSession.getScopeProvider().getResolutionScopeForDeclaration(declaration)
})
bodyResolver.resolvePropertyAccessors(bodyResolveContext, jetProperty, descriptor)
@@ -446,9 +444,8 @@ public abstract class ElementResolver protected constructor(
private class BodyResolveContextForLazy(
private val topDownAnalysisMode: TopDownAnalysisMode,
private val declaringScopes: Function<in JetDeclaration, JetScope>
private val declaringScopes: Function1<JetDeclaration, JetScope?>
) : BodiesResolveContext {
override fun getFiles(): Collection<JetFile> = setOf()
override fun getDeclaredClasses(): Map<JetClassOrObject, ClassDescriptorWithResolutionScopes> = mapOf()
@@ -461,11 +458,11 @@ public abstract class ElementResolver protected constructor(
override fun getFunctions(): Map<JetNamedFunction, SimpleFunctionDescriptor> = mapOf()
override fun getDeclaringScopes() = declaringScopes as Function<JetDeclaration, JetScope>
override fun getDeclaringScope(declaration: JetDeclaration): JetScope? = declaringScopes(declaration)
override fun getScripts(): Map<JetScript, ScriptDescriptor> = mapOf()
override fun getOuterDataFlowInfo() = DataFlowInfo.EMPTY
override fun getOuterDataFlowInfo(): DataFlowInfo = DataFlowInfo.EMPTY
override fun getTopDownAnalysisMode() = topDownAnalysisMode
}