@@ -1506,6 +1506,9 @@ bool IndexSwiftASTWalker::reportRelatedRef(ValueDecl *D, SourceLoc Loc, bool isI
1506
1506
bool IndexSwiftASTWalker::reportInheritedTypeRefs (InheritedTypes Inherited,
1507
1507
Decl *Inheritee) {
1508
1508
for (auto Base : Inherited.getEntries ()) {
1509
+ // Suppressed conformances aren't considered base types.
1510
+ if (Base.isSuppressed ())
1511
+ continue ;
1509
1512
if (!reportRelatedTypeRef (Base, (SymbolRoleSet) SymbolRole::RelationBaseOf, Inheritee))
1510
1513
return false ;
1511
1514
}
@@ -1516,6 +1519,25 @@ bool IndexSwiftASTWalker::reportRelatedTypeRepr(const TypeRepr *TR,
1516
1519
SymbolRoleSet Relations,
1517
1520
Decl *Related, bool Implicit,
1518
1521
SourceLoc ParentLoc) {
1522
+ // Look through parens/specifiers/attributes.
1523
+ while (true ) {
1524
+ if (TR->isParenType ()) {
1525
+ TR = TR->getWithoutParens ();
1526
+ continue ;
1527
+ }
1528
+ if (auto *SPR = dyn_cast<SpecifierTypeRepr>(TR)) {
1529
+ TR = SPR->getBase ();
1530
+ continue ;
1531
+ }
1532
+ if (auto *ATR = dyn_cast<AttributedTypeRepr>(TR)) {
1533
+ TR = ATR->getTypeRepr ();
1534
+ continue ;
1535
+ }
1536
+ break ;
1537
+ }
1538
+ // NOTE: We don't yet handle InverseTypeRepr since we don't have an inverse
1539
+ // relation for inheritance.
1540
+
1519
1541
if (auto *composite = dyn_cast<CompositionTypeRepr>(TR)) {
1520
1542
for (auto *Type : composite->getTypes ()) {
1521
1543
if (!reportRelatedTypeRepr (Type, Relations, Related, Implicit,
@@ -1561,6 +1583,15 @@ bool IndexSwiftASTWalker::reportRelatedTypeRepr(const TypeRepr *TR,
1561
1583
bool IndexSwiftASTWalker::reportRelatedType (Type Ty, SymbolRoleSet Relations,
1562
1584
Decl *Related, bool Implicit,
1563
1585
SourceLoc Loc) {
1586
+ // Try decompose a protocol composition.
1587
+ if (auto *PCT = Ty->getAs <ProtocolCompositionType>()) {
1588
+ for (auto member : PCT->getMembers ()) {
1589
+ if (!reportRelatedType (member, Relations, Related, Implicit, Loc))
1590
+ return false ;
1591
+ }
1592
+ return true ;
1593
+ }
1594
+
1564
1595
if (auto *nominal = Ty->getAnyNominal ()) {
1565
1596
if (!reportRelatedRef (nominal, Loc, Implicit, Relations, Related))
1566
1597
return false ;
0 commit comments