Allow protocol extensions to add further constraints via a trailing where clause.

Start parsing a "trailing" where clause for extension declarations, which follows the extended type name and (optional) inheritance clause. Such a where clause is only currently permitted for protocol extensions right now.

When used on a protocol extension, it allows one to create a more-constrained protocol extension, e.g.,

  extension CollectionType where Self.Generator.Element : Equatable { ... }

which appears to be working, at least in the obvious cases I've tried.

More cleanup, tests, and penance for the previous commit's "--crash" introductions still to come.

Swift SVN r26689
This commit is contained in:
Doug Gregor
2015-03-29 05:42:37 +00:00
parent 2609a971b6
commit ccde6bb87d
11 changed files with 251 additions and 25 deletions

View File

@@ -2881,7 +2881,7 @@ Decl *ModuleFile::getDecl(DeclID DID, Optional<DeclContext *> ForcedContext) {
auto nominal = baseTy->getAnyNominal();
auto extension = ExtensionDecl::create(ctx, SourceLoc(), refComponents, { },
DC);
DC, nullptr);
extension->setEarlyAttrValidation();
declOrOffset = extension;