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:
Chris Lattner
2014-02-10 17:39:57 +00:00
parent 2e898da8e7
commit c57b0d25b7
5 changed files with 35 additions and 9 deletions

View File

@@ -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