Ban generic parameters on extensions.

We no longer allow extensions to provide generic parameters, and the
ability to parse the syntax

  extension Array<String> { ... }

is causing confusion. Fixes rdar://problem/20873336.

Swift SVN r28468
This commit is contained in:
Doug Gregor
2015-05-12 16:26:04 +00:00
parent fcf040402a
commit 985896905e
8 changed files with 27 additions and 109 deletions

View File

@@ -2265,11 +2265,17 @@ Parser::parseDeclExtension(ParseDeclOptions Flags, DeclAttributes &Attributes) {
if (status.isError())
break;
// Parse the generic parameter list.
// Skip over a generic parameter or argument list; they are not
// permitted on extensions.
GenericParamList *genericParams = nullptr;
{
Scope scope(this, ScopeKind::Generics);
genericParams = maybeParseGenericParams();
if (startsWithLess(Tok)) {
SourceLoc lAngleLoc = consumeStartingLess();
skipUntilGreaterInTypeList();
SourceLoc rAngleLoc = Tok.getLoc();
if (startsWithGreater(Tok))
consumeStartingGreater();
diagnose(nameLoc, diag::extension_generic_params_args, name)
.highlight(SourceRange(lAngleLoc, rAngleLoc));
}
auto TyR = new (Context) SimpleIdentTypeRepr(nameLoc, name);