FIR: Introduce ContextFunctionTypeParams type attribute

This commit is contained in:
Denis.Zharkov
2022-02-17 16:21:35 +03:00
committed by teamcity
parent f3e28c3767
commit 550d24f8c6
12 changed files with 81 additions and 43 deletions
@@ -662,6 +662,15 @@ class FirElementSerializer private constructor(
return functionType
}
fillFromPossiblyInnerType(builder, type)
if (type.hasContextReceivers) {
serializeAnnotationFromAttribute(
correspondingTypeRef?.annotations, CompilerConeAttributes.ContextFunctionTypeParams.ANNOTATION_CLASS_ID, builder,
argumentMapping = buildAnnotationArgumentMapping {
this.mapping[StandardNames.CONTEXT_FUNCTION_TYPE_PARAMETER_COUNT_NAME] =
buildConstExpression(source = null, ConstantValueKind.Int, type.contextReceiversNumberForFunctionType)
}
)
}
}
is ConeTypeParameterType -> {
val typeParameter = type.lookupTag.typeParameterSymbol.fir
@@ -721,17 +730,18 @@ class FirElementSerializer private constructor(
private fun serializeAnnotationFromAttribute(
existingAnnotations: List<FirAnnotation>?,
classId: ClassId,
builder: ProtoBuf.Type.Builder
builder: ProtoBuf.Type.Builder,
argumentMapping: FirAnnotationArgumentMapping = FirEmptyAnnotationArgumentMapping,
) {
if (existingAnnotations?.any { it.annotationTypeRef.coneTypeSafe<ConeClassLikeType>()?.classId == classId } != true) {
extension.serializeTypeAnnotation(
buildAnnotation {
annotationTypeRef = buildResolvedTypeRef {
this.type = CompilerConeAttributes.ExtensionFunctionType.ANNOTATION_CLASS_ID.constructClassLikeType(
this.type = classId.constructClassLikeType(
emptyArray(), isNullable = false
)
}
argumentMapping = FirEmptyAnnotationArgumentMapping
this.argumentMapping = argumentMapping
}, builder
)
}