@@ -409,14 +409,14 @@ class ConstraintFix {
409
409
FixKind Kind;
410
410
ConstraintLocator *Locator;
411
411
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;
415
414
416
415
public:
417
416
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) {}
420
420
421
421
virtual ~ConstraintFix ();
422
422
@@ -427,7 +427,14 @@ class ConstraintFix {
427
427
428
428
FixKind getKind () const { return Kind; }
429
429
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; }
431
438
432
439
virtual std::string getName () const = 0;
433
440
@@ -672,14 +679,17 @@ class ContextualMismatch : public ConstraintFix {
672
679
Type LHS, RHS;
673
680
674
681
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),
677
685
LHS (lhs), RHS(rhs) {}
678
686
679
687
protected:
680
688
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) {}
683
693
684
694
public:
685
695
std::string getName () const override { return " fix contextual mismatch" ; }
@@ -766,9 +776,10 @@ class MarkExplicitlyEscaping final : public ContextualMismatch {
766
776
// / Mark function type as being part of a global actor.
767
777
class MarkGlobalActorFunction final : public ContextualMismatch {
768
778
MarkGlobalActorFunction (ConstraintSystem &cs, Type lhs, Type rhs,
769
- ConstraintLocator *locator, bool warning)
779
+ ConstraintLocator *locator,
780
+ DiagnosticBehavior behaviorLimit)
770
781
: ContextualMismatch(cs, FixKind::MarkGlobalActorFunction, lhs, rhs,
771
- locator, warning ) {
782
+ locator, behaviorLimit ) {
772
783
}
773
784
774
785
public:
@@ -778,7 +789,7 @@ class MarkGlobalActorFunction final : public ContextualMismatch {
778
789
779
790
static MarkGlobalActorFunction *create (ConstraintSystem &cs, Type lhs,
780
791
Type rhs, ConstraintLocator *locator,
781
- bool warning );
792
+ DiagnosticBehavior behaviorLimit );
782
793
783
794
static bool classof (ConstraintFix *fix) {
784
795
return fix->getKind () == FixKind::MarkGlobalActorFunction;
@@ -814,9 +825,9 @@ class ForceOptional final : public ContextualMismatch {
814
825
class AddSendableAttribute final : public ContextualMismatch {
815
826
AddSendableAttribute (ConstraintSystem &cs, FunctionType *fromType,
816
827
FunctionType *toType, ConstraintLocator *locator,
817
- bool warning )
828
+ DiagnosticBehavior behaviorLimit )
818
829
: ContextualMismatch(cs, FixKind::AddSendableAttribute, fromType, toType,
819
- locator, warning ) {
830
+ locator, behaviorLimit ) {
820
831
assert (fromType->isSendable () != toType->isSendable ());
821
832
}
822
833
@@ -829,7 +840,7 @@ class AddSendableAttribute final : public ContextualMismatch {
829
840
FunctionType *fromType,
830
841
FunctionType *toType,
831
842
ConstraintLocator *locator,
832
- bool warning );
843
+ DiagnosticBehavior behaviorLimit );
833
844
834
845
static bool classof (ConstraintFix *fix) {
835
846
return fix->getKind () == FixKind::AddSendableAttribute;
@@ -1395,7 +1406,8 @@ class AllowInvalidPartialApplication final : public ConstraintFix {
1395
1406
AllowInvalidPartialApplication (bool isWarning, ConstraintSystem &cs,
1396
1407
ConstraintLocator *locator)
1397
1408
: ConstraintFix(cs, FixKind::AllowInvalidPartialApplication, locator,
1398
- isWarning) {}
1409
+ isWarning ? DiagnosticBehavior::Warning
1410
+ : DiagnosticBehavior::Unspecified) {}
1399
1411
1400
1412
public:
1401
1413
std::string getName () const override {
@@ -2129,8 +2141,10 @@ class AllowArgumentMismatch : public ContextualMismatch {
2129
2141
2130
2142
AllowArgumentMismatch (ConstraintSystem &cs, FixKind kind, Type argType,
2131
2143
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) {}
2134
2148
2135
2149
public:
2136
2150
std::string getName () const override {
@@ -2278,9 +2292,9 @@ class TreatEphemeralAsNonEphemeral final : public AllowArgumentMismatch {
2278
2292
TreatEphemeralAsNonEphemeral (ConstraintSystem &cs, ConstraintLocator *locator,
2279
2293
Type srcType, Type dstType,
2280
2294
ConversionRestrictionKind conversionKind,
2281
- bool downgradeToWarning )
2295
+ DiagnosticBehavior behaviorLimit )
2282
2296
: AllowArgumentMismatch(cs, FixKind::TreatEphemeralAsNonEphemeral,
2283
- srcType, dstType, locator, downgradeToWarning ),
2297
+ srcType, dstType, locator, behaviorLimit ),
2284
2298
ConversionKind (conversionKind) {}
2285
2299
2286
2300
public:
@@ -2444,7 +2458,7 @@ class AllowCoercionToForceCast final : public ContextualMismatch {
2444
2458
AllowCoercionToForceCast (ConstraintSystem &cs, Type fromType, Type toType,
2445
2459
ConstraintLocator *locator)
2446
2460
: ContextualMismatch(cs, FixKind::AllowCoercionToForceCast, fromType,
2447
- toType, locator, /* warning */ true ) {}
2461
+ toType, locator, DiagnosticBehavior::Warning ) {}
2448
2462
2449
2463
public:
2450
2464
std::string getName () const override {
@@ -2558,7 +2572,7 @@ class SpecifyLabelToAssociateTrailingClosure final : public ConstraintFix {
2558
2572
SpecifyLabelToAssociateTrailingClosure (ConstraintSystem &cs,
2559
2573
ConstraintLocator *locator)
2560
2574
: ConstraintFix(cs, FixKind::SpecifyLabelToAssociateTrailingClosure,
2561
- locator, /* isWarning= */ true ) {}
2575
+ locator, DiagnosticBehavior::Warning ) {}
2562
2576
2563
2577
public:
2564
2578
std::string getName () const override {
@@ -2728,7 +2742,7 @@ class SpecifyBaseTypeForOptionalUnresolvedMember final : public ConstraintFix {
2728
2742
DeclNameRef memberName,
2729
2743
ConstraintLocator *locator)
2730
2744
: ConstraintFix(cs, FixKind::SpecifyBaseTypeForOptionalUnresolvedMember,
2731
- locator, /* isWarning= */ true ),
2745
+ locator, DiagnosticBehavior::Warning ),
2732
2746
MemberName (memberName) {}
2733
2747
DeclNameRef MemberName;
2734
2748
@@ -2759,7 +2773,7 @@ class CheckedCastContextualMismatchWarning : public ContextualMismatch {
2759
2773
CheckedCastKind kind,
2760
2774
ConstraintLocator *locator)
2761
2775
: ContextualMismatch(cs, fixKind, fromType, toType, locator,
2762
- /* isWarning */ true ),
2776
+ DiagnosticBehavior::Warning ),
2763
2777
CastKind (kind) {}
2764
2778
CheckedCastKind CastKind;
2765
2779
};
@@ -2918,7 +2932,7 @@ class AllowTupleLabelMismatch final : public ContextualMismatch {
2918
2932
AllowTupleLabelMismatch (ConstraintSystem &cs, Type fromType, Type toType,
2919
2933
ConstraintLocator *locator)
2920
2934
: ContextualMismatch(cs, FixKind::AllowTupleLabelMismatch, fromType,
2921
- toType, locator, /* warning */ true ) {}
2935
+ toType, locator, DiagnosticBehavior::Warning ) {}
2922
2936
2923
2937
public:
2924
2938
std::string getName () const override { return " allow tuple label mismatch" ; }
0 commit comments