[FIR] Initialize annotations in FirErrorTypeRef

^KT-62447 Fixed
^KT-62628 Fixed
This commit is contained in:
Ivan Kochurkin
2023-10-19 18:56:34 +02:00
committed by Space Team
parent ec3cfdefcb
commit bb937a8a21
24 changed files with 127 additions and 73 deletions
@@ -120,6 +120,7 @@ class FirSpecificTypeResolverTransformer(
if (resolvedType != null) {
type = resolvedType
}
annotations += functionTypeRef.annotations
this.diagnostic = diagnostic ?: (resolvedType as? ConeErrorType)?.diagnostic
?: ConeSimpleDiagnostic("Unresolved function type: ${functionTypeRef.render()}")
}
@@ -188,6 +189,7 @@ class FirSpecificTypeResolverTransformer(
delegatedTypeRef = typeRef
type = resolvedType
annotations += typeRef.annotations
val partiallyResolvedTypeRef = tryCalculatingPartiallyResolvedTypeRef(typeRef, scopeClassDeclaration)
this.partiallyResolvedTypeRef = partiallyResolvedTypeRef
@@ -365,6 +365,7 @@ open class FirTypeResolveTransformer(
val errorTypeRef = buildErrorTypeRef {
source = originalTypeRef.source
type = coneTypeFromCompilerRequiredPhase
annotations += originalTypeRef.annotations
delegatedTypeRef = originalTypeRef.delegatedTypeRef
diagnostic = ConeAmbiguouslyResolvedAnnotationFromPlugin(
coneTypeFromCompilerRequiredPhase,
@@ -1236,12 +1236,14 @@ open class FirDeclarationsResolveTransformer(
return when (this) {
is FirImplicitTypeRef -> buildErrorTypeRef {
diagnostic = ConeSimpleDiagnostic("No result type for initializer", DiagnosticKind.InferenceError)
annotations.addAll(this@toExpectedTypeRef.annotations)
}
is FirErrorTypeRef -> buildErrorTypeRef {
diagnostic = this@toExpectedTypeRef.diagnostic
this@toExpectedTypeRef.source?.fakeElement(KtFakeSourceElementKind.ImplicitTypeRef)?.let {
source = it
}
annotations.addAll(this@toExpectedTypeRef.annotations)
}
else -> {
buildResolvedTypeRef {
@@ -293,6 +293,7 @@ open class FirExpressionsResolveTransformer(transformer: FirAbstractBodyResolveT
val actualSuperTypeRef = actualSuperType?.toFirResolvedTypeRef(superTypeRef.source, superTypeRef) ?: buildErrorTypeRef {
source = superTypeRef.source
diagnostic = ConeSimpleDiagnostic("Not a super type", DiagnosticKind.NotASupertype)
annotations = superTypeRef.annotations.toMutableList()
}
superReferenceContainer.resultType = actualSuperTypeRef.type
superReference.replaceSuperTypeRef(actualSuperTypeRef)