Skip to content

Commit 331e9e8

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 8f9fcaa commit 331e9e8

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
@@ -311,8 +311,11 @@ void TypeChecker::checkInheritanceClause(Decl *decl,
311311
// Retrieve the location of the start of the inheritance clause.
312312
auto getStartLocOfInheritanceClause = [&] {
313313
if (auto genericTypeDecl = dyn_cast<GenericTypeDecl>(decl)) {
314-
if (auto genericParams = genericTypeDecl->getGenericParams())
315-
return genericParams->getSourceRange().End;
314+
// Get the end location of the generic parameters, except for protocols
315+
// which don't have explicit generic parameters.
316+
if (!isa<ProtocolDecl>(decl))
317+
if (auto genericParams = genericTypeDecl->getGenericParams())
318+
return genericParams->getSourceRange().End;
316319

317320
return genericTypeDecl->getNameLoc();
318321
}
@@ -321,7 +324,7 @@ void TypeChecker::checkInheritanceClause(Decl *decl,
321324
return typeDecl->getNameLoc();
322325

323326
if (auto ext = dyn_cast<ExtensionDecl>(decl))
324-
return ext->getSourceRange().End;
327+
return ext->getExtendedTypeLoc().getLoc();
325328

326329
return SourceLoc();
327330
};

0 commit comments

Comments
 (0)