mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Change parsing and representation of extensions to accommodate generic parameters.
The eventual goal for extensions of generic types is to require them
to specify their generic parameters, e.g.,
extension Array<T> { ... }
rather than today's
extension Array { ... }
Start parsing (optional) generic parameters here, and update the
representation of ExtensionDecl to accomodate this new grammar
production. Aside from the parser changes, there's no intended
functionality change here.
Swift SVN r20682
This commit is contained in:
@@ -122,14 +122,18 @@ bool SemaAnnotator::walkToDeclPre(Decl *D) {
|
||||
NameLen = VD->getName().getLength();
|
||||
|
||||
} else if (ExtensionDecl *ED = dyn_cast<ExtensionDecl>(D)) {
|
||||
if (TypeRepr *TR = ED->getExtendedTypeLoc().getTypeRepr()) {
|
||||
SourceRange SR = TR->getSourceRange();
|
||||
Loc = SR.Start;
|
||||
NameLen = ED->getASTContext().SourceMgr.getByteDistance(SR.Start, SR.End);
|
||||
} else {
|
||||
Loc = SourceLoc();
|
||||
if (!ED->isInvalid()) {
|
||||
// FIXME: Handle all of the ref-components in extensions, as well as
|
||||
// the generic parameter lists.
|
||||
if (auto nominal = ED->getExtendedType()->getAnyNominal()) {
|
||||
passReference(nominal, ED->getRefComponents().back().NameLoc);
|
||||
}
|
||||
}
|
||||
|
||||
SourceRange SR = ED->getExtendedTypeRange();
|
||||
Loc = SR.Start;
|
||||
if (Loc.isValid())
|
||||
NameLen = ED->getASTContext().SourceMgr.getByteDistance(SR.Start, SR.End);
|
||||
} else if (auto Import = dyn_cast<ImportDecl>(D)) {
|
||||
if (!handleImports(Import))
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user