@@ -1420,9 +1420,14 @@ SourceRange ASTScope::getSourceRangeImpl() const {
1420
1420
return typeDecl->getSourceRange ();
1421
1421
1422
1422
case ASTScopeKind::ExtensionGenericParams: {
1423
- // The generic parameters of an extension are available from the trailing
1423
+ // The generic parameters of an extension are available from the ':' of
1424
+ // the inheritance clause (if available), or else that from the
1424
1425
// 'where' (if present) or from the start of the body.
1426
+ // FIXME: Approximating the ':' with the start of the first inherited entry.
1425
1427
SourceLoc startLoc;
1428
+ if (!extension->getInherited ().empty () &&
1429
+ extension->getInherited ().front ().getSourceRange ().Start .isValid ())
1430
+ startLoc = extension->getInherited ().front ().getSourceRange ().Start ;
1426
1431
if (auto trailingWhere = extension->getTrailingWhereClause ())
1427
1432
startLoc = trailingWhere->getWhereLoc ();
1428
1433
else
@@ -1807,7 +1812,13 @@ SmallVector<ValueDecl *, 4> ASTScope::getLocalBindings() const {
1807
1812
// No local declarations.
1808
1813
break ;
1809
1814
1810
- case ASTScopeKind::ExtensionGenericParams:
1815
+ case ASTScopeKind::ExtensionGenericParams: {
1816
+ // If the source range containing the extension parameters is empty,
1817
+ // do nothing.
1818
+ SourceRange range = getSourceRangeImpl ();
1819
+ if (range.Start == range.End )
1820
+ break ;
1821
+
1811
1822
// Bind this extension, if we haven't done so already.
1812
1823
if (!extension->getExtendedType ())
1813
1824
if (auto resolver = extension->getASTContext ().getLazyResolver ())
@@ -1821,6 +1832,7 @@ SmallVector<ValueDecl *, 4> ASTScope::getLocalBindings() const {
1821
1832
result.push_back (param);
1822
1833
}
1823
1834
break ;
1835
+ }
1824
1836
1825
1837
case ASTScopeKind::GenericParams:
1826
1838
result.push_back (genericParams.params ->getParams ()[genericParams.index ]);
0 commit comments