[Concurrency] Don't lose name information from completion-handler arguments.

When a completion handler parameter has a selector piece that ends with
"WithCompletion(Handler)", prepend the text before that suffix to the
base name or previous argument label, as appropriate. This ensures that
we don't lose information from the name, particularly with delegate names.
This commit is contained in:
Doug Gregor
2020-10-22 13:01:23 -07:00
parent 8521453af3
commit 16104d8045
8 changed files with 86 additions and 38 deletions

View File

@@ -442,7 +442,8 @@ public:
///
/// \param allPropertyNames The set of property names in the enclosing context.
///
/// \param isAsync Whether this is a function imported as 'async'.
/// \param completionHandlerIndex For an 'async' function, the index of the
/// completion handler in argNames.
///
/// \param scratch Scratch space that will be used for modifications beyond
/// just chopping names.
@@ -457,9 +458,13 @@ bool omitNeedlessWords(StringRef &baseName,
bool returnsSelf,
bool isProperty,
const InheritedNameSet *allPropertyNames,
bool isAsync,
Optional<unsigned> completionHandlerIndex,
Optional<StringRef> completionHandlerName,
StringScratchSpace &scratch);
/// If the name has a completion-handler suffix, strip off that suffix.
Optional<StringRef> stripWithCompletionHandlerSuffix(StringRef name);
} // end namespace swift
#endif // SWIFT_BASIC_STRINGEXTRAS_H