@@ -401,14 +401,14 @@ class ConstraintFix {
401401 FixKind Kind;
402402 ConstraintLocator *Locator;
403403
404- // / Determines whether this fix is simplify a warning which doesn't
405- // / require immediate source changes.
406- bool IsWarning;
404+ // / The behavior limit to apply to the diagnostics emitted.
405+ DiagnosticBehavior behaviorLimit;
407406
408407public:
409408 ConstraintFix (ConstraintSystem &cs, FixKind kind, ConstraintLocator *locator,
410- bool warning = false )
411- : CS(cs), Kind(kind), Locator(locator), IsWarning(warning) {}
409+ DiagnosticBehavior behaviorLimit =
410+ DiagnosticBehavior::Unspecified)
411+ : CS(cs), Kind(kind), Locator(locator), behaviorLimit(behaviorLimit) {}
412412
413413 virtual ~ConstraintFix ();
414414
@@ -419,7 +419,14 @@ class ConstraintFix {
419419
420420 FixKind getKind () const { return Kind; }
421421
422- bool isWarning () const { return IsWarning; }
422+ bool isWarning () const {
423+ return behaviorLimit == DiagnosticBehavior::Warning ||
424+ behaviorLimit == DiagnosticBehavior::Ignore;
425+ }
426+
427+ // / The diagnostic behavior limit that will be applied to any emitted
428+ // / diagnostics.
429+ DiagnosticBehavior diagBehaviorLimit () const { return behaviorLimit; }
423430
424431 virtual std::string getName () const = 0;
425432
@@ -664,14 +671,17 @@ class ContextualMismatch : public ConstraintFix {
664671 Type LHS, RHS;
665672
666673 ContextualMismatch (ConstraintSystem &cs, Type lhs, Type rhs,
667- ConstraintLocator *locator, bool warning)
668- : ConstraintFix(cs, FixKind::ContextualMismatch, locator, warning),
674+ ConstraintLocator *locator,
675+ DiagnosticBehavior behaviorLimit)
676+ : ConstraintFix(cs, FixKind::ContextualMismatch, locator, behaviorLimit),
669677 LHS (lhs), RHS(rhs) {}
670678
671679protected:
672680 ContextualMismatch (ConstraintSystem &cs, FixKind kind, Type lhs, Type rhs,
673- ConstraintLocator *locator, bool warning = false )
674- : ConstraintFix(cs, kind, locator, warning), LHS(lhs), RHS(rhs) {}
681+ ConstraintLocator *locator,
682+ DiagnosticBehavior behaviorLimit =
683+ DiagnosticBehavior::Unspecified)
684+ : ConstraintFix(cs, kind, locator, behaviorLimit), LHS(lhs), RHS(rhs) {}
675685
676686public:
677687 std::string getName () const override { return " fix contextual mismatch" ; }
@@ -755,9 +765,10 @@ class MarkExplicitlyEscaping final : public ContextualMismatch {
755765// / Mark function type as being part of a global actor.
756766class MarkGlobalActorFunction final : public ContextualMismatch {
757767 MarkGlobalActorFunction (ConstraintSystem &cs, Type lhs, Type rhs,
758- ConstraintLocator *locator, bool warning)
768+ ConstraintLocator *locator,
769+ DiagnosticBehavior behaviorLimit)
759770 : ContextualMismatch(cs, FixKind::MarkGlobalActorFunction, lhs, rhs,
760- locator, warning ) {
771+ locator, behaviorLimit ) {
761772 }
762773
763774public:
@@ -767,7 +778,7 @@ class MarkGlobalActorFunction final : public ContextualMismatch {
767778
768779 static MarkGlobalActorFunction *create (ConstraintSystem &cs, Type lhs,
769780 Type rhs, ConstraintLocator *locator,
770- bool warning );
781+ DiagnosticBehavior behaviorLimit );
771782
772783 static bool classof (ConstraintFix *fix) {
773784 return fix->getKind () == FixKind::MarkGlobalActorFunction;
@@ -803,9 +814,9 @@ class ForceOptional final : public ContextualMismatch {
803814class AddSendableAttribute final : public ContextualMismatch {
804815 AddSendableAttribute (ConstraintSystem &cs, FunctionType *fromType,
805816 FunctionType *toType, ConstraintLocator *locator,
806- bool warning )
817+ DiagnosticBehavior behaviorLimit )
807818 : ContextualMismatch(cs, FixKind::AddSendableAttribute, fromType, toType,
808- locator, warning ) {
819+ locator, behaviorLimit ) {
809820 assert (fromType->isSendable () != toType->isSendable ());
810821 }
811822
@@ -818,7 +829,7 @@ class AddSendableAttribute final : public ContextualMismatch {
818829 FunctionType *fromType,
819830 FunctionType *toType,
820831 ConstraintLocator *locator,
821- bool warning );
832+ DiagnosticBehavior behaviorLimit );
822833
823834 static bool classof (ConstraintFix *fix) {
824835 return fix->getKind () == FixKind::AddSendableAttribute;
@@ -1384,7 +1395,8 @@ class AllowInvalidPartialApplication final : public ConstraintFix {
13841395 AllowInvalidPartialApplication (bool isWarning, ConstraintSystem &cs,
13851396 ConstraintLocator *locator)
13861397 : ConstraintFix(cs, FixKind::AllowInvalidPartialApplication, locator,
1387- isWarning) {}
1398+ isWarning ? DiagnosticBehavior::Warning
1399+ : DiagnosticBehavior::Unspecified) {}
13881400
13891401public:
13901402 std::string getName () const override {
@@ -2118,8 +2130,10 @@ class AllowArgumentMismatch : public ContextualMismatch {
21182130
21192131 AllowArgumentMismatch (ConstraintSystem &cs, FixKind kind, Type argType,
21202132 Type paramType, ConstraintLocator *locator,
2121- bool warning = false )
2122- : ContextualMismatch(cs, kind, argType, paramType, locator, warning) {}
2133+ DiagnosticBehavior behaviorLimit =
2134+ DiagnosticBehavior::Unspecified)
2135+ : ContextualMismatch(
2136+ cs, kind, argType, paramType, locator, behaviorLimit) {}
21232137
21242138public:
21252139 std::string getName () const override {
@@ -2267,9 +2281,9 @@ class TreatEphemeralAsNonEphemeral final : public AllowArgumentMismatch {
22672281 TreatEphemeralAsNonEphemeral (ConstraintSystem &cs, ConstraintLocator *locator,
22682282 Type srcType, Type dstType,
22692283 ConversionRestrictionKind conversionKind,
2270- bool downgradeToWarning )
2284+ DiagnosticBehavior behaviorLimit )
22712285 : AllowArgumentMismatch(cs, FixKind::TreatEphemeralAsNonEphemeral,
2272- srcType, dstType, locator, downgradeToWarning ),
2286+ srcType, dstType, locator, behaviorLimit ),
22732287 ConversionKind (conversionKind) {}
22742288
22752289public:
@@ -2433,7 +2447,7 @@ class AllowCoercionToForceCast final : public ContextualMismatch {
24332447 AllowCoercionToForceCast (ConstraintSystem &cs, Type fromType, Type toType,
24342448 ConstraintLocator *locator)
24352449 : ContextualMismatch(cs, FixKind::AllowCoercionToForceCast, fromType,
2436- toType, locator, /* warning */ true ) {}
2450+ toType, locator, DiagnosticBehavior::Warning ) {}
24372451
24382452public:
24392453 std::string getName () const override {
@@ -2547,7 +2561,7 @@ class SpecifyLabelToAssociateTrailingClosure final : public ConstraintFix {
25472561 SpecifyLabelToAssociateTrailingClosure (ConstraintSystem &cs,
25482562 ConstraintLocator *locator)
25492563 : ConstraintFix(cs, FixKind::SpecifyLabelToAssociateTrailingClosure,
2550- locator, /* isWarning= */ true ) {}
2564+ locator, DiagnosticBehavior::Warning ) {}
25512565
25522566public:
25532567 std::string getName () const override {
@@ -2717,7 +2731,7 @@ class SpecifyBaseTypeForOptionalUnresolvedMember final : public ConstraintFix {
27172731 DeclNameRef memberName,
27182732 ConstraintLocator *locator)
27192733 : ConstraintFix(cs, FixKind::SpecifyBaseTypeForOptionalUnresolvedMember,
2720- locator, /* isWarning= */ true ),
2734+ locator, DiagnosticBehavior::Warning ),
27212735 MemberName (memberName) {}
27222736 DeclNameRef MemberName;
27232737
@@ -2748,7 +2762,7 @@ class CheckedCastContextualMismatchWarning : public ContextualMismatch {
27482762 CheckedCastKind kind,
27492763 ConstraintLocator *locator)
27502764 : ContextualMismatch(cs, fixKind, fromType, toType, locator,
2751- /* isWarning */ true ),
2765+ DiagnosticBehavior::Warning ),
27522766 CastKind (kind) {}
27532767 CheckedCastKind CastKind;
27542768};
@@ -2859,7 +2873,7 @@ class AllowTupleLabelMismatch final : public ContextualMismatch {
28592873 AllowTupleLabelMismatch (ConstraintSystem &cs, Type fromType, Type toType,
28602874 ConstraintLocator *locator)
28612875 : ContextualMismatch(cs, FixKind::AllowTupleLabelMismatch, fromType,
2862- toType, locator, /* warning */ true ) {}
2876+ toType, locator, DiagnosticBehavior::Warning ) {}
28632877
28642878public:
28652879 std::string getName () const override { return " allow tuple label mismatch" ; }
0 commit comments