@@ -74,6 +74,16 @@ extension ContiguousArray {
7474 }
7575 }
7676
77+ #if INTERNAL_CHECKS_ENABLED && COW_CHECKS_ENABLED
78+ @_alwaysEmitIntoClient
79+ @_semantics ( " array.make_mutable " )
80+ internal mutating func _makeMutableAndUniqueUnchecked( ) {
81+ if _slowPath ( !_buffer. beginCOWMutationUnchecked ( ) ) {
82+ _buffer = _buffer. _consumeAndCreateNew ( )
83+ }
84+ }
85+ #endif
86+
7787 /// Marks the end of an Array mutation.
7888 ///
7989 /// After a call to `_endMutation` the buffer must not be mutated until a call
@@ -1151,19 +1161,24 @@ extension ContiguousArray {
11511161 ) throws ( E) -> R {
11521162 return try unsafe _buffer. withUnsafeBufferPointer ( body)
11531163 }
1164+ }
11541165
1155- @available ( SwiftStdlib 6 . 2 , * )
1166+ @available ( SwiftCompatibilitySpan 5 . 0 , * )
1167+ @_originallyDefinedIn ( module: " Swift;CompatibilitySpan " , SwiftCompatibilitySpan 6 . 2 )
1168+ extension ContiguousArray {
1169+ @_alwaysEmitIntoClient
11561170 public var span : Span < Element > {
11571171 @lifetime ( borrow self)
1158- @_alwaysEmitIntoClient
11591172 borrowing get {
11601173 let pointer = unsafe _buffer . firstElementAddress
11611174 let count = _buffer. immutableCount
11621175 let span = unsafe Span( _unsafeStart: pointer, count: count)
11631176 return unsafe _overrideLifetime ( span, borrowing: self )
11641177 }
11651178 }
1179+ }
11661180
1181+ extension ContiguousArray {
11671182 // Superseded by the typed-throws version of this function, but retained
11681183 // for ABI reasons.
11691184 @_semantics ( " array.withUnsafeMutableBufferPointer " )
@@ -1241,8 +1256,11 @@ extension ContiguousArray {
12411256 // Invoke the body.
12421257 return try unsafe body( & inoutBufferPointer)
12431258 }
1259+ }
12441260
1245- @available ( SwiftStdlib 6 . 2 , * )
1261+ @available ( SwiftCompatibilitySpan 5 . 0 , * )
1262+ @_originallyDefinedIn ( module: " Swift;CompatibilitySpan " , SwiftCompatibilitySpan 6 . 2 )
1263+ extension ContiguousArray {
12461264 @_alwaysEmitIntoClient
12471265 public var mutableSpan : MutableSpan < Element > {
12481266 @lifetime ( & self )
@@ -1262,7 +1280,9 @@ extension ContiguousArray {
12621280 return unsafe _override Lifetime ( span, mutating: & self )
12631281 }
12641282 }
1283+ }
12651284
1285+ extension ContiguousArray {
12661286 @inlinable
12671287 public __consuming func _copyContents(
12681288 initializing buffer: UnsafeMutableBufferPointer < Element >
0 commit comments