Skip to content

Commit 101eea1

Browse files
committed
[Sema] Fix implementation of getStartLocOfInheritanceClause
- Protocol decls don't have explicit generic parameters, so don't use their location. - Get the location of the extended type token rather than the end brace token. Neither of these paths are being exercised yet, so no tests to accompany.
1 parent bd36ce1 commit 101eea1

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/Sema/TypeCheckDecl.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,11 @@ void TypeChecker::checkInheritanceClause(Decl *decl,
363363
// Retrieve the location of the start of the inheritance clause.
364364
auto getStartLocOfInheritanceClause = [&] {
365365
if (auto genericTypeDecl = dyn_cast<GenericTypeDecl>(decl)) {
366-
if (auto genericParams = genericTypeDecl->getGenericParams())
367-
return genericParams->getSourceRange().End;
366+
// Get the end location of the generic parameters, except for protocols
367+
// which don't have explicit generic parameters.
368+
if (!isa<ProtocolDecl>(decl))
369+
if (auto genericParams = genericTypeDecl->getGenericParams())
370+
return genericParams->getSourceRange().End;
368371

369372
return genericTypeDecl->getNameLoc();
370373
}
@@ -373,7 +376,7 @@ void TypeChecker::checkInheritanceClause(Decl *decl,
373376
return typeDecl->getNameLoc();
374377

375378
if (auto ext = dyn_cast<ExtensionDecl>(decl))
376-
return ext->getSourceRange().End;
379+
return ext->getExtendedTypeLoc().getLoc();
377380

378381
return SourceLoc();
379382
};

0 commit comments

Comments
 (0)