Skip to content

Commit 719e220

Browse files
committed
[Concurrency] Move "extra" text from completion handler parameter to base name.
When a completion-handler parameter has text before, e.g., "WithCompletionHandler", put the extra text on the base name rather than the corresponding parameter. This ensures that we don't lose the detail from the text, but always put it into a consistent place.
1 parent b837675 commit 719e220

File tree

3 files changed

+5
-19
lines changed

3 files changed

+5
-19
lines changed

lib/Basic/StringExtras.cpp

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,10 +1322,10 @@ bool swift::omitNeedlessWords(StringRef &baseName,
13221322
}
13231323

13241324
// If this is an asynchronous function where the completion handler is
1325-
// the second parameter, and the corresponding name has some additional
1326-
// information prior to WithCompletion(Handler), append that
1325+
// past the first parameter the corresponding name has some additional
1326+
// information prior to the completion-handled suffix, append that
13271327
// additional text to the base name.
1328-
if (isAsync && *completionHandlerIndex == 1 && completionHandlerName) {
1328+
if (isAsync && *completionHandlerIndex >= 1 && completionHandlerName) {
13291329
if (auto extraParamText = stripWithCompletionHandlerSuffix(
13301330
*completionHandlerName)) {
13311331
SmallString<32> newBaseName;
@@ -1355,20 +1355,6 @@ bool swift::omitNeedlessWords(StringRef &baseName,
13551355
name, paramTypes[i], role,
13561356
role == NameRole::BaseName ? allPropertyNames : nullptr);
13571357

1358-
// If this is an asynchronous function where the completion handler is
1359-
// past the second parameter and has additional information in the name,
1360-
// add that information to the prior argument name.
1361-
if (isAsync && completionHandlerName && *completionHandlerIndex > 1 &&
1362-
*completionHandlerIndex == i + 1) {
1363-
if (auto extraParamText = stripWithCompletionHandlerSuffix(
1364-
*completionHandlerName)) {
1365-
SmallString<32> extendedName;
1366-
extendedName += newName;
1367-
appendSentenceCase(extendedName, *extraParamText);
1368-
newName = scratch.copyString(extendedName);
1369-
}
1370-
}
1371-
13721358
if (name == newName) continue;
13731359

13741360
// Record this change.

lib/ClangImporter/ImportName.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ static bool isCompletionHandlerParamName(StringRef paramName) {
11391139
paramName == "withCompletionHandler" ||
11401140
paramName == "completion" || paramName == "withCompletion" ||
11411141
paramName == "completionBlock" || paramName == "withCompletionBlock" ||
1142-
paramName == "reply" || paramName == "withReply";
1142+
paramName == "reply" || paramName == "withReply" ||
11431143
paramName == "replyTo" || paramName == "withReplyTo";
11441144
}
11451145

test/ClangImporter/objc_async.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func testSlowServer(slowServer: SlowServer) async throws {
2424
let _: Int = await try slowServer.magicNumber(withSeed: 42)
2525

2626
await slowServer.serverRestart("localhost")
27-
await slowServer.server("localhost", atPriorityRestart: 0.8)
27+
await slowServer.serverRestart("localhost", atPriority: 0.8)
2828

2929
_ = await slowServer.allOperations()
3030
}

0 commit comments

Comments
 (0)