mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[test] Test new fix-it for NSObject.hashValue overrides
This commit is contained in:
@@ -110,7 +110,8 @@ class CallbackSubC : CallbackBase {
|
|||||||
|
|
||||||
//
|
//
|
||||||
class MyHashableNSObject: NSObject {
|
class MyHashableNSObject: NSObject {
|
||||||
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}}
|
override var hashValue: Int {
|
||||||
|
// expected-error@-1 {{'NSObject.hashValue' is not overridable; did you mean to override 'NSObject.hash'?}}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
14
test/Migrator/fixit-NSObject-hashValue.swift
Normal file
14
test/Migrator/fixit-NSObject-hashValue.swift
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
// RUN: %empty-directory(%t)
|
||||||
|
// RUN: not %target-swift-frontend -typecheck -update-code -primary-file %s -emit-migrated-file-path %t/fixit-NSObject-hashValue.result
|
||||||
|
// RUN: diff -u %s.expected %t/fixit-NSObject-hashValue.result
|
||||||
|
// RUN: %target-swift-frontend -typecheck %s.expected
|
||||||
|
|
||||||
|
// REQUIRES: objc_interop
|
||||||
|
|
||||||
|
import ObjectiveC
|
||||||
|
|
||||||
|
class MyClass: NSObject {
|
||||||
|
override var hashValue: Int {
|
||||||
|
return 42
|
||||||
|
}
|
||||||
|
}
|
||||||
14
test/Migrator/fixit-NSObject-hashValue.swift.expected
Normal file
14
test/Migrator/fixit-NSObject-hashValue.swift.expected
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
// RUN: %empty-directory(%t)
|
||||||
|
// RUN: not %target-swift-frontend -typecheck -update-code -primary-file %s -emit-migrated-file-path %t/fixit-NSObject-hashValue.result
|
||||||
|
// RUN: diff -u %s.expected %t/fixit-NSObject-hashValue.result
|
||||||
|
// RUN: %target-swift-frontend -typecheck %s.expected
|
||||||
|
|
||||||
|
// REQUIRES: objc_interop
|
||||||
|
|
||||||
|
import ObjectiveC
|
||||||
|
|
||||||
|
class MyClass: NSObject {
|
||||||
|
override var hash: Int {
|
||||||
|
return 42
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,10 +6,13 @@
|
|||||||
import ObjectiveC
|
import ObjectiveC
|
||||||
|
|
||||||
class Foo: NSObject {
|
class Foo: NSObject {
|
||||||
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}}
|
override var hashValue: Int {
|
||||||
|
// expected-error@-1 {{'NSObject.hashValue' is not overridable; did you mean to override 'NSObject.hash'?}}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
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}}
|
override func hash(into hasher: inout Hasher) {
|
||||||
|
// expected-error@-1 {{overriding non-open instance method outside of its defining module}}
|
||||||
|
// expected-error@-2 {{overriding declarations in extensions is not supported}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user