From cee38e080055b2672063fb1229c765a4103571cb Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Fri, 8 May 2020 10:48:13 +0300 Subject: [PATCH] FIR: Implement FirScopeProvider.getStaticScope It will be used in the following commits --- .../kotlin/fir/scopes/FirScopeProvider.kt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/scopes/FirScopeProvider.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/scopes/FirScopeProvider.kt index 0e7c4a4c813..2ff24ba35c2 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/scopes/FirScopeProvider.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/scopes/FirScopeProvider.kt @@ -27,4 +27,21 @@ abstract class FirScopeProvider { useSiteSession: FirSession, scopeSession: ScopeSession ): FirScope? + + fun getStaticScope( + klass: FirClass<*>, + useSiteSession: FirSession, + scopeSession: ScopeSession + ): FirScope? { + val nestedClassifierScope = getNestedClassifierScope(klass, useSiteSession, scopeSession) + val callableScope = getStaticMemberScopeForCallables(klass, useSiteSession, scopeSession) + + return when { + nestedClassifierScope != null && callableScope != null -> + FirReadOnlyCompositeScope(listOf(nestedClassifierScope, callableScope)) + else -> nestedClassifierScope ?: callableScope + } + } } + +private class FirReadOnlyCompositeScope(override val scopes: Iterable) : FirIterableScope()