mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[ObjectiveC] Make NSObject.hashValue non-overridable
We deprecated overriding it in 4.2 with a custom compiler warning. This removes the ability to override it entirely. The correct way to customize hashing for NSObject subclasses is to override the `hash` property.
This commit is contained in:
15
test/stdlib/NSObject-hashing.swift
Normal file
15
test/stdlib/NSObject-hashing.swift
Normal file
@@ -0,0 +1,15 @@
|
||||
// RUN: %target-typecheck-verify-swift
|
||||
// RUN: %target-swift-frontend -c -verify -verify-ignore-unknown %s -o /dev/null
|
||||
|
||||
// REQUIRES: objc_interop
|
||||
|
||||
import ObjectiveC
|
||||
|
||||
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}}
|
||||
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}}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user