mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Implement <rdar://problem/16021869> the first portion of a function selector should allow implicit arg names
This allows us to use implicit names in protocols and asm name functions, as well as for the first chunk of selectors. This feature is particularly useful for delegate methods. Swift SVN r13751
This commit is contained in:
@@ -362,7 +362,8 @@ parseSelectorFunctionArguments(Parser &P,
|
||||
/// identifier '(' pattern-atom (':' type-annotation)? ('=' expr)? ')'
|
||||
///
|
||||
ParserStatus
|
||||
Parser::parseFunctionArguments(SmallVectorImpl<Pattern *> &ArgPatterns,
|
||||
Parser::parseFunctionArguments(Identifier functionName,
|
||||
SmallVectorImpl<Pattern *> &ArgPatterns,
|
||||
SmallVectorImpl<Pattern *> &BodyPatterns,
|
||||
DefaultArgumentInfo &DefaultArgs,
|
||||
bool &HasSelectorStyleSignature) {
|
||||
@@ -370,7 +371,7 @@ Parser::parseFunctionArguments(SmallVectorImpl<Pattern *> &ArgPatterns,
|
||||
|
||||
// Parse the first function argument clause.
|
||||
ParserResult<Pattern> ArgPattern =
|
||||
parsePatternTuple(/*IsLet*/true, /*IsArgList*/true, &DefaultArgs);
|
||||
parseArgument(*this, functionName, &DefaultArgs);
|
||||
|
||||
if (ArgPattern.isNull() || ArgPattern.hasCodeCompletion())
|
||||
return ArgPattern;
|
||||
@@ -416,7 +417,8 @@ Parser::parseFunctionArguments(SmallVectorImpl<Pattern *> &ArgPatterns,
|
||||
///
|
||||
/// Note that this leaves retType as null if unspecified.
|
||||
ParserStatus
|
||||
Parser::parseFunctionSignature(SmallVectorImpl<Pattern *> &argPatterns,
|
||||
Parser::parseFunctionSignature(Identifier Name,
|
||||
SmallVectorImpl<Pattern *> &argPatterns,
|
||||
SmallVectorImpl<Pattern *> &bodyPatterns,
|
||||
DefaultArgumentInfo &defaultArgs,
|
||||
TypeRepr *&retType,
|
||||
@@ -426,8 +428,8 @@ Parser::parseFunctionSignature(SmallVectorImpl<Pattern *> &argPatterns,
|
||||
ParserStatus Status;
|
||||
// We force first type of a func declaration to be a tuple for consistency.
|
||||
if (Tok.is(tok::l_paren)) {
|
||||
Status = parseFunctionArguments(argPatterns, bodyPatterns, defaultArgs,
|
||||
HasSelectorStyleSignature);
|
||||
Status = parseFunctionArguments(Name, argPatterns, bodyPatterns,
|
||||
defaultArgs, HasSelectorStyleSignature);
|
||||
|
||||
if (bodyPatterns.empty()) {
|
||||
// If we didn't get anything, add a () pattern to avoid breaking
|
||||
|
||||
Reference in New Issue
Block a user