[FIR] Move TypeAliasConstructorsSubstitutingScope
It will be needed in the next commit to check for conflicting declarations
This commit is contained in:
committed by
Space Team
parent
c4201101ac
commit
01d4f25363
@@ -8,13 +8,11 @@ package org.jetbrains.kotlin.fir.resolve
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.containingClassForLocalAttr
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.isInner
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.isLocal
|
||||
import org.jetbrains.kotlin.fir.resolve.dfa.RealVariable
|
||||
import org.jetbrains.kotlin.fir.resolve.providers.symbolProvider
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirConstructorSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeAliasSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.LookupTagInternals
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
|
||||
@@ -82,20 +80,6 @@ fun FirTypeRef.firClassLike(session: FirSession): FirClassLikeDeclaration? {
|
||||
fun List<FirQualifierPart>.toTypeProjections(): Array<ConeTypeProjection> =
|
||||
asReversed().flatMap { it.typeArgumentList.typeArguments.map { typeArgument -> typeArgument.toConeTypeProjection() } }.toTypedArray()
|
||||
|
||||
private object TypeAliasConstructorKey : FirDeclarationDataKey()
|
||||
|
||||
var FirConstructor.originalConstructorIfTypeAlias: FirConstructor? by FirDeclarationDataRegistry.data(TypeAliasConstructorKey)
|
||||
|
||||
val FirConstructorSymbol.isTypeAliasedConstructor: Boolean
|
||||
get() = fir.originalConstructorIfTypeAlias != null
|
||||
|
||||
private object TypeAliasForConstructorKey : FirDeclarationDataKey()
|
||||
|
||||
var FirConstructor.typeAliasForConstructor: FirTypeAliasSymbol? by FirDeclarationDataRegistry.data(TypeAliasForConstructorKey)
|
||||
|
||||
val FirConstructorSymbol.typeAliasForConstructor: FirTypeAliasSymbol?
|
||||
get() = fir.typeAliasForConstructor
|
||||
|
||||
interface FirCodeFragmentContext {
|
||||
val towerDataContext: FirTowerDataContext
|
||||
val smartCasts: Map<RealVariable, Set<ConeKotlinType>>
|
||||
@@ -104,3 +88,30 @@ interface FirCodeFragmentContext {
|
||||
private object CodeFragmentContextDataKey : FirDeclarationDataKey()
|
||||
|
||||
var FirCodeFragment.codeFragmentContext: FirCodeFragmentContext? by FirDeclarationDataRegistry.data(CodeFragmentContextDataKey)
|
||||
|
||||
/**
|
||||
* If `classLikeType` is an inner class,
|
||||
* then this function returns a type representing
|
||||
* only the "outer" part of `classLikeType`:
|
||||
* the part with the outer classes and their
|
||||
* type arguments. Returns `null` otherwise.
|
||||
*/
|
||||
inline fun outerType(
|
||||
classLikeType: ConeClassLikeType,
|
||||
session: FirSession,
|
||||
outerClass: (FirClassLikeSymbol<*>) -> FirClassLikeSymbol<*>?,
|
||||
): ConeClassLikeType? {
|
||||
val fullyExpandedType = classLikeType.fullyExpandedType(session)
|
||||
|
||||
val symbol = fullyExpandedType.lookupTag.toSymbol(session) ?: return null
|
||||
|
||||
if (symbol is FirRegularClassSymbol && !symbol.fir.isInner) return null
|
||||
|
||||
val containingSymbol = outerClass(symbol) ?: return null
|
||||
val currentTypeArgumentsNumber = (symbol as? FirRegularClassSymbol)?.fir?.typeParameters?.count { it is FirTypeParameter } ?: 0
|
||||
|
||||
return containingSymbol.constructType(
|
||||
fullyExpandedType.typeArguments.drop(currentTypeArgumentsNumber).toTypedArray(),
|
||||
isNullable = false
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user