[FIR] Add ability to specify that diagnostic collector should visit nodes with specific fake kind

This commit is contained in:
Dmitriy Novozhilov
2023-02-01 12:46:57 +02:00
committed by Space Team
parent f784628ebf
commit ad3ae0ff69
3 changed files with 18 additions and 12 deletions
@@ -44,6 +44,7 @@ object FirProjectionRelationChecker : FirBasicDeclarationChecker() {
context: CheckerContext,
reporter: DiagnosticReporter
) {
if (typeRef.source?.kind?.shouldSkipErrorTypeReporting != false) return
val type = typeRef.coneTypeSafe<ConeClassLikeType>()
val fullyExpandedType = type?.fullyExpandedType(context.session) ?: return
val declaration = fullyExpandedType.toSymbol(context.session) as? FirRegularClassSymbol ?: return
@@ -182,7 +182,7 @@ abstract class AbstractDiagnosticCollectorVisitor(
}
override fun visitTypeRef(typeRef: FirTypeRef, data: Nothing?) {
if (typeRef.source != null && typeRef.source?.kind !is KtFakeSourceElementKind) {
if (typeRef.source?.kind?.shouldSkipErrorTypeReporting == false) {
withTypeRefAnnotationContainer(typeRef) {
checkElement(typeRef)
visitNestedElements(typeRef)
@@ -200,9 +200,9 @@ abstract class AbstractDiagnosticCollectorVisitor(
// collected twice: once through resolvedTypeRef's children and another through resolvedTypeRef.delegatedTypeRef's children.
val resolvedTypeRefType = resolvedTypeRef.type
if (resolvedTypeRefType is ConeErrorType) {
super.visitResolvedTypeRef(resolvedTypeRef, data)
visitTypeRef(resolvedTypeRef, data)
}
if (resolvedTypeRef.source?.kind is KtFakeSourceElementKind) return
if (resolvedTypeRef.source?.kind?.shouldSkipErrorTypeReporting != false) return
// Even though we don't visit the children of the resolvedTypeRef we still add it as an annotation container
// and take care not to add the corresponding delegatedTypeRef. This is so that diagnostics will have access to