You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[5.0][Sema] Add dedicated fix-it for NSObject.hashValue overrides (#22173)
* [Sema] Add dedicated fix-it for NSObject.hashValue overrides
NSObject.hashValue used to be declared `@objc open` by historical accident. This has been corrected to `@nonobjc public` in Swift 5’s SDK overlays, to catch accidental overrides. (These never did work correctly, and shouldn’t have been allowed.)
Help migration by adding a dedicated error message for NSObject.hashValue overrides, with a nice fix-it.
rdar://problem/45674813
(cherry picked from commit df8eba4)
* [test] Test new fix-it for NSObject.hashValue overrides
(cherry picked from commit 6af814d)
Copy file name to clipboardExpand all lines: test/ClangImporter/objc_override.swift
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -110,7 +110,8 @@ class CallbackSubC : CallbackBase {
110
110
111
111
//
112
112
classMyHashableNSObject:NSObject{
113
-
overridevarhashValue:Int{ // expected-error{{overriding non-open property outside of its defining module}} expected-error{{overriding non-@objc declarations from extensions is not supported}}
113
+
overridevarhashValue:Int{
114
+
// expected-error@-1 {{'NSObject.hashValue' is not overridable; did you mean to override 'NSObject.hash'?}}
Copy file name to clipboardExpand all lines: test/stdlib/NSObject-hashing.swift
+5-2Lines changed: 5 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -6,10 +6,13 @@
6
6
import ObjectiveC
7
7
8
8
classFoo:NSObject{
9
-
overridevarhashValue:Int{ // expected-error {{overriding non-open property outside of its defining module}} expected-error {{overriding non-@objc declarations from extensions is not supported}}
9
+
overridevarhashValue:Int{
10
+
// expected-error@-1 {{'NSObject.hashValue' is not overridable; did you mean to override 'NSObject.hash'?}}
10
11
return0
11
12
}
12
13
13
-
overridefunc hash(into hasher:inoutHasher){ // expected-error {{overriding non-open instance method outside of its defining module}} expected-error {{overriding declarations in extensions is not supported}}
14
+
overridefunc hash(into hasher:inoutHasher){
15
+
// expected-error@-1 {{overriding non-open instance method outside of its defining module}}
16
+
// expected-error@-2 {{overriding declarations in extensions is not supported}}
0 commit comments