[FIR] Add containingDeclarationSymbol to FirTypeParameter
This commit is contained in:
committed by
TeamCityServer
parent
0c25d280ee
commit
345152d198
+24
-9
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
|||||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||||
import org.jetbrains.kotlin.fir.expressions.builder.buildExpressionStub
|
import org.jetbrains.kotlin.fir.expressions.builder.buildExpressionStub
|
||||||
import org.jetbrains.kotlin.fir.resolve.defaultType
|
import org.jetbrains.kotlin.fir.resolve.defaultType
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||||
import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
|
import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
|
||||||
@@ -62,7 +63,8 @@ class FirDeserializationContext(
|
|||||||
containerSource: DeserializedContainerSource? = this.containerSource,
|
containerSource: DeserializedContainerSource? = this.containerSource,
|
||||||
outerClassSymbol: FirRegularClassSymbol? = this.outerClassSymbol,
|
outerClassSymbol: FirRegularClassSymbol? = this.outerClassSymbol,
|
||||||
annotationDeserializer: AbstractAnnotationDeserializer = this.annotationDeserializer,
|
annotationDeserializer: AbstractAnnotationDeserializer = this.annotationDeserializer,
|
||||||
capturesTypeParameters: Boolean = true
|
capturesTypeParameters: Boolean = true,
|
||||||
|
containingDeclarationSymbol: FirBasedSymbol<*>? = this.outerClassSymbol
|
||||||
): FirDeserializationContext = FirDeserializationContext(
|
): FirDeserializationContext = FirDeserializationContext(
|
||||||
nameResolver,
|
nameResolver,
|
||||||
typeTable,
|
typeTable,
|
||||||
@@ -70,7 +72,15 @@ class FirDeserializationContext(
|
|||||||
moduleData,
|
moduleData,
|
||||||
packageFqName,
|
packageFqName,
|
||||||
relativeClassName,
|
relativeClassName,
|
||||||
FirTypeDeserializer(moduleData, nameResolver, typeTable, annotationDeserializer, typeParameterProtos, typeDeserializer),
|
FirTypeDeserializer(
|
||||||
|
moduleData,
|
||||||
|
nameResolver,
|
||||||
|
typeTable,
|
||||||
|
annotationDeserializer,
|
||||||
|
typeParameterProtos,
|
||||||
|
typeDeserializer,
|
||||||
|
containingDeclarationSymbol
|
||||||
|
),
|
||||||
annotationDeserializer,
|
annotationDeserializer,
|
||||||
constDeserializer,
|
constDeserializer,
|
||||||
containerSource,
|
containerSource,
|
||||||
@@ -101,7 +111,8 @@ class FirDeserializationContext(
|
|||||||
relativeClassName = null,
|
relativeClassName = null,
|
||||||
typeParameterProtos = emptyList(),
|
typeParameterProtos = emptyList(),
|
||||||
containerSource,
|
containerSource,
|
||||||
outerClassSymbol = null
|
outerClassSymbol = null,
|
||||||
|
containingDeclarationSymbol = null
|
||||||
)
|
)
|
||||||
|
|
||||||
fun createForClass(
|
fun createForClass(
|
||||||
@@ -124,6 +135,7 @@ class FirDeserializationContext(
|
|||||||
classId.relativeClassName,
|
classId.relativeClassName,
|
||||||
classProto.typeParameterList,
|
classProto.typeParameterList,
|
||||||
containerSource,
|
containerSource,
|
||||||
|
outerClassSymbol,
|
||||||
outerClassSymbol
|
outerClassSymbol
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -139,6 +151,7 @@ class FirDeserializationContext(
|
|||||||
typeParameterProtos: List<ProtoBuf.TypeParameter>,
|
typeParameterProtos: List<ProtoBuf.TypeParameter>,
|
||||||
containerSource: DeserializedContainerSource?,
|
containerSource: DeserializedContainerSource?,
|
||||||
outerClassSymbol: FirRegularClassSymbol?,
|
outerClassSymbol: FirRegularClassSymbol?,
|
||||||
|
containingDeclarationSymbol: FirBasedSymbol<*>?
|
||||||
): FirDeserializationContext {
|
): FirDeserializationContext {
|
||||||
return FirDeserializationContext(
|
return FirDeserializationContext(
|
||||||
nameResolver, typeTable,
|
nameResolver, typeTable,
|
||||||
@@ -152,7 +165,8 @@ class FirDeserializationContext(
|
|||||||
typeTable,
|
typeTable,
|
||||||
annotationDeserializer,
|
annotationDeserializer,
|
||||||
typeParameterProtos,
|
typeParameterProtos,
|
||||||
null
|
null,
|
||||||
|
containingDeclarationSymbol
|
||||||
),
|
),
|
||||||
annotationDeserializer,
|
annotationDeserializer,
|
||||||
constDeserializer,
|
constDeserializer,
|
||||||
@@ -176,8 +190,9 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
|||||||
fun loadTypeAlias(proto: ProtoBuf.TypeAlias): FirTypeAlias {
|
fun loadTypeAlias(proto: ProtoBuf.TypeAlias): FirTypeAlias {
|
||||||
val flags = proto.flags
|
val flags = proto.flags
|
||||||
val name = c.nameResolver.getName(proto.name)
|
val name = c.nameResolver.getName(proto.name)
|
||||||
val local = c.childContext(proto.typeParameterList)
|
|
||||||
val classId = ClassId(c.packageFqName, name)
|
val classId = ClassId(c.packageFqName, name)
|
||||||
|
val symbol = FirTypeAliasSymbol(classId)
|
||||||
|
val local = c.childContext(proto.typeParameterList, containingDeclarationSymbol = symbol)
|
||||||
return buildTypeAlias {
|
return buildTypeAlias {
|
||||||
moduleData = c.moduleData
|
moduleData = c.moduleData
|
||||||
origin = FirDeclarationOrigin.Library
|
origin = FirDeclarationOrigin.Library
|
||||||
@@ -193,7 +208,7 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
annotations += c.annotationDeserializer.loadTypeAliasAnnotations(proto, local.nameResolver)
|
annotations += c.annotationDeserializer.loadTypeAliasAnnotations(proto, local.nameResolver)
|
||||||
symbol = FirTypeAliasSymbol(classId)
|
this.symbol = symbol
|
||||||
expandedTypeRef = proto.underlyingType(c.typeTable).toTypeRef(local)
|
expandedTypeRef = proto.underlyingType(c.typeTable).toTypeRef(local)
|
||||||
resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
|
resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
|
||||||
typeParameters += local.typeDeserializer.ownTypeParameters.map { it.fir }
|
typeParameters += local.typeDeserializer.ownTypeParameters.map { it.fir }
|
||||||
@@ -212,7 +227,7 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
|||||||
val callableName = c.nameResolver.getName(proto.name)
|
val callableName = c.nameResolver.getName(proto.name)
|
||||||
val callableId = CallableId(c.packageFqName, c.relativeClassName, callableName)
|
val callableId = CallableId(c.packageFqName, c.relativeClassName, callableName)
|
||||||
val symbol = FirPropertySymbol(callableId)
|
val symbol = FirPropertySymbol(callableId)
|
||||||
val local = c.childContext(proto.typeParameterList)
|
val local = c.childContext(proto.typeParameterList, containingDeclarationSymbol = symbol)
|
||||||
|
|
||||||
// Per documentation on Property.getter_flags in metadata.proto, if an accessor flags field is absent, its value should be computed
|
// Per documentation on Property.getter_flags in metadata.proto, if an accessor flags field is absent, its value should be computed
|
||||||
// by taking hasAnnotations/visibility/modality from property flags, and using false for the rest
|
// by taking hasAnnotations/visibility/modality from property flags, and using false for the rest
|
||||||
@@ -381,7 +396,7 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
|||||||
val callableName = c.nameResolver.getName(proto.name)
|
val callableName = c.nameResolver.getName(proto.name)
|
||||||
val callableId = CallableId(c.packageFqName, c.relativeClassName, callableName)
|
val callableId = CallableId(c.packageFqName, c.relativeClassName, callableName)
|
||||||
val symbol = FirNamedFunctionSymbol(callableId)
|
val symbol = FirNamedFunctionSymbol(callableId)
|
||||||
val local = c.childContext(proto.typeParameterList)
|
val local = c.childContext(proto.typeParameterList, containingDeclarationSymbol = symbol)
|
||||||
|
|
||||||
val simpleFunction = buildSimpleFunction {
|
val simpleFunction = buildSimpleFunction {
|
||||||
moduleData = c.moduleData
|
moduleData = c.moduleData
|
||||||
@@ -443,7 +458,7 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
|||||||
val relativeClassName = c.relativeClassName!!
|
val relativeClassName = c.relativeClassName!!
|
||||||
val callableId = CallableId(c.packageFqName, relativeClassName, relativeClassName.shortName())
|
val callableId = CallableId(c.packageFqName, relativeClassName, relativeClassName.shortName())
|
||||||
val symbol = FirConstructorSymbol(callableId)
|
val symbol = FirConstructorSymbol(callableId)
|
||||||
val local = c.childContext(emptyList())
|
val local = c.childContext(emptyList(), containingDeclarationSymbol = symbol)
|
||||||
val isPrimary = !Flags.IS_SECONDARY.get(flags)
|
val isPrimary = !Flags.IS_SECONDARY.get(flags)
|
||||||
|
|
||||||
val typeParameters = classBuilder.typeParameters
|
val typeParameters = classBuilder.typeParameters
|
||||||
|
|||||||
+4
-1
@@ -19,6 +19,7 @@ import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.firUnsafe
|
|||||||
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag
|
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag
|
||||||
import org.jetbrains.kotlin.fir.symbols.ConeClassifierLookupTag
|
import org.jetbrains.kotlin.fir.symbols.ConeClassifierLookupTag
|
||||||
import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterLookupTag
|
import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterLookupTag
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl
|
import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
|
||||||
@@ -43,7 +44,8 @@ class FirTypeDeserializer(
|
|||||||
val typeTable: TypeTable,
|
val typeTable: TypeTable,
|
||||||
val annotationDeserializer: AbstractAnnotationDeserializer,
|
val annotationDeserializer: AbstractAnnotationDeserializer,
|
||||||
typeParameterProtos: List<ProtoBuf.TypeParameter>,
|
typeParameterProtos: List<ProtoBuf.TypeParameter>,
|
||||||
val parent: FirTypeDeserializer?
|
val parent: FirTypeDeserializer?,
|
||||||
|
val containingSymbol: FirBasedSymbol<*>?
|
||||||
) {
|
) {
|
||||||
private val typeParameterDescriptors: Map<Int, FirTypeParameterSymbol> = if (typeParameterProtos.isNotEmpty()) {
|
private val typeParameterDescriptors: Map<Int, FirTypeParameterSymbol> = if (typeParameterProtos.isNotEmpty()) {
|
||||||
LinkedHashMap<Int, FirTypeParameterSymbol>()
|
LinkedHashMap<Int, FirTypeParameterSymbol>()
|
||||||
@@ -73,6 +75,7 @@ class FirTypeDeserializer(
|
|||||||
origin = FirDeclarationOrigin.Library
|
origin = FirDeclarationOrigin.Library
|
||||||
this.name = name
|
this.name = name
|
||||||
this.symbol = symbol
|
this.symbol = symbol
|
||||||
|
this.containingDeclarationSymbol = containingSymbol
|
||||||
variance = proto.variance.convertVariance()
|
variance = proto.variance.convertVariance()
|
||||||
isReified = proto.reified
|
isReified = proto.reified
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -229,6 +229,7 @@ private class SyntheticFunctionalInterfaceCache(private val moduleData: FirModul
|
|||||||
origin = FirDeclarationOrigin.BuiltIns
|
origin = FirDeclarationOrigin.BuiltIns
|
||||||
name = Name.identifier("P$it")
|
name = Name.identifier("P$it")
|
||||||
symbol = FirTypeParameterSymbol()
|
symbol = FirTypeParameterSymbol()
|
||||||
|
containingDeclarationSymbol = this@symbol
|
||||||
variance = Variance.IN_VARIANCE
|
variance = Variance.IN_VARIANCE
|
||||||
isReified = false
|
isReified = false
|
||||||
bounds += moduleData.session.builtinTypes.nullableAnyType
|
bounds += moduleData.session.builtinTypes.nullableAnyType
|
||||||
@@ -242,6 +243,7 @@ private class SyntheticFunctionalInterfaceCache(private val moduleData: FirModul
|
|||||||
origin = FirDeclarationOrigin.BuiltIns
|
origin = FirDeclarationOrigin.BuiltIns
|
||||||
name = Name.identifier("R")
|
name = Name.identifier("R")
|
||||||
symbol = FirTypeParameterSymbol()
|
symbol = FirTypeParameterSymbol()
|
||||||
|
containingDeclarationSymbol = this@symbol
|
||||||
variance = Variance.OUT_VARIANCE
|
variance = Variance.OUT_VARIANCE
|
||||||
isReified = false
|
isReified = false
|
||||||
bounds += moduleData.session.builtinTypes.nullableAnyType
|
bounds += moduleData.session.builtinTypes.nullableAnyType
|
||||||
|
|||||||
+44
-18
@@ -41,6 +41,7 @@ import org.jetbrains.kotlin.fir.references.builder.buildExplicitThisReference
|
|||||||
import org.jetbrains.kotlin.fir.references.builder.buildSimpleNamedReference
|
import org.jetbrains.kotlin.fir.references.builder.buildSimpleNamedReference
|
||||||
import org.jetbrains.kotlin.fir.references.impl.FirReferencePlaceholderForResolvedAnnotations
|
import org.jetbrains.kotlin.fir.references.impl.FirReferencePlaceholderForResolvedAnnotations
|
||||||
import org.jetbrains.kotlin.fir.scopes.FirScopeProvider
|
import org.jetbrains.kotlin.fir.scopes.FirScopeProvider
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||||
import org.jetbrains.kotlin.fir.types.*
|
import org.jetbrains.kotlin.fir.types.*
|
||||||
import org.jetbrains.kotlin.fir.types.builder.*
|
import org.jetbrains.kotlin.fir.types.builder.*
|
||||||
@@ -374,8 +375,8 @@ class DeclarationsConverter(
|
|||||||
val typeConstraints = mutableListOf<TypeConstraint>()
|
val typeConstraints = mutableListOf<TypeConstraint>()
|
||||||
var classBody: LighterASTNode? = null
|
var classBody: LighterASTNode? = null
|
||||||
var superTypeList: LighterASTNode? = null
|
var superTypeList: LighterASTNode? = null
|
||||||
|
|
||||||
var typeParameterList: LighterASTNode? = null
|
var typeParameterList: LighterASTNode? = null
|
||||||
|
|
||||||
classNode.forEachChildren {
|
classNode.forEachChildren {
|
||||||
when (it.tokenType) {
|
when (it.tokenType) {
|
||||||
MODIFIER_LIST -> modifiers = convertModifierList(it, isInClass = true)
|
MODIFIER_LIST -> modifiers = convertModifierList(it, isInClass = true)
|
||||||
@@ -390,7 +391,6 @@ class DeclarationsConverter(
|
|||||||
CLASS_BODY -> classBody = it
|
CLASS_BODY -> classBody = it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
typeParameterList?.let { firTypeParameters += convertTypeParameters(it, typeConstraints) }
|
|
||||||
|
|
||||||
if (classKind == ClassKind.CLASS) {
|
if (classKind == ClassKind.CLASS) {
|
||||||
classKind = when {
|
classKind = when {
|
||||||
@@ -418,6 +418,10 @@ class DeclarationsConverter(
|
|||||||
isExternal = modifiers.hasExternal()
|
isExternal = modifiers.hasExternal()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val classSymbol = FirRegularClassSymbol(context.currentClassId)
|
||||||
|
|
||||||
|
typeParameterList?.let { firTypeParameters += convertTypeParameters(it, typeConstraints, classSymbol) }
|
||||||
|
|
||||||
withCapturedTypeParameters(status.isInner, firTypeParameters) {
|
withCapturedTypeParameters(status.isInner, firTypeParameters) {
|
||||||
buildRegularClass {
|
buildRegularClass {
|
||||||
source = classNode.toFirSourceElement()
|
source = classNode.toFirSourceElement()
|
||||||
@@ -427,7 +431,7 @@ class DeclarationsConverter(
|
|||||||
this.status = status
|
this.status = status
|
||||||
this.classKind = classKind
|
this.classKind = classKind
|
||||||
scopeProvider = baseScopeProvider
|
scopeProvider = baseScopeProvider
|
||||||
symbol = FirRegularClassSymbol(context.currentClassId)
|
symbol = classSymbol
|
||||||
annotations += modifiers.annotations
|
annotations += modifiers.annotations
|
||||||
typeParameters += firTypeParameters
|
typeParameters += firTypeParameters
|
||||||
|
|
||||||
@@ -565,7 +569,8 @@ class DeclarationsConverter(
|
|||||||
scopeProvider = baseScopeProvider
|
scopeProvider = baseScopeProvider
|
||||||
symbol = FirAnonymousObjectSymbol()
|
symbol = FirAnonymousObjectSymbol()
|
||||||
context.applyToActualCapturedTypeParameters(false) {
|
context.applyToActualCapturedTypeParameters(false) {
|
||||||
typeParameters += buildOuterClassTypeParameterRef { this.symbol = it } }
|
typeParameters += buildOuterClassTypeParameterRef { this.symbol = it }
|
||||||
|
}
|
||||||
val delegatedSelfType = objectLiteral.toDelegatedSelfType(this)
|
val delegatedSelfType = objectLiteral.toDelegatedSelfType(this)
|
||||||
registerSelfType(delegatedSelfType)
|
registerSelfType(delegatedSelfType)
|
||||||
|
|
||||||
@@ -958,18 +963,26 @@ class DeclarationsConverter(
|
|||||||
var modifiers = Modifier()
|
var modifiers = Modifier()
|
||||||
var identifier: String? = null
|
var identifier: String? = null
|
||||||
lateinit var firType: FirTypeRef
|
lateinit var firType: FirTypeRef
|
||||||
val firTypeParameters = mutableListOf<FirTypeParameter>()
|
|
||||||
typeAlias.forEachChildren {
|
typeAlias.forEachChildren {
|
||||||
when (it.tokenType) {
|
when (it.tokenType) {
|
||||||
MODIFIER_LIST -> modifiers = convertModifierList(it)
|
MODIFIER_LIST -> modifiers = convertModifierList(it)
|
||||||
IDENTIFIER -> identifier = it.asText
|
IDENTIFIER -> identifier = it.asText
|
||||||
TYPE_PARAMETER_LIST -> firTypeParameters += convertTypeParameters(it, emptyList())
|
|
||||||
TYPE_REFERENCE -> firType = convertType(it)
|
TYPE_REFERENCE -> firType = convertType(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val typeAliasName = identifier.nameAsSafeName()
|
val typeAliasName = identifier.nameAsSafeName()
|
||||||
return withChildClassName(typeAliasName) {
|
return withChildClassName(typeAliasName) {
|
||||||
|
val classSymbol = FirTypeAliasSymbol(context.currentClassId)
|
||||||
|
|
||||||
|
val firTypeParameters = mutableListOf<FirTypeParameter>()
|
||||||
|
typeAlias.forEachChildren {
|
||||||
|
if (it.tokenType == TYPE_PARAMETER_LIST) {
|
||||||
|
firTypeParameters += convertTypeParameters(it, emptyList(), classSymbol)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return@withChildClassName buildTypeAlias {
|
return@withChildClassName buildTypeAlias {
|
||||||
source = typeAlias.toFirSourceElement()
|
source = typeAlias.toFirSourceElement()
|
||||||
moduleData = baseModuleData
|
moduleData = baseModuleData
|
||||||
@@ -979,7 +992,7 @@ class DeclarationsConverter(
|
|||||||
isExpect = modifiers.hasExpect()
|
isExpect = modifiers.hasExpect()
|
||||||
isActual = modifiers.hasActual()
|
isActual = modifiers.hasActual()
|
||||||
}
|
}
|
||||||
symbol = FirTypeAliasSymbol(context.currentClassId)
|
symbol = classSymbol
|
||||||
expandedTypeRef = firType
|
expandedTypeRef = firType
|
||||||
annotations += modifiers.annotations
|
annotations += modifiers.annotations
|
||||||
typeParameters += firTypeParameters
|
typeParameters += firTypeParameters
|
||||||
@@ -1020,8 +1033,6 @@ class DeclarationsConverter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
typeParameterList?.let { firTypeParameters += convertTypeParameters(it, typeConstraints) }
|
|
||||||
|
|
||||||
val propertyName = identifier.nameAsSafeName()
|
val propertyName = identifier.nameAsSafeName()
|
||||||
|
|
||||||
val parentNode = property.getParent()
|
val parentNode = property.getParent()
|
||||||
@@ -1042,9 +1053,12 @@ class DeclarationsConverter(
|
|||||||
(it.getExpressionInParentheses() ?: it).toFirSourceElement()
|
(it.getExpressionInParentheses() ?: it).toFirSourceElement()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
symbol = if (isLocal) FirPropertySymbol(propertyName) else FirPropertySymbol(callableIdForName(propertyName))
|
||||||
|
|
||||||
|
typeParameterList?.let { firTypeParameters += convertTypeParameters(it, typeConstraints, symbol) }
|
||||||
|
|
||||||
if (isLocal) {
|
if (isLocal) {
|
||||||
this.isLocal = true
|
this.isLocal = true
|
||||||
symbol = FirPropertySymbol(propertyName)
|
|
||||||
val delegateBuilder = delegateExpression?.let {
|
val delegateBuilder = delegateExpression?.let {
|
||||||
FirWrappedDelegateExpressionBuilder().apply {
|
FirWrappedDelegateExpressionBuilder().apply {
|
||||||
source = delegateSource
|
source = delegateSource
|
||||||
@@ -1071,7 +1085,6 @@ class DeclarationsConverter(
|
|||||||
} else {
|
} else {
|
||||||
this.isLocal = false
|
this.isLocal = false
|
||||||
receiverTypeRef = receiverType
|
receiverTypeRef = receiverType
|
||||||
symbol = FirPropertySymbol(callableIdForName(propertyName))
|
|
||||||
dispatchReceiverType = currentDispatchReceiverType()
|
dispatchReceiverType = currentDispatchReceiverType()
|
||||||
withCapturedTypeParameters(true, firTypeParameters) {
|
withCapturedTypeParameters(true, firTypeParameters) {
|
||||||
typeParameters += firTypeParameters
|
typeParameters += firTypeParameters
|
||||||
@@ -1353,7 +1366,6 @@ class DeclarationsConverter(
|
|||||||
fun convertFunctionDeclaration(functionDeclaration: LighterASTNode, classWrapper: ClassWrapper? = null): FirStatement {
|
fun convertFunctionDeclaration(functionDeclaration: LighterASTNode, classWrapper: ClassWrapper? = null): FirStatement {
|
||||||
var modifiers = Modifier()
|
var modifiers = Modifier()
|
||||||
var identifier: String? = null
|
var identifier: String? = null
|
||||||
val firTypeParameters = mutableListOf<FirTypeParameter>()
|
|
||||||
var valueParametersList: LighterASTNode? = null
|
var valueParametersList: LighterASTNode? = null
|
||||||
var isReturnType = false
|
var isReturnType = false
|
||||||
var receiverType: FirTypeRef? = null
|
var receiverType: FirTypeRef? = null
|
||||||
@@ -1379,7 +1391,6 @@ class DeclarationsConverter(
|
|||||||
else -> if (it.isExpression()) expression = it
|
else -> if (it.isExpression()) expression = it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
typeParameterList?.let { firTypeParameters += convertTypeParameters(it, typeConstraints) }
|
|
||||||
|
|
||||||
if (returnType == null) {
|
if (returnType == null) {
|
||||||
returnType =
|
returnType =
|
||||||
@@ -1391,19 +1402,22 @@ class DeclarationsConverter(
|
|||||||
val isLocal = !(parentNode?.tokenType == KT_FILE || parentNode?.tokenType == CLASS_BODY)
|
val isLocal = !(parentNode?.tokenType == KT_FILE || parentNode?.tokenType == CLASS_BODY)
|
||||||
val target: FirFunctionTarget
|
val target: FirFunctionTarget
|
||||||
val functionSource = functionDeclaration.toFirSourceElement()
|
val functionSource = functionDeclaration.toFirSourceElement()
|
||||||
|
val functionSymbol: FirFunctionSymbol<*>
|
||||||
val functionBuilder = if (identifier == null && isLocal) {
|
val functionBuilder = if (identifier == null && isLocal) {
|
||||||
val labelName = functionDeclaration.getLabelName() ?: context.calleeNamesForLambda.lastOrNull()?.identifier
|
val labelName = functionDeclaration.getLabelName() ?: context.calleeNamesForLambda.lastOrNull()?.identifier
|
||||||
target = FirFunctionTarget(labelName = labelName, isLambda = false)
|
target = FirFunctionTarget(labelName = labelName, isLambda = false)
|
||||||
|
functionSymbol = FirAnonymousFunctionSymbol()
|
||||||
FirAnonymousFunctionBuilder().apply {
|
FirAnonymousFunctionBuilder().apply {
|
||||||
source = functionSource
|
source = functionSource
|
||||||
receiverTypeRef = receiverType
|
receiverTypeRef = receiverType
|
||||||
symbol = FirAnonymousFunctionSymbol()
|
symbol = functionSymbol
|
||||||
isLambda = false
|
isLambda = false
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val functionName = identifier.nameAsSafeName()
|
val functionName = identifier.nameAsSafeName()
|
||||||
val labelName = runIf(!functionName.isSpecial) { functionName.identifier }
|
val labelName = runIf(!functionName.isSpecial) { functionName.identifier }
|
||||||
target = FirFunctionTarget(labelName, isLambda = false)
|
target = FirFunctionTarget(labelName, isLambda = false)
|
||||||
|
functionSymbol = FirNamedFunctionSymbol(callableIdForName(functionName))
|
||||||
FirSimpleFunctionBuilder().apply {
|
FirSimpleFunctionBuilder().apply {
|
||||||
source = functionSource
|
source = functionSource
|
||||||
receiverTypeRef = receiverType
|
receiverTypeRef = receiverType
|
||||||
@@ -1423,11 +1437,14 @@ class DeclarationsConverter(
|
|||||||
isSuspend = modifiers.hasSuspend()
|
isSuspend = modifiers.hasSuspend()
|
||||||
}
|
}
|
||||||
|
|
||||||
symbol = FirNamedFunctionSymbol(callableIdForName(functionName))
|
symbol = functionSymbol
|
||||||
dispatchReceiverType = currentDispatchReceiverType()
|
dispatchReceiverType = currentDispatchReceiverType()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val firTypeParameters = mutableListOf<FirTypeParameter>()
|
||||||
|
typeParameterList?.let { firTypeParameters += convertTypeParameters(it, typeConstraints, functionSymbol) }
|
||||||
|
|
||||||
val function = functionBuilder.apply {
|
val function = functionBuilder.apply {
|
||||||
moduleData = baseModuleData
|
moduleData = baseModuleData
|
||||||
origin = FirDeclarationOrigin.Source
|
origin = FirDeclarationOrigin.Source
|
||||||
@@ -1627,10 +1644,14 @@ class DeclarationsConverter(
|
|||||||
/**
|
/**
|
||||||
* @see org.jetbrains.kotlin.parsing.KotlinParsing.parseTypeParameterList
|
* @see org.jetbrains.kotlin.parsing.KotlinParsing.parseTypeParameterList
|
||||||
*/
|
*/
|
||||||
private fun convertTypeParameters(typeParameterList: LighterASTNode, typeConstraints: List<TypeConstraint>): List<FirTypeParameter> {
|
private fun convertTypeParameters(
|
||||||
|
typeParameterList: LighterASTNode,
|
||||||
|
typeConstraints: List<TypeConstraint>,
|
||||||
|
containingDeclarationSymbol: FirBasedSymbol<*>
|
||||||
|
): List<FirTypeParameter> {
|
||||||
return typeParameterList.forEachChildrenReturnList { node, container ->
|
return typeParameterList.forEachChildrenReturnList { node, container ->
|
||||||
when (node.tokenType) {
|
when (node.tokenType) {
|
||||||
TYPE_PARAMETER -> container += convertTypeParameter(node, typeConstraints)
|
TYPE_PARAMETER -> container += convertTypeParameter(node, typeConstraints, containingDeclarationSymbol)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1672,7 +1693,11 @@ class DeclarationsConverter(
|
|||||||
/**
|
/**
|
||||||
* @see org.jetbrains.kotlin.parsing.KotlinParsing.parseTypeParameter
|
* @see org.jetbrains.kotlin.parsing.KotlinParsing.parseTypeParameter
|
||||||
*/
|
*/
|
||||||
private fun convertTypeParameter(typeParameter: LighterASTNode, typeConstraints: List<TypeConstraint>): FirTypeParameter {
|
private fun convertTypeParameter(
|
||||||
|
typeParameter: LighterASTNode,
|
||||||
|
typeConstraints: List<TypeConstraint>,
|
||||||
|
containingSymbol: FirBasedSymbol<*>
|
||||||
|
): FirTypeParameter {
|
||||||
var typeParameterModifiers = TypeParameterModifier()
|
var typeParameterModifiers = TypeParameterModifier()
|
||||||
var identifier: String? = null
|
var identifier: String? = null
|
||||||
var firType: FirTypeRef? = null
|
var firType: FirTypeRef? = null
|
||||||
@@ -1690,6 +1715,7 @@ class DeclarationsConverter(
|
|||||||
origin = FirDeclarationOrigin.Source
|
origin = FirDeclarationOrigin.Source
|
||||||
name = identifier.nameAsSafeName()
|
name = identifier.nameAsSafeName()
|
||||||
symbol = FirTypeParameterSymbol()
|
symbol = FirTypeParameterSymbol()
|
||||||
|
containingDeclarationSymbol = containingSymbol
|
||||||
variance = typeParameterModifiers.getVariance()
|
variance = typeParameterModifiers.getVariance()
|
||||||
isReified = typeParameterModifiers.hasReified()
|
isReified = typeParameterModifiers.hasReified()
|
||||||
annotations += typeParameterModifiers.annotations
|
annotations += typeParameterModifiers.annotations
|
||||||
|
|||||||
+46
-34
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.fir.expressions.builder.*
|
|||||||
import org.jetbrains.kotlin.fir.expressions.impl.FirSingleExpressionBlock
|
import org.jetbrains.kotlin.fir.expressions.impl.FirSingleExpressionBlock
|
||||||
import org.jetbrains.kotlin.fir.references.builder.*
|
import org.jetbrains.kotlin.fir.references.builder.*
|
||||||
import org.jetbrains.kotlin.fir.scopes.FirScopeProvider
|
import org.jetbrains.kotlin.fir.scopes.FirScopeProvider
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||||
import org.jetbrains.kotlin.fir.types.*
|
import org.jetbrains.kotlin.fir.types.*
|
||||||
import org.jetbrains.kotlin.fir.types.builder.*
|
import org.jetbrains.kotlin.fir.types.builder.*
|
||||||
@@ -532,18 +533,55 @@ open class RawFirBuilder(
|
|||||||
extractAnnotationsTo(container.annotations)
|
extractAnnotationsTo(container.annotations)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun KtTypeParameterListOwner.extractTypeParametersTo(container: FirTypeParameterRefsOwnerBuilder) {
|
private fun KtTypeParameterListOwner.extractTypeParametersTo(
|
||||||
|
container: FirTypeParameterRefsOwnerBuilder,
|
||||||
|
declarationSymbol: FirBasedSymbol<*>
|
||||||
|
) {
|
||||||
for (typeParameter in typeParameters) {
|
for (typeParameter in typeParameters) {
|
||||||
container.typeParameters += typeParameter.convert<FirTypeParameter>()
|
container.typeParameters += extractTypeParameter(typeParameter, declarationSymbol)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun KtTypeParameterListOwner.extractTypeParametersTo(container: FirTypeParametersOwnerBuilder) {
|
private fun KtTypeParameterListOwner.extractTypeParametersTo(
|
||||||
|
container: FirTypeParametersOwnerBuilder,
|
||||||
|
declarationSymbol: FirBasedSymbol<*>
|
||||||
|
) {
|
||||||
for (typeParameter in typeParameters) {
|
for (typeParameter in typeParameters) {
|
||||||
container.typeParameters += typeParameter.convert<FirTypeParameter>()
|
container.typeParameters += extractTypeParameter(typeParameter, declarationSymbol)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun extractTypeParameter(parameter: KtTypeParameter, declarationSymbol: FirBasedSymbol<*>): FirTypeParameter {
|
||||||
|
val parameterName = parameter.nameAsSafeName
|
||||||
|
return buildTypeParameter {
|
||||||
|
source = parameter.toFirSourceElement()
|
||||||
|
moduleData = baseModuleData
|
||||||
|
origin = FirDeclarationOrigin.Source
|
||||||
|
name = parameterName
|
||||||
|
symbol = FirTypeParameterSymbol()
|
||||||
|
containingDeclarationSymbol = declarationSymbol
|
||||||
|
variance = parameter.variance
|
||||||
|
isReified = parameter.hasModifier(REIFIED_KEYWORD)
|
||||||
|
parameter.extractAnnotationsTo(this)
|
||||||
|
val extendsBound = parameter.extendsBound
|
||||||
|
if (extendsBound != null) {
|
||||||
|
bounds += extendsBound.convert<FirTypeRef>()
|
||||||
|
}
|
||||||
|
val owner = parameter.getStrictParentOfType<KtTypeParameterListOwner>() ?: return@buildTypeParameter
|
||||||
|
for (typeConstraint in owner.typeConstraints) {
|
||||||
|
val subjectName = typeConstraint.subjectTypeParameterName?.getReferencedNameAsName()
|
||||||
|
if (subjectName == parameterName) {
|
||||||
|
bounds += typeConstraint.boundTypeReference.toFirOrErrorType()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
addDefaultBoundIfNecessary()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun visitTypeParameter(parameter: KtTypeParameter, data: Unit?): FirElement {
|
||||||
|
throw AssertionError("KtTypeParameter should be process via extractTypeParameter")
|
||||||
|
}
|
||||||
|
|
||||||
private fun <T> KtTypeParameterListOwner.fillDanglingConstraintsTo(to: T) where T : FirDeclaration, T : FirTypeParameterRefsOwner {
|
private fun <T> KtTypeParameterListOwner.fillDanglingConstraintsTo(to: T) where T : FirDeclaration, T : FirTypeParameterRefsOwner {
|
||||||
val typeParamNames = typeParameters.mapNotNull { it.nameAsName }.toSet()
|
val typeParamNames = typeParameters.mapNotNull { it.nameAsName }.toSet()
|
||||||
val result = typeConstraints.mapNotNull { constraint ->
|
val result = typeConstraints.mapNotNull { constraint ->
|
||||||
@@ -890,7 +928,7 @@ open class RawFirBuilder(
|
|||||||
symbol = FirRegularClassSymbol(context.currentClassId)
|
symbol = FirRegularClassSymbol(context.currentClassId)
|
||||||
|
|
||||||
classOrObject.extractAnnotationsTo(this)
|
classOrObject.extractAnnotationsTo(this)
|
||||||
classOrObject.extractTypeParametersTo(this)
|
classOrObject.extractTypeParametersTo(this, symbol)
|
||||||
|
|
||||||
context.applyToActualCapturedTypeParameters(true) {
|
context.applyToActualCapturedTypeParameters(true) {
|
||||||
typeParameters += buildOuterClassTypeParameterRef { symbol = it }
|
typeParameters += buildOuterClassTypeParameterRef { symbol = it }
|
||||||
@@ -1032,7 +1070,7 @@ open class RawFirBuilder(
|
|||||||
symbol = FirTypeAliasSymbol(context.currentClassId)
|
symbol = FirTypeAliasSymbol(context.currentClassId)
|
||||||
expandedTypeRef = typeAlias.getTypeReference().toFirOrErrorType()
|
expandedTypeRef = typeAlias.getTypeReference().toFirOrErrorType()
|
||||||
typeAlias.extractAnnotationsTo(this)
|
typeAlias.extractAnnotationsTo(this)
|
||||||
typeAlias.extractTypeParametersTo(this)
|
typeAlias.extractTypeParametersTo(this, symbol)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1090,7 +1128,7 @@ open class RawFirBuilder(
|
|||||||
context.firFunctionTargets += target
|
context.firFunctionTargets += target
|
||||||
function.extractAnnotationsTo(this)
|
function.extractAnnotationsTo(this)
|
||||||
if (this is FirSimpleFunctionBuilder) {
|
if (this is FirSimpleFunctionBuilder) {
|
||||||
function.extractTypeParametersTo(this)
|
function.extractTypeParametersTo(this, symbol)
|
||||||
}
|
}
|
||||||
for (valueParameter in function.valueParameters) {
|
for (valueParameter in function.valueParameters) {
|
||||||
valueParameters += valueParameter.convert<FirValueParameter>()
|
valueParameters += valueParameter.convert<FirValueParameter>()
|
||||||
@@ -1373,7 +1411,7 @@ open class RawFirBuilder(
|
|||||||
receiverTypeRef = receiverTypeReference.convertSafe()
|
receiverTypeRef = receiverTypeReference.convertSafe()
|
||||||
symbol = FirPropertySymbol(callableIdForName(propertyName))
|
symbol = FirPropertySymbol(callableIdForName(propertyName))
|
||||||
dispatchReceiverType = currentDispatchReceiverType()
|
dispatchReceiverType = currentDispatchReceiverType()
|
||||||
extractTypeParametersTo(this)
|
extractTypeParametersTo(this, symbol)
|
||||||
withCapturedTypeParameters(true, this.typeParameters) {
|
withCapturedTypeParameters(true, this.typeParameters) {
|
||||||
val delegateBuilder = if (hasDelegate()) {
|
val delegateBuilder = if (hasDelegate()) {
|
||||||
FirWrappedDelegateExpressionBuilder().apply {
|
FirWrappedDelegateExpressionBuilder().apply {
|
||||||
@@ -1557,32 +1595,6 @@ open class RawFirBuilder(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitTypeParameter(parameter: KtTypeParameter, data: Unit): FirElement {
|
|
||||||
val parameterName = parameter.nameAsSafeName
|
|
||||||
return buildTypeParameter {
|
|
||||||
source = parameter.toFirSourceElement()
|
|
||||||
moduleData = baseModuleData
|
|
||||||
origin = FirDeclarationOrigin.Source
|
|
||||||
name = parameterName
|
|
||||||
symbol = FirTypeParameterSymbol()
|
|
||||||
variance = parameter.variance
|
|
||||||
isReified = parameter.hasModifier(REIFIED_KEYWORD)
|
|
||||||
parameter.extractAnnotationsTo(this)
|
|
||||||
val extendsBound = parameter.extendsBound
|
|
||||||
if (extendsBound != null) {
|
|
||||||
bounds += extendsBound.convert<FirTypeRef>()
|
|
||||||
}
|
|
||||||
val owner = parameter.getStrictParentOfType<KtTypeParameterListOwner>() ?: return@buildTypeParameter
|
|
||||||
for (typeConstraint in owner.typeConstraints) {
|
|
||||||
val subjectName = typeConstraint.subjectTypeParameterName?.getReferencedNameAsName()
|
|
||||||
if (subjectName == parameterName) {
|
|
||||||
bounds += typeConstraint.boundTypeReference.toFirOrErrorType()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
addDefaultBoundIfNecessary()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO introduce placeholder projection type
|
// TODO introduce placeholder projection type
|
||||||
private fun KtTypeProjection.isPlaceholderProjection() =
|
private fun KtTypeProjection.isPlaceholderProjection() =
|
||||||
projectionKind == KtProjectionKind.NONE && (typeReference?.typeElement as? KtUserType)?.referencedName == "_"
|
projectionKind == KtProjectionKind.NONE && (typeReference?.typeElement as? KtUserType)?.referencedName == "_"
|
||||||
|
|||||||
+5
-4
@@ -218,7 +218,7 @@ class FirSyntheticCallGenerator(
|
|||||||
containingDeclarations = components.containingDeclarations
|
containingDeclarations = components.containingDeclarations
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun generateSyntheticSelectTypeParameter(): Pair<FirTypeParameter, FirResolvedTypeRef> {
|
private fun generateSyntheticSelectTypeParameter(functionSymbol: FirSyntheticFunctionSymbol): Pair<FirTypeParameter, FirResolvedTypeRef> {
|
||||||
val typeParameterSymbol = FirTypeParameterSymbol()
|
val typeParameterSymbol = FirTypeParameterSymbol()
|
||||||
val typeParameter =
|
val typeParameter =
|
||||||
buildTypeParameter {
|
buildTypeParameter {
|
||||||
@@ -227,6 +227,7 @@ class FirSyntheticCallGenerator(
|
|||||||
resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
|
resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
|
||||||
name = Name.identifier("K")
|
name = Name.identifier("K")
|
||||||
symbol = typeParameterSymbol
|
symbol = typeParameterSymbol
|
||||||
|
containingDeclarationSymbol = functionSymbol
|
||||||
variance = Variance.INVARIANT
|
variance = Variance.INVARIANT
|
||||||
isReified = false
|
isReified = false
|
||||||
addDefaultBoundIfNecessary()
|
addDefaultBoundIfNecessary()
|
||||||
@@ -242,7 +243,7 @@ class FirSyntheticCallGenerator(
|
|||||||
// fun <K> select(vararg values: K): K
|
// fun <K> select(vararg values: K): K
|
||||||
val functionSymbol = FirSyntheticFunctionSymbol(callableId)
|
val functionSymbol = FirSyntheticFunctionSymbol(callableId)
|
||||||
|
|
||||||
val (typeParameter, returnType) = generateSyntheticSelectTypeParameter()
|
val (typeParameter, returnType) = generateSyntheticSelectTypeParameter(functionSymbol)
|
||||||
|
|
||||||
val argumentType = buildResolvedTypeRef { type = returnType.type.createArrayType() }
|
val argumentType = buildResolvedTypeRef { type = returnType.type.createArrayType() }
|
||||||
val typeArgument = buildTypeProjectionWithVariance {
|
val typeArgument = buildTypeProjectionWithVariance {
|
||||||
@@ -264,7 +265,7 @@ class FirSyntheticCallGenerator(
|
|||||||
// fun <X> test(a: X) = a!!
|
// fun <X> test(a: X) = a!!
|
||||||
// `X` is not a subtype of `Any` and hence cannot satisfy `K` if it had an upper bound of `Any`.
|
// `X` is not a subtype of `Any` and hence cannot satisfy `K` if it had an upper bound of `Any`.
|
||||||
val functionSymbol = FirSyntheticFunctionSymbol(SyntheticCallableId.CHECK_NOT_NULL)
|
val functionSymbol = FirSyntheticFunctionSymbol(SyntheticCallableId.CHECK_NOT_NULL)
|
||||||
val (typeParameter, returnType) = generateSyntheticSelectTypeParameter()
|
val (typeParameter, returnType) = generateSyntheticSelectTypeParameter(functionSymbol)
|
||||||
|
|
||||||
val argumentType = buildResolvedTypeRef {
|
val argumentType = buildResolvedTypeRef {
|
||||||
type = returnType.type.withNullability(ConeNullability.NULLABLE, session.typeContext)
|
type = returnType.type.withNullability(ConeNullability.NULLABLE, session.typeContext)
|
||||||
@@ -292,7 +293,7 @@ class FirSyntheticCallGenerator(
|
|||||||
// fun <X> test(a: X, b: X) = a ?: b
|
// fun <X> test(a: X, b: X) = a ?: b
|
||||||
// `X` is not a subtype of `Any` and hence cannot satisfy `K` if it had an upper bound of `Any`.
|
// `X` is not a subtype of `Any` and hence cannot satisfy `K` if it had an upper bound of `Any`.
|
||||||
val functionSymbol = FirSyntheticFunctionSymbol(SyntheticCallableId.ELVIS_NOT_NULL)
|
val functionSymbol = FirSyntheticFunctionSymbol(SyntheticCallableId.ELVIS_NOT_NULL)
|
||||||
val (typeParameter, rightArgumentType) = generateSyntheticSelectTypeParameter()
|
val (typeParameter, rightArgumentType) = generateSyntheticSelectTypeParameter(functionSymbol)
|
||||||
|
|
||||||
val leftArgumentType = buildResolvedTypeRef {
|
val leftArgumentType = buildResolvedTypeRef {
|
||||||
type = rightArgumentType.coneTypeUnsafe<ConeKotlinType>().withNullability(ConeNullability.NULLABLE, session.typeContext)
|
type = rightArgumentType.coneTypeUnsafe<ConeKotlinType>().withNullability(ConeNullability.NULLABLE, session.typeContext)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.fir.FirElement
|
|||||||
import org.jetbrains.kotlin.fir.FirModuleData
|
import org.jetbrains.kotlin.fir.FirModuleData
|
||||||
import org.jetbrains.kotlin.fir.FirSourceElement
|
import org.jetbrains.kotlin.fir.FirSourceElement
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
|
||||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
@@ -28,6 +29,7 @@ abstract class FirTypeParameter : FirTypeParameterRef, FirAnnotatedDeclaration()
|
|||||||
abstract override val attributes: FirDeclarationAttributes
|
abstract override val attributes: FirDeclarationAttributes
|
||||||
abstract val name: Name
|
abstract val name: Name
|
||||||
abstract override val symbol: FirTypeParameterSymbol
|
abstract override val symbol: FirTypeParameterSymbol
|
||||||
|
abstract val containingDeclarationSymbol: FirBasedSymbol<*>?
|
||||||
abstract val variance: Variance
|
abstract val variance: Variance
|
||||||
abstract val isReified: Boolean
|
abstract val isReified: Boolean
|
||||||
abstract val bounds: List<FirTypeRef>
|
abstract val bounds: List<FirTypeRef>
|
||||||
|
|||||||
+3
@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
|||||||
import org.jetbrains.kotlin.fir.declarations.FirTypeParameter
|
import org.jetbrains.kotlin.fir.declarations.FirTypeParameter
|
||||||
import org.jetbrains.kotlin.fir.declarations.impl.FirTypeParameterImpl
|
import org.jetbrains.kotlin.fir.declarations.impl.FirTypeParameterImpl
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
|
||||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||||
import org.jetbrains.kotlin.fir.visitors.*
|
import org.jetbrains.kotlin.fir.visitors.*
|
||||||
@@ -36,6 +37,7 @@ class FirTypeParameterBuilder : FirAnnotationContainerBuilder {
|
|||||||
var attributes: FirDeclarationAttributes = FirDeclarationAttributes()
|
var attributes: FirDeclarationAttributes = FirDeclarationAttributes()
|
||||||
lateinit var name: Name
|
lateinit var name: Name
|
||||||
lateinit var symbol: FirTypeParameterSymbol
|
lateinit var symbol: FirTypeParameterSymbol
|
||||||
|
var containingDeclarationSymbol: FirBasedSymbol<*>? = null
|
||||||
lateinit var variance: Variance
|
lateinit var variance: Variance
|
||||||
var isReified: Boolean by kotlin.properties.Delegates.notNull<Boolean>()
|
var isReified: Boolean by kotlin.properties.Delegates.notNull<Boolean>()
|
||||||
val bounds: MutableList<FirTypeRef> = mutableListOf()
|
val bounds: MutableList<FirTypeRef> = mutableListOf()
|
||||||
@@ -50,6 +52,7 @@ class FirTypeParameterBuilder : FirAnnotationContainerBuilder {
|
|||||||
attributes,
|
attributes,
|
||||||
name,
|
name,
|
||||||
symbol,
|
symbol,
|
||||||
|
containingDeclarationSymbol,
|
||||||
variance,
|
variance,
|
||||||
isReified,
|
isReified,
|
||||||
bounds,
|
bounds,
|
||||||
|
|||||||
+2
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin
|
|||||||
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirTypeParameter
|
import org.jetbrains.kotlin.fir.declarations.FirTypeParameter
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
|
||||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
@@ -31,6 +32,7 @@ internal class FirTypeParameterImpl(
|
|||||||
override val attributes: FirDeclarationAttributes,
|
override val attributes: FirDeclarationAttributes,
|
||||||
override val name: Name,
|
override val name: Name,
|
||||||
override val symbol: FirTypeParameterSymbol,
|
override val symbol: FirTypeParameterSymbol,
|
||||||
|
override val containingDeclarationSymbol: FirBasedSymbol<*>?,
|
||||||
override val variance: Variance,
|
override val variance: Variance,
|
||||||
override val isReified: Boolean,
|
override val isReified: Boolean,
|
||||||
override val bounds: MutableList<FirTypeRef>,
|
override val bounds: MutableList<FirTypeRef>,
|
||||||
|
|||||||
+1
@@ -289,6 +289,7 @@ object NodeConfigurator : AbstractFieldConfigurator<FirTreeBuilder>(FirTreeBuild
|
|||||||
typeParameter.configure {
|
typeParameter.configure {
|
||||||
+name
|
+name
|
||||||
+symbol("FirTypeParameterSymbol")
|
+symbol("FirTypeParameterSymbol")
|
||||||
|
+field("containingDeclarationSymbol", firBasedSymbolType, "*", nullable = true)
|
||||||
+field(varianceType)
|
+field(varianceType)
|
||||||
+booleanField("isReified")
|
+booleanField("isReified")
|
||||||
+fieldList("bounds", typeRef, withReplace = true)
|
+fieldList("bounds", typeRef, withReplace = true)
|
||||||
|
|||||||
+15
-15
@@ -102,23 +102,23 @@ fun SmartPrinter.printImplementation(implementation: Implementation) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
element.allFields.filter { it.type.contains("Symbol") && it !is FieldList }
|
element.allFields.filter {
|
||||||
.takeIf {
|
it.name != "containingDeclarationSymbol" && it.type.contains("Symbol") && it !is FieldList
|
||||||
it.isNotEmpty() && !isInterface && !isAbstract &&
|
}.takeIf {
|
||||||
!element.type.contains("Reference")
|
it.isNotEmpty() && !isInterface && !isAbstract &&
|
||||||
&& !element.type.contains("ResolvedQualifier")
|
!element.type.contains("Reference")
|
||||||
&& !element.type.endsWith("Ref")
|
&& !element.type.contains("ResolvedQualifier")
|
||||||
}
|
&& !element.type.endsWith("Ref")
|
||||||
?.let { symbolFields ->
|
}?.let { symbolFields ->
|
||||||
println("init {")
|
println("init {")
|
||||||
for (symbolField in symbolFields) {
|
for (symbolField in symbolFields) {
|
||||||
withIndent {
|
withIndent {
|
||||||
println("${symbolField.name}${symbolField.call()}bind(this)")
|
println("${symbolField.name}${symbolField.call()}bind(this)")
|
||||||
}
|
|
||||||
}
|
}
|
||||||
println("}")
|
|
||||||
println()
|
|
||||||
}
|
}
|
||||||
|
println("}")
|
||||||
|
println()
|
||||||
|
}
|
||||||
|
|
||||||
fun Field.acceptString(): String = "${name}${call()}accept(visitor, data)"
|
fun Field.acceptString(): String = "${name}${call()}accept(visitor, data)"
|
||||||
if (!isInterface && !isAbstract) {
|
if (!isInterface && !isAbstract) {
|
||||||
|
|||||||
Reference in New Issue
Block a user