Skip to content

Commit edcf405

Browse files
committed
[Diagnostics] Use ContextualFailure and ContextualMistatch as base classes
for `AutoClosurePointerConversionFailure` and `AllowAutoClosurePointerConversion` respectively.
1 parent e76f5f1 commit edcf405

File tree

4 files changed

+7
-14
lines changed

4 files changed

+7
-14
lines changed

lib/Sema/CSDiagnostics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1981,7 +1981,7 @@ bool AutoClosureForwardingFailure::diagnoseAsError() {
19811981
bool AutoClosurePointerConversionFailure::diagnoseAsError() {
19821982
auto *anchor = getAnchor();
19831983
auto diagnostic = diag::invalid_autoclosure_pointer_conversion;
1984-
emitDiagnostic(anchor->getLoc(), diagnostic, PointeeType, PointerType)
1984+
emitDiagnostic(anchor->getLoc(), diagnostic, getFromType(), getToType())
19851985
.highlight(anchor->getSourceRange());
19861986
return true;
19871987
}

lib/Sema/CSDiagnostics.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -785,16 +785,12 @@ class AutoClosureForwardingFailure final : public FailureDiagnostic {
785785
/// var i = 0
786786
/// foo(&i) // Invalid conversion to UnsafePointer
787787
/// \endcode
788-
class AutoClosurePointerConversionFailure final : public FailureDiagnostic {
789-
Type PointeeType;
790-
Type PointerType;
791-
788+
class AutoClosurePointerConversionFailure final : public ContextualFailure {
792789
public:
793790
AutoClosurePointerConversionFailure(Expr *root, ConstraintSystem &cs,
794791
Type pointeeType, Type pointerType,
795792
ConstraintLocator *locator)
796-
: FailureDiagnostic(root, cs, locator), PointeeType(pointeeType),
797-
PointerType(pointerType) {}
793+
: ContextualFailure(root, cs, pointeeType, pointerType, locator) {}
798794

799795
bool diagnoseAsError() override;
800796
};

lib/Sema/CSFix.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ AutoClosureForwarding *AutoClosureForwarding::create(ConstraintSystem &cs,
271271

272272
bool AllowAutoClosurePointerConversion::diagnose(Expr *root, bool asNote) const {
273273
auto failure = AutoClosurePointerConversionFailure(root, getConstraintSystem(),
274-
PointeeType, PointerType, getLocator());
274+
getFromType(), getToType(), getLocator());
275275
return failure.diagnose(asNote);
276276
}
277277

lib/Sema/CSFix.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -625,14 +625,11 @@ class AutoClosureForwarding final : public ConstraintFix {
625625
ConstraintLocator *locator);
626626
};
627627

628-
class AllowAutoClosurePointerConversion final : public ConstraintFix {
629-
Type PointeeType;
630-
Type PointerType;
631-
628+
class AllowAutoClosurePointerConversion final : public ContextualMismatch {
632629
AllowAutoClosurePointerConversion(ConstraintSystem &cs, Type pointeeType,
633630
Type pointerType, ConstraintLocator *locator)
634-
: ConstraintFix(cs, FixKind::AllowAutoClosurePointerConversion, locator),
635-
PointeeType(pointeeType), PointerType(pointerType) {}
631+
: ContextualMismatch(cs, FixKind::AllowAutoClosurePointerConversion,
632+
pointeeType, pointerType, locator) {}
636633

637634
public:
638635
std::string getName() const override {

0 commit comments

Comments
 (0)