Restrict use of default arguments on protocol method signatures.

We were never handling this correctly, and default arguments are checked along with the method body.
In some cases where no further validation was necessary (such as when the default argument was a literal value),
the compiler would let this slip through but in others this would cause a crash.  (rdar://problem/16476405)

Swift SVN r15736
This commit is contained in:
Joe Pamer
2014-04-01 16:53:21 +00:00
parent af5aeadc98
commit cbc69bc8ee
5 changed files with 31 additions and 2 deletions

View File

@@ -89,6 +89,8 @@ static ParserStatus parseDefaultArgument(Parser &P,
auto inFlight = P.diagnose(equalLoc, diag::non_func_decl_pattern_init);
if (initR.isNonNull())
inFlight.fixItRemove(SourceRange(equalLoc, initR.get()->getEndLoc()));
} else {
defaultArgs->HasDefaultArgument = true;
}
if (initR.hasCodeCompletion()) {