@@ -401,14 +401,14 @@ class ConstraintFix {
401
401
FixKind Kind;
402
402
ConstraintLocator *Locator;
403
403
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;
407
406
408
407
public:
409
408
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) {}
412
412
413
413
virtual ~ConstraintFix ();
414
414
@@ -419,7 +419,14 @@ class ConstraintFix {
419
419
420
420
FixKind getKind () const { return Kind; }
421
421
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; }
423
430
424
431
virtual std::string getName () const = 0;
425
432
@@ -664,14 +671,17 @@ class ContextualMismatch : public ConstraintFix {
664
671
Type LHS, RHS;
665
672
666
673
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),
669
677
LHS (lhs), RHS(rhs) {}
670
678
671
679
protected:
672
680
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) {}
675
685
676
686
public:
677
687
std::string getName () const override { return " fix contextual mismatch" ; }
@@ -755,9 +765,10 @@ class MarkExplicitlyEscaping final : public ContextualMismatch {
755
765
// / Mark function type as being part of a global actor.
756
766
class MarkGlobalActorFunction final : public ContextualMismatch {
757
767
MarkGlobalActorFunction (ConstraintSystem &cs, Type lhs, Type rhs,
758
- ConstraintLocator *locator, bool warning)
768
+ ConstraintLocator *locator,
769
+ DiagnosticBehavior behaviorLimit)
759
770
: ContextualMismatch(cs, FixKind::MarkGlobalActorFunction, lhs, rhs,
760
- locator, warning ) {
771
+ locator, behaviorLimit ) {
761
772
}
762
773
763
774
public:
@@ -767,7 +778,7 @@ class MarkGlobalActorFunction final : public ContextualMismatch {
767
778
768
779
static MarkGlobalActorFunction *create (ConstraintSystem &cs, Type lhs,
769
780
Type rhs, ConstraintLocator *locator,
770
- bool warning );
781
+ DiagnosticBehavior behaviorLimit );
771
782
772
783
static bool classof (ConstraintFix *fix) {
773
784
return fix->getKind () == FixKind::MarkGlobalActorFunction;
@@ -803,9 +814,9 @@ class ForceOptional final : public ContextualMismatch {
803
814
class AddSendableAttribute final : public ContextualMismatch {
804
815
AddSendableAttribute (ConstraintSystem &cs, FunctionType *fromType,
805
816
FunctionType *toType, ConstraintLocator *locator,
806
- bool warning )
817
+ DiagnosticBehavior behaviorLimit )
807
818
: ContextualMismatch(cs, FixKind::AddSendableAttribute, fromType, toType,
808
- locator, warning ) {
819
+ locator, behaviorLimit ) {
809
820
assert (fromType->isSendable () != toType->isSendable ());
810
821
}
811
822
@@ -818,7 +829,7 @@ class AddSendableAttribute final : public ContextualMismatch {
818
829
FunctionType *fromType,
819
830
FunctionType *toType,
820
831
ConstraintLocator *locator,
821
- bool warning );
832
+ DiagnosticBehavior behaviorLimit );
822
833
823
834
static bool classof (ConstraintFix *fix) {
824
835
return fix->getKind () == FixKind::AddSendableAttribute;
@@ -1384,7 +1395,8 @@ class AllowInvalidPartialApplication final : public ConstraintFix {
1384
1395
AllowInvalidPartialApplication (bool isWarning, ConstraintSystem &cs,
1385
1396
ConstraintLocator *locator)
1386
1397
: ConstraintFix(cs, FixKind::AllowInvalidPartialApplication, locator,
1387
- isWarning) {}
1398
+ isWarning ? DiagnosticBehavior::Warning
1399
+ : DiagnosticBehavior::Unspecified) {}
1388
1400
1389
1401
public:
1390
1402
std::string getName () const override {
@@ -2118,8 +2130,10 @@ class AllowArgumentMismatch : public ContextualMismatch {
2118
2130
2119
2131
AllowArgumentMismatch (ConstraintSystem &cs, FixKind kind, Type argType,
2120
2132
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) {}
2123
2137
2124
2138
public:
2125
2139
std::string getName () const override {
@@ -2267,9 +2281,9 @@ class TreatEphemeralAsNonEphemeral final : public AllowArgumentMismatch {
2267
2281
TreatEphemeralAsNonEphemeral (ConstraintSystem &cs, ConstraintLocator *locator,
2268
2282
Type srcType, Type dstType,
2269
2283
ConversionRestrictionKind conversionKind,
2270
- bool downgradeToWarning )
2284
+ DiagnosticBehavior behaviorLimit )
2271
2285
: AllowArgumentMismatch(cs, FixKind::TreatEphemeralAsNonEphemeral,
2272
- srcType, dstType, locator, downgradeToWarning ),
2286
+ srcType, dstType, locator, behaviorLimit ),
2273
2287
ConversionKind (conversionKind) {}
2274
2288
2275
2289
public:
@@ -2433,7 +2447,7 @@ class AllowCoercionToForceCast final : public ContextualMismatch {
2433
2447
AllowCoercionToForceCast (ConstraintSystem &cs, Type fromType, Type toType,
2434
2448
ConstraintLocator *locator)
2435
2449
: ContextualMismatch(cs, FixKind::AllowCoercionToForceCast, fromType,
2436
- toType, locator, /* warning */ true ) {}
2450
+ toType, locator, DiagnosticBehavior::Warning ) {}
2437
2451
2438
2452
public:
2439
2453
std::string getName () const override {
@@ -2547,7 +2561,7 @@ class SpecifyLabelToAssociateTrailingClosure final : public ConstraintFix {
2547
2561
SpecifyLabelToAssociateTrailingClosure (ConstraintSystem &cs,
2548
2562
ConstraintLocator *locator)
2549
2563
: ConstraintFix(cs, FixKind::SpecifyLabelToAssociateTrailingClosure,
2550
- locator, /* isWarning= */ true ) {}
2564
+ locator, DiagnosticBehavior::Warning ) {}
2551
2565
2552
2566
public:
2553
2567
std::string getName () const override {
@@ -2717,7 +2731,7 @@ class SpecifyBaseTypeForOptionalUnresolvedMember final : public ConstraintFix {
2717
2731
DeclNameRef memberName,
2718
2732
ConstraintLocator *locator)
2719
2733
: ConstraintFix(cs, FixKind::SpecifyBaseTypeForOptionalUnresolvedMember,
2720
- locator, /* isWarning= */ true ),
2734
+ locator, DiagnosticBehavior::Warning ),
2721
2735
MemberName (memberName) {}
2722
2736
DeclNameRef MemberName;
2723
2737
@@ -2748,7 +2762,7 @@ class CheckedCastContextualMismatchWarning : public ContextualMismatch {
2748
2762
CheckedCastKind kind,
2749
2763
ConstraintLocator *locator)
2750
2764
: ContextualMismatch(cs, fixKind, fromType, toType, locator,
2751
- /* isWarning */ true ),
2765
+ DiagnosticBehavior::Warning ),
2752
2766
CastKind (kind) {}
2753
2767
CheckedCastKind CastKind;
2754
2768
};
@@ -2859,7 +2873,7 @@ class AllowTupleLabelMismatch final : public ContextualMismatch {
2859
2873
AllowTupleLabelMismatch (ConstraintSystem &cs, Type fromType, Type toType,
2860
2874
ConstraintLocator *locator)
2861
2875
: ContextualMismatch(cs, FixKind::AllowTupleLabelMismatch, fromType,
2862
- toType, locator, /* warning */ true ) {}
2876
+ toType, locator, DiagnosticBehavior::Warning ) {}
2863
2877
2864
2878
public:
2865
2879
std::string getName () const override { return " allow tuple label mismatch" ; }
0 commit comments