File tree Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -6841,8 +6841,6 @@ AbstractRawRepresentableFailure::getDiagnostic() const {
6841
6841
return diag::cannot_convert_assign;
6842
6842
} else if (locator->isLastElement <LocatorPathElt::ApplyArgToParam>()) {
6843
6843
return diag::cannot_convert_argument_value;
6844
- } else if (locator->isLastElement <LocatorPathElt::AnyRequirement>()) {
6845
- return diag::type_does_not_conform;
6846
6844
}
6847
6845
6848
6846
return None;
@@ -6938,6 +6936,26 @@ void MissingRawRepresentableInitFailure::fixIt(
6938
6936
}
6939
6937
}
6940
6938
6939
+ bool MissingRawValueFailure::diagnoseAsError () {
6940
+ auto *locator = getLocator ();
6941
+
6942
+ if (locator->isLastElement <LocatorPathElt::AnyRequirement>()) {
6943
+ MissingConformanceFailure failure (getSolution (), locator,
6944
+ {RawReprType, ExpectedType});
6945
+
6946
+ auto diagnosed = failure.diagnoseAsError ();
6947
+ if (!diagnosed)
6948
+ return false ;
6949
+
6950
+ auto note = emitDiagnostic (diag::note_remapped_type, " .rawValue" );
6951
+ fixIt (note);
6952
+
6953
+ return true ;
6954
+ }
6955
+
6956
+ return AbstractRawRepresentableFailure::diagnoseAsError ();
6957
+ }
6958
+
6941
6959
void MissingRawValueFailure::fixIt (InFlightDiagnostic &diagnostic) const {
6942
6960
auto *E = getAsExpr (getAnchor ());
6943
6961
if (!E)
Original file line number Diff line number Diff line change @@ -2273,6 +2273,8 @@ class MissingRawValueFailure final : public AbstractRawRepresentableFailure {
2273
2273
Type getFromType () const override { return RawReprType; }
2274
2274
Type getToType () const override { return ExpectedType; }
2275
2275
2276
+ bool diagnoseAsError () override ;
2277
+
2276
2278
private:
2277
2279
void fixIt (InFlightDiagnostic &diagnostic) const override ;
2278
2280
};
Original file line number Diff line number Diff line change @@ -16,11 +16,13 @@ func acceptHashable<T: Hashable>(_: T) {}
16
16
// expected-note@-1 {{where 'T' = 'WrappedRef'}}
17
17
// expected-note@-2 {{where 'T' = 'WrappedValue'}}
18
18
func acceptComparable< T: Comparable > ( _: T ) { }
19
+ // expected-note@-1 {{where 'T' = 'NSNotification.Name'}}
19
20
20
21
func testNewTypeWrapper( x: NSNotification . Name , y: NSNotification . Name ) {
21
22
acceptEquatable ( x)
22
23
acceptHashable ( x)
23
- acceptComparable ( x) // expected-error {{type 'NSNotification.Name' does not conform to protocol 'Comparable'}} {{19-19=.rawValue}}
24
+ acceptComparable ( x) // expected-error {{global function 'acceptComparable' requires that 'NSNotification.Name' conform to 'Comparable'}}
25
+ // expected-note@-1 {{did you mean to use '.rawValue'?}} {{19-19=.rawValue}}
24
26
25
27
_ = x == y
26
28
_ = x != y
You can’t perform that action at this time.
0 commit comments