mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user