[FIR] Pass container when creating FunctionType

so that it can be resolved when type annotations are demanded.
This commit is contained in:
Ting-Yuan Huang
2023-02-02 22:01:32 -08:00
committed by teamcity
parent 8f34b6599a
commit 42b08d411b
11 changed files with 136 additions and 3 deletions
@@ -443,7 +443,10 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver() {
}
}
private fun createFunctionType(typeRef: FirFunctionTypeRef): Pair<ConeClassLikeTypeImpl, ConeDiagnostic?> {
private fun createFunctionType(
typeRef: FirFunctionTypeRef,
containerDeclaration: FirDeclaration? = null
): Pair<ConeClassLikeTypeImpl, ConeDiagnostic?> {
val parameters =
typeRef.contextReceiverTypeRefs.map { it.coneType } +
listOfNotNull(typeRef.receiverTypeRef?.coneType) +
@@ -472,7 +475,8 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver() {
if (typeRef.contextReceiverTypeRefs.isNotEmpty()) {
add(CompilerConeAttributes.ContextFunctionTypeParams(typeRef.contextReceiverTypeRefs.size))
}
}
},
containerDeclaration
)
return ConeClassLikeTypeImpl(
classId.toLookupTag(),
@@ -503,7 +507,7 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver() {
isOperandOfIsOperator,
) to (result as? TypeResolutionResult.Resolved)?.typeCandidate?.diagnostic
}
is FirFunctionTypeRef -> createFunctionType(typeRef)
is FirFunctionTypeRef -> createFunctionType(typeRef, scopeClassDeclaration.containerDeclaration)
is FirDynamicTypeRef -> ConeDynamicType.create(session) to null
is FirIntersectionTypeRef -> {
val leftType = typeRef.leftType.coneType