Skip to content

Commit f11cc97

Browse files
rintaroNathan Hawes
authored andcommitted
[Sema] Cosolidate suppress diagnostics mechanisms
TypeCheckExprFlags::SuppressDiagnostics is now done by DiagnosticSuppression.
1 parent 242699f commit f11cc97

File tree

4 files changed

+6
-10
lines changed

4 files changed

+6
-10
lines changed

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2142,7 +2142,7 @@ class FallbackDiagnosticListener : public ExprTypeCheckListener {
21422142

21432143
void maybeProduceFallbackDiagnostic(Expr *expr) const {
21442144
if (Options.contains(TypeCheckExprFlags::SubExpressionDiagnostics) ||
2145-
Options.contains(TypeCheckExprFlags::SuppressDiagnostics))
2145+
DiagnosticSuppression::isEnabled(TC.Diags))
21462146
return;
21472147

21482148
// Before producing fatal error here, let's check if there are any "error"
@@ -2184,8 +2184,7 @@ Type TypeChecker::typeCheckExpressionImpl(Expr *&expr, DeclContext *dc,
21842184
// Construct a constraint system from this expression.
21852185
ConstraintSystemOptions csOptions = ConstraintSystemFlags::AllowFixes;
21862186

2187-
if (options.contains(TypeCheckExprFlags::SuppressDiagnostics) ||
2188-
DiagnosticSuppression::isEnabled(Diags))
2187+
if (DiagnosticSuppression::isEnabled(Diags))
21892188
csOptions |= ConstraintSystemFlags::SuppressDiagnostics;
21902189

21912190
if (options.contains(TypeCheckExprFlags::AllowUnresolvedTypeVariables))

lib/Sema/TypeCheckStmt.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "swift/AST/ASTWalker.h"
2525
#include "swift/AST/ASTVisitor.h"
2626
#include "swift/AST/DiagnosticsSema.h"
27+
#include "swift/AST/DiagnosticSuppression.h"
2728
#include "swift/AST/Identifier.h"
2829
#include "swift/AST/Initializer.h"
2930
#include "swift/AST/NameLookup.h"
@@ -1942,10 +1943,10 @@ static Expr* constructCallToSuperInit(ConstructorDecl *ctor,
19421943
r = new (Context) TryExpr(SourceLoc(), r, Type(), /*implicit=*/true);
19431944

19441945
TypeChecker &tc = *static_cast<TypeChecker *>(Context.getLazyResolver());
1946+
DiagnosticSuppression suppression(tc.Diags);
19451947
auto resultTy =
19461948
tc.typeCheckExpression(r, ctor, TypeLoc(), CTP_Unused,
1947-
TypeCheckExprFlags::IsDiscarded |
1948-
TypeCheckExprFlags::SuppressDiagnostics);
1949+
TypeCheckExprFlags::IsDiscarded);
19491950
if (!resultTy)
19501951
return nullptr;
19511952

lib/Sema/TypeChecker.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -705,8 +705,7 @@ bool swift::typeCheckExpression(DeclContext *DC, Expr *&parsedExpr) {
705705
TypeChecker &TC = createTypeChecker(ctx);
706706

707707
auto resultTy = TC.typeCheckExpression(parsedExpr, DC, TypeLoc(),
708-
ContextualTypePurpose::CTP_Unused,
709-
TypeCheckExprFlags::SuppressDiagnostics);
708+
ContextualTypePurpose::CTP_Unused);
710709
return !resultTy;
711710
}
712711

lib/Sema/TypeChecker.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,6 @@ enum class TypeCheckExprFlags {
235235
/// that we force for style or other reasons.
236236
DisableStructuralChecks = 0x02,
237237

238-
/// Set if the client wants diagnostics suppressed.
239-
SuppressDiagnostics = 0x04,
240-
241238
/// If set, the client wants a best-effort solution to the constraint system,
242239
/// but can tolerate a solution where all of the constraints are solved, but
243240
/// not all type variables have been determined. In this case, the constraint

0 commit comments

Comments
 (0)