Skip to content

Commit 0cdcd18

Browse files
authored
Merge pull request #4086 from apple/deprecate-contiguousarray
[stdlib] Deprecate ContiguousArray (do not merge yet)
2 parents 1a6828b + 595aad3 commit 0cdcd18

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

stdlib/public/core/Arrays.swift.gyb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,9 @@ ${SelfDocComment}
448448
% if Self != 'ArraySlice':
449449
@_fixed_layout
450450
%end
451+
% if Self == 'ContiguousArray':
452+
@available(*, deprecated, renamed: "Array")
453+
%end
451454
public struct ${Self}<Element>
452455
: RandomAccessCollection,
453456
MutableCollection,

test/1_stdlib/Renames.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func _Arrays<T>(e: T) {
1414
// _ = Array(count: 1, repeatedValue: e) // xpected-error {{Please use init(repeating:count:) instead}} {{none}}
1515
// The actual error is: {{argument 'repeatedValue' must precede argument 'count'}}
1616

17-
var a = ContiguousArray<T>()
17+
var a = ContiguousArray<T>() // expected-warning {{'ContiguousArray' is deprecated: renamed to 'Array'}} expected-note {{use 'Array' instead}}
1818
_ = a.removeAtIndex(0) // expected-error {{'removeAtIndex' has been renamed to 'remove(at:)'}} {{9-22=remove}} {{23-23=at: }} {{none}}
1919
_ = a.replaceRange(0..<1, with: []) // expected-error {{'replaceRange(_:with:)' has been renamed to 'replaceSubrange(_:with:)'}} {{9-21=replaceSubrange}} {{none}}
2020
_ = a.appendContentsOf([]) // expected-error {{'appendContentsOf' has been renamed to 'append(contentsOf:)'}} {{9-25=append}} {{26-26=contentsOf: }} {{none}}

test/expr/cast/array_coerce.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ cs = ds // expected-error{{cannot assign value of type 'ArraySlice<D>' to type '
3838
ds = cs // expected-error{{cannot assign value of type 'ArraySlice<C>' to type 'ArraySlice<D>'}}
3939

4040
// ContiguousArray<T>
41-
var cna: ContiguousArray<C> = [c1]
42-
var dna: ContiguousArray<D> = [d1]
41+
var cna: ContiguousArray<C> = [c1] // expected-warning {{'ContiguousArray' is deprecated: renamed to 'Array'}} expected-note {{use 'Array' instead}}
42+
var dna: ContiguousArray<D> = [d1] // expected-warning {{'ContiguousArray' is deprecated: renamed to 'Array'}} expected-note {{use 'Array' instead}}
4343

4444
cna = dna // expected-error{{cannot assign value of type 'ContiguousArray<D>' to type 'ContiguousArray<C>'}}
4545
dna = cna // expected-error{{cannot assign value of type 'ContiguousArray<C>' to type 'ContiguousArray<D>'}}

0 commit comments

Comments
 (0)