Optimize/simplify FirAbstractImportingScope.getStaticsScope
This commit is contained in:
+15
-8
@@ -26,24 +26,32 @@ abstract class FirAbstractImportingScope(
|
|||||||
lookupInFir: Boolean
|
lookupInFir: Boolean
|
||||||
) : FirAbstractProviderBasedScope(session, lookupInFir) {
|
) : FirAbstractProviderBasedScope(session, lookupInFir) {
|
||||||
|
|
||||||
// TODO: Rewrite somehow?
|
private fun getStaticsScope(symbol: FirClassLikeSymbol<*>): FirScope? {
|
||||||
fun getStaticsScope(classId: ClassId): FirScope? {
|
|
||||||
val symbol = provider.getClassLikeSymbolByFqName(classId) ?: return null
|
|
||||||
if (symbol is FirTypeAliasSymbol) {
|
if (symbol is FirTypeAliasSymbol) {
|
||||||
val expansionSymbol = symbol.fir.expandedConeType?.lookupTag?.toSymbol(session)
|
val expansionSymbol = symbol.fir.expandedConeType?.lookupTag?.toSymbol(session)
|
||||||
if (expansionSymbol != null) {
|
if (expansionSymbol != null) {
|
||||||
return getStaticsScope(expansionSymbol.classId)
|
return getStaticsScope(expansionSymbol)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val firClass = (symbol as FirClassSymbol<*>).fir
|
val firClass = (symbol as FirClassSymbol<*>).fir
|
||||||
|
|
||||||
return if (firClass.classKind == ClassKind.OBJECT)
|
return if (firClass.classKind == ClassKind.OBJECT) {
|
||||||
FirObjectImportedCallableScope(classId, firClass.unsubstitutedScope(session, scopeSession, withForcedTypeCalculator = false))
|
FirObjectImportedCallableScope(
|
||||||
else
|
symbol.classId,
|
||||||
|
firClass.unsubstitutedScope(session, scopeSession, withForcedTypeCalculator = false)
|
||||||
|
)
|
||||||
|
} else {
|
||||||
firClass.scopeProvider.getStaticScope(firClass, session, scopeSession)
|
firClass.scopeProvider.getStaticScope(firClass, session, scopeSession)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null
|
return null
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getStaticsScope(classId: ClassId): FirScope? {
|
||||||
|
val symbol = provider.getClassLikeSymbolByFqName(classId) ?: return null
|
||||||
|
return getStaticsScope(symbol)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun <T : FirCallableSymbol<*>> processCallables(
|
protected fun <T : FirCallableSymbol<*>> processCallables(
|
||||||
@@ -79,7 +87,6 @@ abstract class FirAbstractImportingScope(
|
|||||||
processor(symbol)
|
processor(symbol)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract fun <T : FirCallableSymbol<*>> processCallables(
|
abstract fun <T : FirCallableSymbol<*>> processCallables(
|
||||||
|
|||||||
Reference in New Issue
Block a user