Skip to content

Commit a1a71ac

Browse files
committed
Merge remote-tracking branch 'origin/master' into master-next
2 parents 4868880 + e8b6091 commit a1a71ac

File tree

3 files changed

+25
-19
lines changed

3 files changed

+25
-19
lines changed

stdlib/public/core/CollectionAlgorithms.swift

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,6 @@ extension Collection where Element : Equatable {
7272
}
7373
return nil
7474
}
75-
76-
/// Returns the first index where the specified value appears in the
77-
/// collection.
78-
@inlinable
79-
public func index(of _element: Element) -> Index? {
80-
return firstIndex(of: _element)
81-
}
8275
}
8376

8477
extension Collection {
@@ -117,15 +110,6 @@ extension Collection {
117110
}
118111
return nil
119112
}
120-
121-
/// Returns the first index in which an element of the collection satisfies
122-
/// the given predicate.
123-
@inlinable
124-
public func index(
125-
where _predicate: (Element) throws -> Bool
126-
) rethrows -> Index? {
127-
return try firstIndex(where: _predicate)
128-
}
129113
}
130114

131115
//===----------------------------------------------------------------------===//

stdlib/public/core/MigrationSupport.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,28 @@ extension Collection {
10111011
}
10121012
}
10131013

1014+
extension Collection {
1015+
/// Returns the first index in which an element of the collection satisfies
1016+
/// the given predicate.
1017+
@available(swift, deprecated: 5.0, renamed: "firstIndex(where:)")
1018+
@inlinable
1019+
public func index(
1020+
where _predicate: (Element) throws -> Bool
1021+
) rethrows -> Index? {
1022+
return try firstIndex(where: _predicate)
1023+
}
1024+
}
1025+
1026+
extension Collection where Element: Equatable {
1027+
/// Returns the first index where the specified value appears in the
1028+
/// collection.
1029+
@available(swift, deprecated: 5.0, renamed: "firstIndex(of:)")
1030+
@inlinable
1031+
public func index(of element: Element) -> Index? {
1032+
return firstIndex(of: element)
1033+
}
1034+
}
1035+
10141036
extension String.Index {
10151037
@available(swift, deprecated: 3.2, obsoleted: 4.0)
10161038
public init(_position: Int) {

test/stdlib/IndexOfRenaming.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// RUN: %target-typecheck-verify-swift
1+
// RUN: %target-typecheck-verify-swift -swift-version 5
22

33
let a = [10, 20, 30, 40, 50, 60]
44

5-
_ = a.index(of: 30)
5+
_ = a.index(of: 30) // expected-warning {{'index(of:)' is deprecated: renamed to 'firstIndex(of:)'}} expected-note {{use 'firstIndex(of:)' instead}}
66
_ = a.firstIndex(of: 30)
7-
_ = a.index(where: { $0 > 30 })
7+
_ = a.index(where: { $0 > 30 }) // expected-warning {{'index(where:)' is deprecated: renamed to 'firstIndex(where:)'}} expected-note {{use 'firstIndex(where:)' instead}}
88
_ = a.firstIndex(where: { $0 > 30 })

0 commit comments

Comments
 (0)