[FIR] Add ability to get scopes for declarations of TYPES resolve phase
This commit is contained in:
@@ -22,14 +22,20 @@ import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl
|
||||
import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
|
||||
|
||||
fun ConeKotlinType.scope(useSiteSession: FirSession, scopeSession: ScopeSession): FirTypeScope? {
|
||||
fun ConeKotlinType.scope(useSiteSession: FirSession, scopeSession: ScopeSession): FirTypeScope? =
|
||||
scope(useSiteSession, scopeSession, FirResolvePhase.STATUS)
|
||||
|
||||
fun ConeKotlinType.scopeForStatusResolve(useSiteSession: FirSession, scopeSession: ScopeSession): FirTypeScope? =
|
||||
scope(useSiteSession, scopeSession, FirResolvePhase.TYPES)
|
||||
|
||||
private fun ConeKotlinType.scope(useSiteSession: FirSession, scopeSession: ScopeSession, requiredPhase: FirResolvePhase): FirTypeScope? {
|
||||
return when (this) {
|
||||
is ConeKotlinErrorType -> null
|
||||
is ConeClassLikeType -> {
|
||||
val fullyExpandedType = fullyExpandedType(useSiteSession)
|
||||
val fir = fullyExpandedType.lookupTag.toSymbol(useSiteSession)?.fir as? FirClass<*> ?: return null
|
||||
|
||||
fir.symbol.ensureResolved(FirResolvePhase.STATUS, useSiteSession)
|
||||
fir.symbol.ensureResolved(requiredPhase, useSiteSession)
|
||||
|
||||
val substitution = createSubstitution(fir.typeParameters, fullyExpandedType, useSiteSession)
|
||||
|
||||
@@ -42,19 +48,19 @@ fun ConeKotlinType.scope(useSiteSession: FirSession, scopeSession: ScopeSession)
|
||||
useSiteSession.typeContext,
|
||||
symbol.fir.bounds.map { it.coneType }
|
||||
)
|
||||
intersectionType.scope(useSiteSession, scopeSession) ?: FirTypeScope.Empty
|
||||
intersectionType.scope(useSiteSession, scopeSession, requiredPhase) ?: FirTypeScope.Empty
|
||||
}
|
||||
}
|
||||
is ConeRawType -> lowerBound.scope(useSiteSession, scopeSession)
|
||||
is ConeFlexibleType -> lowerBound.scope(useSiteSession, scopeSession)
|
||||
is ConeRawType -> lowerBound.scope(useSiteSession, scopeSession, requiredPhase)
|
||||
is ConeFlexibleType -> lowerBound.scope(useSiteSession, scopeSession, requiredPhase)
|
||||
is ConeIntersectionType -> FirTypeIntersectionScope.prepareIntersectionScope(
|
||||
useSiteSession,
|
||||
FirStandardOverrideChecker(useSiteSession),
|
||||
intersectedTypes.mapNotNullTo(mutableListOf()) {
|
||||
it.scope(useSiteSession, scopeSession)
|
||||
it.scope(useSiteSession, scopeSession, requiredPhase)
|
||||
}
|
||||
)
|
||||
is ConeDefinitelyNotNullType -> original.scope(useSiteSession, scopeSession)
|
||||
is ConeDefinitelyNotNullType -> original.scope(useSiteSession, scopeSession, requiredPhase)
|
||||
is ConeIntegerLiteralType -> error("ILT should not be in receiver position")
|
||||
else -> null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user