@@ -409,14 +409,14 @@ class ConstraintFix {
409409 FixKind Kind;
410410 ConstraintLocator *Locator;
411411
412- // / Determines whether this fix is simplify a warning which doesn't
413- // / require immediate source changes.
414- bool IsWarning;
412+ // / The behavior limit to apply to the diagnostics emitted.
413+ DiagnosticBehavior behaviorLimit;
415414
416415public:
417416 ConstraintFix (ConstraintSystem &cs, FixKind kind, ConstraintLocator *locator,
418- bool warning = false )
419- : CS(cs), Kind(kind), Locator(locator), IsWarning(warning) {}
417+ DiagnosticBehavior behaviorLimit =
418+ DiagnosticBehavior::Unspecified)
419+ : CS(cs), Kind(kind), Locator(locator), behaviorLimit(behaviorLimit) {}
420420
421421 virtual ~ConstraintFix ();
422422
@@ -427,7 +427,14 @@ class ConstraintFix {
427427
428428 FixKind getKind () const { return Kind; }
429429
430- bool isWarning () const { return IsWarning; }
430+ bool isWarning () const {
431+ return behaviorLimit == DiagnosticBehavior::Warning ||
432+ behaviorLimit == DiagnosticBehavior::Ignore;
433+ }
434+
435+ // / The diagnostic behavior limit that will be applied to any emitted
436+ // / diagnostics.
437+ DiagnosticBehavior diagBehaviorLimit () const { return behaviorLimit; }
431438
432439 virtual std::string getName () const = 0;
433440
@@ -672,14 +679,17 @@ class ContextualMismatch : public ConstraintFix {
672679 Type LHS, RHS;
673680
674681 ContextualMismatch (ConstraintSystem &cs, Type lhs, Type rhs,
675- ConstraintLocator *locator, bool warning)
676- : ConstraintFix(cs, FixKind::ContextualMismatch, locator, warning),
682+ ConstraintLocator *locator,
683+ DiagnosticBehavior behaviorLimit)
684+ : ConstraintFix(cs, FixKind::ContextualMismatch, locator, behaviorLimit),
677685 LHS (lhs), RHS(rhs) {}
678686
679687protected:
680688 ContextualMismatch (ConstraintSystem &cs, FixKind kind, Type lhs, Type rhs,
681- ConstraintLocator *locator, bool warning = false )
682- : ConstraintFix(cs, kind, locator, warning), LHS(lhs), RHS(rhs) {}
689+ ConstraintLocator *locator,
690+ DiagnosticBehavior behaviorLimit =
691+ DiagnosticBehavior::Unspecified)
692+ : ConstraintFix(cs, kind, locator, behaviorLimit), LHS(lhs), RHS(rhs) {}
683693
684694public:
685695 std::string getName () const override { return " fix contextual mismatch" ; }
@@ -766,9 +776,10 @@ class MarkExplicitlyEscaping final : public ContextualMismatch {
766776// / Mark function type as being part of a global actor.
767777class MarkGlobalActorFunction final : public ContextualMismatch {
768778 MarkGlobalActorFunction (ConstraintSystem &cs, Type lhs, Type rhs,
769- ConstraintLocator *locator, bool warning)
779+ ConstraintLocator *locator,
780+ DiagnosticBehavior behaviorLimit)
770781 : ContextualMismatch(cs, FixKind::MarkGlobalActorFunction, lhs, rhs,
771- locator, warning ) {
782+ locator, behaviorLimit ) {
772783 }
773784
774785public:
@@ -778,7 +789,7 @@ class MarkGlobalActorFunction final : public ContextualMismatch {
778789
779790 static MarkGlobalActorFunction *create (ConstraintSystem &cs, Type lhs,
780791 Type rhs, ConstraintLocator *locator,
781- bool warning );
792+ DiagnosticBehavior behaviorLimit );
782793
783794 static bool classof (ConstraintFix *fix) {
784795 return fix->getKind () == FixKind::MarkGlobalActorFunction;
@@ -814,9 +825,9 @@ class ForceOptional final : public ContextualMismatch {
814825class AddSendableAttribute final : public ContextualMismatch {
815826 AddSendableAttribute (ConstraintSystem &cs, FunctionType *fromType,
816827 FunctionType *toType, ConstraintLocator *locator,
817- bool warning )
828+ DiagnosticBehavior behaviorLimit )
818829 : ContextualMismatch(cs, FixKind::AddSendableAttribute, fromType, toType,
819- locator, warning ) {
830+ locator, behaviorLimit ) {
820831 assert (fromType->isSendable () != toType->isSendable ());
821832 }
822833
@@ -829,7 +840,7 @@ class AddSendableAttribute final : public ContextualMismatch {
829840 FunctionType *fromType,
830841 FunctionType *toType,
831842 ConstraintLocator *locator,
832- bool warning );
843+ DiagnosticBehavior behaviorLimit );
833844
834845 static bool classof (ConstraintFix *fix) {
835846 return fix->getKind () == FixKind::AddSendableAttribute;
@@ -1395,7 +1406,8 @@ class AllowInvalidPartialApplication final : public ConstraintFix {
13951406 AllowInvalidPartialApplication (bool isWarning, ConstraintSystem &cs,
13961407 ConstraintLocator *locator)
13971408 : ConstraintFix(cs, FixKind::AllowInvalidPartialApplication, locator,
1398- isWarning) {}
1409+ isWarning ? DiagnosticBehavior::Warning
1410+ : DiagnosticBehavior::Unspecified) {}
13991411
14001412public:
14011413 std::string getName () const override {
@@ -2129,8 +2141,10 @@ class AllowArgumentMismatch : public ContextualMismatch {
21292141
21302142 AllowArgumentMismatch (ConstraintSystem &cs, FixKind kind, Type argType,
21312143 Type paramType, ConstraintLocator *locator,
2132- bool warning = false )
2133- : ContextualMismatch(cs, kind, argType, paramType, locator, warning) {}
2144+ DiagnosticBehavior behaviorLimit =
2145+ DiagnosticBehavior::Unspecified)
2146+ : ContextualMismatch(
2147+ cs, kind, argType, paramType, locator, behaviorLimit) {}
21342148
21352149public:
21362150 std::string getName () const override {
@@ -2278,9 +2292,9 @@ class TreatEphemeralAsNonEphemeral final : public AllowArgumentMismatch {
22782292 TreatEphemeralAsNonEphemeral (ConstraintSystem &cs, ConstraintLocator *locator,
22792293 Type srcType, Type dstType,
22802294 ConversionRestrictionKind conversionKind,
2281- bool downgradeToWarning )
2295+ DiagnosticBehavior behaviorLimit )
22822296 : AllowArgumentMismatch(cs, FixKind::TreatEphemeralAsNonEphemeral,
2283- srcType, dstType, locator, downgradeToWarning ),
2297+ srcType, dstType, locator, behaviorLimit ),
22842298 ConversionKind (conversionKind) {}
22852299
22862300public:
@@ -2444,7 +2458,7 @@ class AllowCoercionToForceCast final : public ContextualMismatch {
24442458 AllowCoercionToForceCast (ConstraintSystem &cs, Type fromType, Type toType,
24452459 ConstraintLocator *locator)
24462460 : ContextualMismatch(cs, FixKind::AllowCoercionToForceCast, fromType,
2447- toType, locator, /* warning */ true ) {}
2461+ toType, locator, DiagnosticBehavior::Warning ) {}
24482462
24492463public:
24502464 std::string getName () const override {
@@ -2558,7 +2572,7 @@ class SpecifyLabelToAssociateTrailingClosure final : public ConstraintFix {
25582572 SpecifyLabelToAssociateTrailingClosure (ConstraintSystem &cs,
25592573 ConstraintLocator *locator)
25602574 : ConstraintFix(cs, FixKind::SpecifyLabelToAssociateTrailingClosure,
2561- locator, /* isWarning= */ true ) {}
2575+ locator, DiagnosticBehavior::Warning ) {}
25622576
25632577public:
25642578 std::string getName () const override {
@@ -2728,7 +2742,7 @@ class SpecifyBaseTypeForOptionalUnresolvedMember final : public ConstraintFix {
27282742 DeclNameRef memberName,
27292743 ConstraintLocator *locator)
27302744 : ConstraintFix(cs, FixKind::SpecifyBaseTypeForOptionalUnresolvedMember,
2731- locator, /* isWarning= */ true ),
2745+ locator, DiagnosticBehavior::Warning ),
27322746 MemberName (memberName) {}
27332747 DeclNameRef MemberName;
27342748
@@ -2759,7 +2773,7 @@ class CheckedCastContextualMismatchWarning : public ContextualMismatch {
27592773 CheckedCastKind kind,
27602774 ConstraintLocator *locator)
27612775 : ContextualMismatch(cs, fixKind, fromType, toType, locator,
2762- /* isWarning */ true ),
2776+ DiagnosticBehavior::Warning ),
27632777 CastKind (kind) {}
27642778 CheckedCastKind CastKind;
27652779};
@@ -2918,7 +2932,7 @@ class AllowTupleLabelMismatch final : public ContextualMismatch {
29182932 AllowTupleLabelMismatch (ConstraintSystem &cs, Type fromType, Type toType,
29192933 ConstraintLocator *locator)
29202934 : ContextualMismatch(cs, FixKind::AllowTupleLabelMismatch, fromType,
2921- toType, locator, /* warning */ true ) {}
2935+ toType, locator, DiagnosticBehavior::Warning ) {}
29222936
29232937public:
29242938 std::string getName () const override { return " allow tuple label mismatch" ; }
0 commit comments