@@ -732,7 +732,7 @@ public struct ${Self}<Element>
732
732
get {
733
733
_checkIndex ( bounds. lowerBound)
734
734
_checkIndex ( bounds. upperBound)
735
- return ArraySlice ( _buffer [ bounds] )
735
+ return ArraySlice ( _buffer: _buffer [ bounds] )
736
736
}
737
737
set ( rhs) {
738
738
_checkIndex ( bounds. lowerBound)
@@ -884,10 +884,20 @@ public struct ${Self}<Element>
884
884
885
885
/// Initialization from an existing buffer does not have "array.init"
886
886
/// semantics because the caller may retain an alias to buffer.
887
- public init ( _ _buffer: _Buffer ) {
887
+ public // @testable
888
+ init ( _buffer: _Buffer ) {
888
889
self . _buffer = _buffer
889
890
}
890
891
892
+ % if Self == 'ArraySlice':
893
+ /// Initialization from an existing buffer does not have "array.init"
894
+ /// semantics because the caller may retain an alias to buffer.
895
+ public // @testable
896
+ init ( _buffer: _ContiguousArrayBuffer < Element > ) {
897
+ self . init ( _buffer: _Buffer ( _buffer, shiftedToStartIndex: 0 ) )
898
+ }
899
+ % end
900
+
891
901
public var _buffer : _Buffer
892
902
}
893
903
@@ -926,7 +936,7 @@ extension ${Self} : ArrayLiteralConvertible {
926
936
///
927
937
/// - Parameter elements: A variadic list of elements of the new array.
928
938
public init ( arrayLiteral elements: Element ... ) {
929
- self . init ( _extractOrCopyToNativeArrayBuffer ( elements. _buffer) )
939
+ self . init ( _buffer : _extractOrCopyToNativeArrayBuffer ( elements. _buffer) )
930
940
}
931
941
% end
932
942
}
@@ -1027,7 +1037,7 @@ extension ${Self} : RangeReplaceableCollection, _ArrayProtocol {
1027
1037
public init< S : Sequence> ( _ s: S)
1028
1038
where S. Iterator . Element == Element {
1029
1039
1030
- self = ${ Self} ( _Buffer ( s. _copyToNativeArrayBuffer ( ) ,
1040
+ self = ${ Self} ( _buffer : _Buffer ( s. _copyToNativeArrayBuffer ( ) ,
1031
1041
shiftedToStartIndex: 0 ) )
1032
1042
}
1033
1043
@@ -1114,7 +1124,7 @@ extension ${Self} : RangeReplaceableCollection, _ArrayProtocol {
1114
1124
storage, to: _ContiguousArrayStorage< Element> . self ) )
1115
1125
1116
1126
return (
1117
- Array ( _Buffer ( innerBuffer, shiftedToStartIndex: 0 ) ) ,
1127
+ Array ( _buffer : _Buffer ( innerBuffer, shiftedToStartIndex: 0 ) ) ,
1118
1128
innerBuffer. firstElementAddress)
1119
1129
}
1120
1130
@@ -2082,7 +2092,7 @@ public func != <Element : Equatable>(
2082
2092
public func _arrayUpCast< Derived, Base> ( _ a: Array < Derived > ) -> Array < Base > {
2083
2093
// FIXME: Dynamic casting is currently not possible without the objc runtime:
2084
2094
// rdar://problem/18801510
2085
- return Array ( a. _buffer. cast ( toBufferOf: Base . self) )
2095
+ return Array ( _buffer : a. _buffer. cast ( toBufferOf: Base . self) )
2086
2096
}
2087
2097
#endif
2088
2098
@@ -2113,7 +2123,7 @@ extension Array {
2113
2123
/// * `Element` is bridged verbatim to Objective-C (i.e.,
2114
2124
/// is a reference type).
2115
2125
public init ( _immutableCocoaArray: _NSArrayCore ) {
2116
- self = Array ( _ArrayBuffer ( nsArray: _immutableCocoaArray) )
2126
+ self = Array ( _buffer : _ArrayBuffer ( nsArray: _immutableCocoaArray) )
2117
2127
}
2118
2128
}
2119
2129
#endif
0 commit comments