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
@@ -468,6 +468,7 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver() {
private fun createFunctionalType(typeRef: FirFunctionTypeRef): ConeClassLikeType {
val parameters =
listOfNotNull(typeRef.receiverTypeRef?.coneType) +
typeRef.contextReceiverTypeRefs.map { it.coneType } +
typeRef.valueParameters.map { it.returnTypeRef.coneType.withParameterNameAnnotation(it) } +
listOf(typeRef.returnTypeRef.coneType)
val classId = if (typeRef.isSuspend) {
@@ -475,7 +476,19 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver() {
} else {
StandardClassIds.FunctionN(typeRef.parametersCount)
}
val attributes = typeRef.annotations.computeTypeAttributes(session)
val attributes = typeRef.annotations.computeTypeAttributes(
session,
predefined = buildList {
if (typeRef.receiverTypeRef != null) {
add(CompilerConeAttributes.ExtensionFunctionType)
}
if (typeRef.contextReceiverTypeRefs.isNotEmpty()) {
add(CompilerConeAttributes.ContextFunctionTypeParams(typeRef.contextReceiverTypeRefs.size))
}
}
)
val symbol = resolveBuiltInQualified(classId, session)
return ConeClassLikeTypeImpl(
symbol.toLookupTag().also {