mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Add wrappers around Builtin.isUnique.
The wrappers for the _native variants provide point-of-use sanity checking. They also allows stdlib code to use regular (Bool) types. These need to be fully generic to support class protocols. It also avoids a massive amount of overloading for all the reference type variations (AnyObject, Native, Unknown, Bridge) x 2 for optional versions of each. Because the wrapper is generic, type checking had to be deferred until IRGen. Generating code for the wrapper itself will result in an IRGen-time type error. They need to be transparent anyway for proper diagnostics, but also must be internal. The external API passes type checks because it forces conformance to AnyObject. Swift SVN r27930
This commit is contained in:
@@ -2703,12 +2703,12 @@ internal enum _Variant${Self}Storage<${TypeParametersDecl}> : _HashStorageType {
|
||||
|
||||
internal mutating func isUniquelyReferenced() -> Bool {
|
||||
if _fastPath(guaranteedNative) {
|
||||
return Bool(Builtin.isUnique_native(&self))
|
||||
return _isUnique_native(&self)
|
||||
}
|
||||
|
||||
switch self {
|
||||
case .Native:
|
||||
return Bool(Builtin.isUnique_native(&self))
|
||||
return _isUnique_native(&self)
|
||||
case .Cocoa:
|
||||
// Don't consider Cocoa storage mutable, even if it is mutable and is
|
||||
// uniquely referenced.
|
||||
|
||||
Reference in New Issue
Block a user