Files
swift-mirror/test/stdlib/NSObject-hashing.swift
Karoy Lorentey 0b5b998327 [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.
2018-10-29 19:14:37 +00:00

16 lines
626 B
Swift

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