Skip to content

Commit fad1263

Browse files
authored
[5.9] Include extended typealias in index data (#65532)
Previously only the type underlying the typealias was included in the index data. Now the extension of a typealias includes 2 entries, 1 for the underlying type and one for the typealias definition. Fixes #64594 (cherry picked from commit e80bbd5)
1 parent 725bdcd commit fad1263

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/Index/Index.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,8 +1536,8 @@ bool IndexSwiftASTWalker::reportExtension(ExtensionDecl *D) {
15361536
if (!startEntity(D, Info, /*IsRef=*/false))
15371537
return false;
15381538

1539-
if (!reportRelatedRef(NTD, Loc, /*isImplicit=*/false,
1540-
(SymbolRoleSet)SymbolRole::RelationExtendedBy, D))
1539+
TypeLoc TL(D->getExtendedTypeRepr(), D->getExtendedType());
1540+
if (!reportRelatedTypeRef(TL, (SymbolRoleSet)SymbolRole::RelationExtendedBy, D))
15411541
return false;
15421542
if (!reportInheritedTypeRefs(D->getInherited(), D))
15431543
return false;

test/Index/roles.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,3 +499,13 @@ protocol WithPrimary<Assoc> {
499499
// CHECK: [[@LINE-1]]:18 | type-alias/associated-type/Swift | Assoc | {{.*}} | Def,RelChild | rel: 1
500500
// CHECK-NEXT: RelChild | protocol/Swift | WithPrimary | {{.*}}
501501
}
502+
503+
struct Root {} // CHECK: [[@LINE]]:8 | struct/Swift | Root | [[Root_USR:.*]] | Def | rel: 0
504+
505+
typealias Alias = Root // CHECK: [[@LINE]]:11 | type-alias/Swift | Alias | [[Alias_USR:.*]] | Def | rel: 0
506+
507+
extension Alias {
508+
// CHECK: [[@LINE-1]]:11 | type-alias/Swift | Alias | [[Alias_USR]] | Ref | rel: 0
509+
// CHECK: [[@LINE-2]]:11 | struct/Swift | Root | [[Root_USR]] | Ref,Impl,RelExt | rel: 1
510+
func empty() {}
511+
}

0 commit comments

Comments
 (0)