Skip to content

Commit 0e6dcab

Browse files
committed
[Diagnostics] Share diagnoseAsNote for raw representable diagnostics
1 parent 9805b0a commit 0e6dcab

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

lib/Sema/CSDiagnostics.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6395,7 +6395,7 @@ void MissingRawRepresentativeInitFailure::fixIt(
63956395
}
63966396
}
63976397

6398-
bool MissingRawRepresentativeInitFailure::diagnoseAsNote() {
6398+
bool AbstractRawRepresentableFailure::diagnoseAsNote() {
63996399
auto *locator = getLocator();
64006400

64016401
Optional<InFlightDiagnostic> diagnostic;
@@ -6442,10 +6442,10 @@ void UseOfRawRepresentableInsteadOfItsRawValueFailure::fixIt(
64426442
// out first and then, if destination is not optional, allow to specify
64436443
// default value.
64446444
if (RawReprType->getOptionalObjectType()) {
6445-
fix += ".map { $0.rawValue } ";
6445+
fix += ".map { $0.rawValue }";
64466446

64476447
if (!ExpectedType->getOptionalObjectType())
6448-
fix += "?? <#default value#>";
6448+
fix += " ?? <#default value#>";
64496449
} else {
64506450
fix += ".rawValue";
64516451
}

lib/Sema/CSDiagnostics.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2118,7 +2118,7 @@ class AbstractRawRepresentableFailure : public FailureDiagnostic {
21182118
virtual Type getToType() const = 0;
21192119

21202120
bool diagnoseAsError() override;
2121-
bool diagnoseAsNote() override { return false; }
2121+
bool diagnoseAsNote() override;
21222122

21232123
protected:
21242124
Optional<Diag<Type, Type>> getDiagnostic() const;
@@ -2151,8 +2151,6 @@ class MissingRawRepresentativeInitFailure final
21512151
Type getFromType() const override { return ExpectedType; }
21522152
Type getToType() const override { return RawReprType; }
21532153

2154-
bool diagnoseAsNote() override;
2155-
21562154
protected:
21572155
void fixIt(InFlightDiagnostic &diagnostic) const override;
21582156
};

0 commit comments

Comments
 (0)