Skip to content

Commit 2f2c132

Browse files
committed
stdlib: fix availability for internal COW checks.
Those checks should only be done if linked with a built library, but not when linked with the OS libraries.
1 parent 6f41929 commit 2f2c132

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

stdlib/public/core/Builtin.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,12 +346,18 @@ internal func _class_getInstancePositiveExtentSize(_ theClass: AnyClass) -> Int
346346
}
347347

348348
#if INTERNAL_CHECKS_ENABLED
349-
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
349+
// "9999" means: enable if linked with a built library, but not when linked with
350+
// the OS libraries.
351+
// Note: this must not be changed to a "real" OS version.
352+
@available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *)
350353
@usableFromInline
351354
@_silgen_name("_swift_isImmutableCOWBuffer")
352355
internal func _swift_isImmutableCOWBuffer(_ object: AnyObject) -> Bool
353356

354-
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
357+
// "9999" means: enable if linked with a built library, but not when linked with
358+
// the OS libraries.
359+
// Note: this must not be changed to a "real" OS version.
360+
@available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *)
355361
@usableFromInline
356362
@_silgen_name("_swift_setImmutableCOWBuffer")
357363
internal func _swift_setImmutableCOWBuffer(_ object: AnyObject, _ immutable: Bool) -> Bool

stdlib/public/core/ContiguousArrayBuffer.swift

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
import SwiftShims
1414

1515
#if INTERNAL_CHECKS_ENABLED
16-
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
16+
// "9999" means: enable if linked with a built library, but not when linked with
17+
// the OS libraries.
18+
// Note: this must not be changed to a "real" OS version.
19+
@available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *)
1720
@_silgen_name("swift_COWChecksEnabled")
1821
public func _COWChecksEnabled() -> Bool
1922
#endif
@@ -460,15 +463,21 @@ internal struct _ContiguousArrayBuffer<Element>: _ArrayBufferProtocol {
460463
@_alwaysEmitIntoClient
461464
internal var isImmutable: Bool {
462465
get {
463-
if #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) {
466+
// "9999" means: enable if linked with a built library, but not when
467+
// linked with the OS libraries.
468+
// Note: this must not be changed to a "real" OS version.
469+
if #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) {
464470
if (_COWChecksEnabled()) {
465471
return capacity == 0 || _swift_isImmutableCOWBuffer(_storage)
466472
}
467473
}
468474
return true
469475
}
470476
nonmutating set {
471-
if #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) {
477+
// "9999" means: enable if linked with a built library, but not when
478+
// linked with the OS libraries.
479+
// Note: this must not be changed to a "real" OS version.
480+
if #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) {
472481
if (_COWChecksEnabled()) {
473482
// Make sure to not modify the empty array singleton (which has a
474483
// capacity of 0).
@@ -489,7 +498,10 @@ internal struct _ContiguousArrayBuffer<Element>: _ArrayBufferProtocol {
489498

490499
@_alwaysEmitIntoClient
491500
internal var isMutable: Bool {
492-
if #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) {
501+
// "9999" means: enable if linked with a built library, but not when
502+
// linked with the OS libraries.
503+
// Note: this must not be changed to a "real" OS version.
504+
if #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) {
493505
if (_COWChecksEnabled()) {
494506
return !_swift_isImmutableCOWBuffer(_storage)
495507
}

0 commit comments

Comments
 (0)