Skip to content

Commit 6af814d

Browse files
committed
[test] Test new fix-it for NSObject.hashValue overrides
1 parent df8eba4 commit 6af814d

File tree

4 files changed

+35
-3
lines changed

4 files changed

+35
-3
lines changed

test/ClangImporter/objc_override.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ class CallbackSubC : CallbackBase {
110110

111111
//
112112
class MyHashableNSObject: NSObject {
113-
override var hashValue: Int { // expected-error{{overriding non-open property outside of its defining module}} expected-error{{overriding non-@objc declarations from extensions is not supported}}
113+
override var hashValue: Int {
114+
// expected-error@-1 {{'NSObject.hashValue' is not overridable; did you mean to override 'NSObject.hash'?}}
114115
return 0
115116
}
116117
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: not %target-swift-frontend -typecheck -update-code -primary-file %s -emit-migrated-file-path %t/fixit-NSObject-hashValue.result
3+
// RUN: diff -u %s.expected %t/fixit-NSObject-hashValue.result
4+
// RUN: %target-swift-frontend -typecheck %s.expected
5+
6+
// REQUIRES: objc_interop
7+
8+
import ObjectiveC
9+
10+
class MyClass: NSObject {
11+
override var hashValue: Int {
12+
return 42
13+
}
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: not %target-swift-frontend -typecheck -update-code -primary-file %s -emit-migrated-file-path %t/fixit-NSObject-hashValue.result
3+
// RUN: diff -u %s.expected %t/fixit-NSObject-hashValue.result
4+
// RUN: %target-swift-frontend -typecheck %s.expected
5+
6+
// REQUIRES: objc_interop
7+
8+
import ObjectiveC
9+
10+
class MyClass: NSObject {
11+
override var hash: Int {
12+
return 42
13+
}
14+
}

test/stdlib/NSObject-hashing.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
import ObjectiveC
77

88
class Foo: NSObject {
9-
override var hashValue: Int { // expected-error {{overriding non-open property outside of its defining module}} expected-error {{overriding non-@objc declarations from extensions is not supported}}
9+
override var hashValue: Int {
10+
// expected-error@-1 {{'NSObject.hashValue' is not overridable; did you mean to override 'NSObject.hash'?}}
1011
return 0
1112
}
1213

13-
override func hash(into hasher: inout Hasher) { // expected-error {{overriding non-open instance method outside of its defining module}} expected-error {{overriding declarations in extensions is not supported}}
14+
override func hash(into hasher: inout Hasher) {
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}}
1417
}
1518
}

0 commit comments

Comments
 (0)