[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:
Karoy Lorentey
2018-10-29 19:12:24 +00:00
parent d026b10366
commit 0b5b998327
2 changed files with 27 additions and 12 deletions

View 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}}
}
}