Skip to content

Commit ec920c9

Browse files
authored
Merge pull request #3596 from apple/revert-3589-closure-naming-and-labeling
Revert "Implement SE-0118"
2 parents 3b378f7 + fc37603 commit ec920c9

File tree

64 files changed

+348
-380
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+348
-380
lines changed

benchmark/single-source/CaptureProp.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func benchCaptureProp<S : Sequence
2121

2222
var it = s.makeIterator()
2323
let initial = it.next()!
24-
return IteratorSequence(it).reduce(initial, f)
24+
return IteratorSequence(it).reduce(initial, combine: f)
2525
}
2626

2727
public func run_CaptureProp(_ N: Int) {

benchmark/single-source/MapReduce.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public func run_MapReduce(_ N: Int) {
2020
var c = 0
2121
for _ in 1...N*100 {
2222
numbers = numbers.map({$0 &+ 5})
23-
c += numbers.reduce(0, &+)
23+
c += numbers.reduce(0, combine: &+)
2424
}
2525
CheckResults(c != 0, "IncorrectResults in MapReduce")
2626
}

benchmark/single-source/SortStrings.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ func benchSortStrings(_ words: [String]) {
10211021
// Notice that we _copy_ the array of words before we sort it.
10221022
// Pass an explicit '<' predicate to benchmark reabstraction thunks.
10231023
var tempwords = words
1024-
tempwords.sort(by: <)
1024+
tempwords.sort(isOrderedBefore: <)
10251025
}
10261026

10271027
public func run_SortStrings(_ N: Int) {

stdlib/private/StdlibCollectionUnittest/LoggingWrappers.swift.gyb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,10 @@ public struct ${Self}<
229229
}
230230

231231
public func filter(
232-
_ isIncluded: @noescape (Base.Iterator.Element) throws -> Bool
232+
_ includeElement: @noescape (Base.Iterator.Element) throws -> Bool
233233
) rethrows -> [Base.Iterator.Element] {
234234
Log.filter[selfType] += 1
235-
return try base.filter(isIncluded)
235+
return try base.filter(includeElement)
236236
}
237237

238238
public func forEach(
@@ -274,13 +274,13 @@ public struct ${Self}<
274274
public func split(
275275
maxSplits: Int = Int.max,
276276
omittingEmptySubsequences: Bool = true,
277-
whereSeparator isSeparator: @noescape (Base.Iterator.Element) throws -> Bool
277+
isSeparator: @noescape (Base.Iterator.Element) throws -> Bool
278278
) rethrows -> [SubSequence] {
279279
Log.split[selfType] += 1
280280
return try base.split(
281281
maxSplits: maxSplits,
282282
omittingEmptySubsequences: omittingEmptySubsequences,
283-
whereSeparator: isSeparator)
283+
isSeparator: isSeparator)
284284
}
285285

286286
public func _customContainsEquatableElement(

stdlib/private/StdlibUnittest/RaceTest.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -596,9 +596,7 @@ internal struct ClosureBasedRaceTest : RaceTestWithPerTrialData {
596596
) {}
597597
}
598598

599-
public func runRaceTest(
600-
trials: Int, threads: Int? = nil, invoking body: () -> ()
601-
) {
599+
public func runRaceTest(trials: Int, threads: Int? = nil, body: () -> ()) {
602600
ClosureBasedRaceTest.thread = body
603601
runRaceTest(ClosureBasedRaceTest.self, trials: trials, threads: threads)
604602
}

stdlib/private/StdlibUnittest/StdlibCoreExtras.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ extension MutableCollection
214214
}
215215

216216
/// Generate all permutations.
217-
public func forAllPermutations(_ size: Int, _ body: ([Int]) -> Void) {
217+
public func forAllPermutations(_ size: Int, body: ([Int]) -> Void) {
218218
var data = Array(0..<size)
219219
repeat {
220220
body(data)
@@ -223,7 +223,7 @@ public func forAllPermutations(_ size: Int, _ body: ([Int]) -> Void) {
223223

224224
/// Generate all permutations.
225225
public func forAllPermutations<S : Sequence>(
226-
_ sequence: S, _ body: ([S.Iterator.Element]) -> Void
226+
_ sequence: S, body: ([S.Iterator.Element]) -> Void
227227
) {
228228
let data = Array(sequence)
229229
forAllPermutations(data.count) {

stdlib/private/StdlibUnittest/StdlibUnittest.swift.gyb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ var _seenExpectCrash = false
107107
/// Run `body` and expect a failure to happen.
108108
///
109109
/// The check passes iff `body` triggers one or more failures.
110-
public func expectFailure(${TRACE}, invoking body: () -> Void) {
110+
public func expectFailure(${TRACE}, body: () -> Void) {
111111
let startAnyExpectFailed = _anyExpectFailed
112112
_anyExpectFailed = false
113113
body()
@@ -2244,7 +2244,7 @@ public func expectEqualSequence<
22442244
) where
22452245
Expected.Iterator.Element == Actual.Iterator.Element {
22462246

2247-
if !expected.elementsEqual(actual, by: sameValue) {
2247+
if !expected.elementsEqual(actual, isEquivalent: sameValue) {
22482248
expectationFailure("expected elements: \"\(expected)\"\n"
22492249
+ "actual: \"\(actual)\" (of type \(String(reflecting: actual.dynamicType)))",
22502250
trace: ${trace})
@@ -2262,9 +2262,9 @@ public func expectEqualsUnordered<
22622262
Expected.Iterator.Element == Actual.Iterator.Element {
22632263

22642264
let x: [Expected.Iterator.Element] =
2265-
expected.sorted(by: compose(compare, { $0.isLT() }))
2265+
expected.sorted(isOrderedBefore: compose(compare, { $0.isLT() }))
22662266
let y: [Actual.Iterator.Element] =
2267-
actual.sorted(by: compose(compare, { $0.isLT() }))
2267+
actual.sorted(isOrderedBefore: compose(compare, { $0.isLT() }))
22682268
expectEqualSequence(
22692269
x, y, ${trace}, sameValue: compose(compare, { $0.isEQ() }))
22702270
}
@@ -2361,10 +2361,10 @@ public func expectEqualsUnordered<
23612361
}
23622362

23632363
let x: [(T, T)] =
2364-
expected.sorted(by: comparePairLess)
2364+
expected.sorted(isOrderedBefore: comparePairLess)
23652365
let y: [(T, T)] =
23662366
actual.map { ($0.0, $0.1) }
2367-
.sorted(by: comparePairLess)
2367+
.sorted(isOrderedBefore: comparePairLess)
23682368

23692369
func comparePairEquals(_ lhs: (T, T), rhs: (key: T, value: T)) -> Bool {
23702370
return lhs.0 == rhs.0 && lhs.1 == rhs.1

stdlib/private/StdlibUnittest/TypeIndexed.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ extension TypeIndexed where Value : Strideable {
5959
showFrame: Bool = true,
6060
stackTrace: SourceLocStack = SourceLocStack(),
6161
file: String = #file, line: UInt = #line,
62-
invoking body: () -> R
62+
body: () -> R
6363
) -> R {
6464
let expected = self[t].advanced(by: 1)
6565
let r = body()
@@ -77,7 +77,7 @@ extension TypeIndexed where Value : Equatable {
7777
showFrame: Bool = true,
7878
stackTrace: SourceLocStack = SourceLocStack(),
7979
file: String = #file, line: UInt = #line,
80-
invoking body: () -> R
80+
body: () -> R
8181
) -> R {
8282
let expected = self[t]
8383
let r = body()

stdlib/private/StdlibUnittestFoundationExtras/StdlibUnittestFoundationExtras.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public func withOverriddenLocaleCurrentLocale<Result>(
6565
/// return-autoreleased optimization.)
6666
@inline(never)
6767
public func autoreleasepoolIfUnoptimizedReturnAutoreleased(
68-
invoking body: @noescape () -> Void
68+
_ body: @noescape () -> Void
6969
) {
7070
#if arch(i386) && (os(iOS) || os(watchOS))
7171
autoreleasepool(body)

stdlib/public/SDK/Foundation/NSStringAPI.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ extension Optional {
7676
/// `body` is complicated than that results in unnecessarily repeated code.
7777
internal func _withNilOrAddress<NSType : AnyObject, ResultType>(
7878
of object: inout NSType?,
79-
_ body:
80-
@noescape (AutoreleasingUnsafeMutablePointer<NSType?>?) -> ResultType
79+
body: @noescape (AutoreleasingUnsafeMutablePointer<NSType?>?) -> ResultType
8180
) -> ResultType {
8281
return self == nil ? body(nil) : body(&object)
8382
}
@@ -496,9 +495,7 @@ extension String {
496495
// enumerateLinesUsing:(void (^)(NSString *line, BOOL *stop))block
497496

498497
/// Enumerates all the lines in a string.
499-
public func enumerateLines(
500-
invoking body: (line: String, stop: inout Bool) -> ()
501-
) {
498+
public func enumerateLines(_ body: (line: String, stop: inout Bool) -> ()) {
502499
_ns.enumerateLines {
503500
(line: String, stop: UnsafeMutablePointer<ObjCBool>)
504501
in
@@ -529,7 +526,7 @@ extension String {
529526
scheme tagScheme: String,
530527
options opts: NSLinguisticTagger.Options = [],
531528
orthography: NSOrthography? = nil,
532-
invoking body:
529+
_ body:
533530
(String, Range<Index>, Range<Index>, inout Bool) -> ()
534531
) {
535532
_ns.enumerateLinguisticTags(

stdlib/public/SDK/ObjectiveC/ObjectiveC.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ func __pushAutoreleasePool() -> OpaquePointer
187187
func __popAutoreleasePool(_ pool: OpaquePointer)
188188

189189
public func autoreleasepool<Result>(
190-
invoking body: @noescape () throws -> Result
190+
_ body: @noescape () throws -> Result
191191
) rethrows -> Result {
192192
let pool = __pushAutoreleasePool()
193193
defer {

stdlib/public/core/Arrays.swift.gyb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ if True:
9999
///
100100
/// You can call any method on the slices that you might have called on the
101101
/// `absences` array. To learn which half had more absences, use the
102-
/// `reduce(_:)` method to calculate each sum.
102+
/// `reduce(_:combine:)` method to calculate each sum.
103103
///
104-
/// let firstHalfSum = firstHalf.reduce(0, +)
105-
/// let secondHalfSum = secondHalf.reduce(0, +)
104+
/// let firstHalfSum = firstHalf.reduce(0, combine: +)
105+
/// let secondHalfSum = secondHalf.reduce(0, combine: +)
106106
///
107107
/// if firstHalfSum > secondHalfSum {
108108
/// print("More absences in the first half.")

stdlib/public/core/Character.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public struct Character :
9292
shift += 8
9393
}
9494

95-
UTF8.encode(scalar, into: output)
95+
UTF8.encode(scalar, sendingOutputTo: output)
9696
asInt |= (~0) << shift
9797
_representation = .small(Builtin.trunc_Int64_Int63(asInt._value))
9898
}
@@ -297,7 +297,7 @@ public struct Character :
297297
_SmallUTF8(u8).makeIterator(),
298298
from: UTF8.self, to: UTF16.self,
299299
stoppingOnError: false,
300-
into: output)
300+
sendingOutputTo: output)
301301
self.data = u16
302302
}
303303

stdlib/public/core/Collection.swift

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,17 +1484,15 @@ extension Collection {
14841484
/// that was originally separated by one or more spaces.
14851485
///
14861486
/// let line = "BLANCHE: I don't want realism. I want magic!"
1487-
/// print(line.characters.split(whereSeparator: { $0 == " " })
1487+
/// print(line.characters.split(isSeparator: { $0 == " " })
14881488
/// .map(String.init))
14891489
/// // Prints "["BLANCHE:", "I", "don\'t", "want", "realism.", "I", "want", "magic!"]"
14901490
///
14911491
/// The second example passes `1` for the `maxSplits` parameter, so the
14921492
/// original string is split just once, into two new strings.
14931493
///
1494-
/// print(
1495-
/// line.characters.split(
1496-
/// maxSplits: 1, whereSeparator: { $0 == " " }
1497-
/// ).map(String.init))
1494+
/// print(line.characters.split(maxSplits: 1, isSeparator: { $0 == " " })
1495+
/// .map(String.init))
14981496
/// // Prints "["BLANCHE:", " I don\'t want realism. I want magic!"]"
14991497
///
15001498
/// The final example passes `false` for the `omittingEmptySubsequences`
@@ -1525,7 +1523,7 @@ extension Collection {
15251523
public func split(
15261524
maxSplits: Int = Int.max,
15271525
omittingEmptySubsequences: Bool = true,
1528-
whereSeparator isSeparator: @noescape (Iterator.Element) throws -> Bool
1526+
isSeparator: @noescape (Iterator.Element) throws -> Bool
15291527
) rethrows -> [SubSequence] {
15301528
// TODO: swift-3-indexing-model - review the following
15311529
_precondition(maxSplits >= 0, "Must take zero or more splits")
@@ -1626,7 +1624,7 @@ extension Collection where Iterator.Element : Equatable {
16261624
return split(
16271625
maxSplits: maxSplits,
16281626
omittingEmptySubsequences: omittingEmptySubsequences,
1629-
whereSeparator: { $0 == separator })
1627+
isSeparator: { $0 == separator })
16301628
}
16311629
}
16321630

@@ -1721,11 +1719,11 @@ extension Collection {
17211719
Builtin.unreachable()
17221720
}
17231721

1724-
@available(*, unavailable, message: "Please use split(maxSplits:omittingEmptySubsequences:whereSeparator:) instead")
1722+
@available(*, unavailable, message: "Please use split(maxSplits:omittingEmptySubsequences:isSeparator:) instead")
17251723
public func split(
17261724
_ maxSplit: Int = Int.max,
17271725
allowEmptySlices: Bool = false,
1728-
whereSeparator isSeparator: @noescape (Iterator.Element) throws -> Bool
1726+
isSeparator: @noescape (Iterator.Element) throws -> Bool
17291727
) rethrows -> [SubSequence] {
17301728
Builtin.unreachable()
17311729
}

0 commit comments

Comments
 (0)