Skip to content

Commit f263914

Browse files
committed
[Sema] Cosolidate suppress diagnostics mechanisms
TypeCheckExprFlags::SuppressDiagnostics is now done by DiagnosticSuppression.
1 parent 94cdb51 commit f263914

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
@@ -2134,7 +2134,7 @@ class FallbackDiagnosticListener : public ExprTypeCheckListener {
21342134

21352135
void maybeProduceFallbackDiagnostic(Expr *expr) const {
21362136
if (Options.contains(TypeCheckExprFlags::SubExpressionDiagnostics) ||
2137-
Options.contains(TypeCheckExprFlags::SuppressDiagnostics))
2137+
DiagnosticSuppression::isEnabled(TC.Diags))
21382138
return;
21392139

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

2179-
if (options.contains(TypeCheckExprFlags::SuppressDiagnostics) ||
2180-
DiagnosticSuppression::isEnabled(Diags))
2179+
if (DiagnosticSuppression::isEnabled(Diags))
21812180
csOptions |= ConstraintSystemFlags::SuppressDiagnostics;
21822181

21832182
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"
@@ -2031,10 +2032,10 @@ Expr* TypeChecker::constructCallToSuperInit(ConstructorDecl *ctor,
20312032
if (ctor->hasThrows())
20322033
r = new (Context) TryExpr(SourceLoc(), r, Type(), /*implicit=*/true);
20332034

2035+
DiagnosticSuppression suppression(Diags);
20342036
auto resultTy =
20352037
typeCheckExpression(r, ctor, TypeLoc(), CTP_Unused,
2036-
TypeCheckExprFlags::IsDiscarded |
2037-
TypeCheckExprFlags::SuppressDiagnostics);
2038+
TypeCheckExprFlags::IsDiscarded);
20382039
if (!resultTy)
20392040
return nullptr;
20402041

lib/Sema/TypeChecker.cpp

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

762762
auto resultTy = TC.typeCheckExpression(parsedExpr, DC, TypeLoc(),
763-
ContextualTypePurpose::CTP_Unused,
764-
TypeCheckExprFlags::SuppressDiagnostics);
763+
ContextualTypePurpose::CTP_Unused);
765764
return !resultTy;
766765
}
767766

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)