@@ -355,7 +355,7 @@ class IndexSwiftASTWalker : public SourceEntityWalker {
355
355
bool startEntity (Decl *D, IndexSymbol &Info);
356
356
bool startEntityDecl (ValueDecl *D);
357
357
358
- bool reportRelatedRef (ValueDecl *D, SourceLoc Loc, SymbolRoleSet Relations, Decl *Related);
358
+ bool reportRelatedRef (ValueDecl *D, SourceLoc Loc, bool isImplicit, SymbolRoleSet Relations, Decl *Related);
359
359
bool reportRelatedTypeRef (const TypeLoc &Ty, SymbolRoleSet Relations, Decl *Related);
360
360
bool reportInheritedTypeRefs (ArrayRef<TypeLoc> Inherited, Decl *Inheritee);
361
361
NominalTypeDecl *getTypeLocAsNominalTypeDecl (const TypeLoc &Ty);
@@ -624,13 +624,16 @@ bool IndexSwiftASTWalker::startEntityDecl(ValueDecl *D) {
624
624
return startEntity (D, Info);
625
625
}
626
626
627
- bool IndexSwiftASTWalker::reportRelatedRef (ValueDecl *D, SourceLoc Loc, SymbolRoleSet Relations, Decl *Related) {
627
+ bool IndexSwiftASTWalker::reportRelatedRef (ValueDecl *D, SourceLoc Loc, bool isImplicit,
628
+ SymbolRoleSet Relations, Decl *Related) {
628
629
if (!shouldIndex (D))
629
630
return true ;
630
631
631
632
IndexSymbol Info;
632
633
if (addRelation (Info, Relations, Related))
633
634
return true ;
635
+ if (isImplicit)
636
+ Info.roles |= (unsigned )SymbolRole::Implicit;
634
637
635
638
// don't report this ref again when visitDeclReference reports it
636
639
repressRefAtLoc (Loc);
@@ -655,17 +658,32 @@ bool IndexSwiftASTWalker::reportRelatedTypeRef(const TypeLoc &Ty, SymbolRoleSet
655
658
656
659
if (IdentTypeRepr *T = dyn_cast_or_null<IdentTypeRepr>(Ty.getTypeRepr ())) {
657
660
auto Comps = T->getComponentRange ();
658
- if (auto NTD =
659
- dyn_cast_or_null<NominalTypeDecl>(Comps.back ()->getBoundDecl ())) {
660
- if (!reportRelatedRef (NTD, Comps.back ()->getIdLoc (), Relations, Related))
661
+ SourceLoc IdLoc = Comps.back ()->getIdLoc ();
662
+ NominalTypeDecl *NTD = nullptr ;
663
+ bool isImplicit = false ;
664
+ if (auto *VD = Comps.back ()->getBoundDecl ()) {
665
+ if (auto *TAD = dyn_cast<TypeAliasDecl>(VD)) {
666
+ IndexSymbol Info;
667
+ if (!reportRef (TAD, IdLoc, Info))
668
+ return false ;
669
+ if (auto Ty = TAD->getUnderlyingTypeLoc ().getType ()) {
670
+ NTD = Ty->getAnyNominal ();
671
+ isImplicit = true ;
672
+ }
673
+ } else {
674
+ NTD = dyn_cast<NominalTypeDecl>(VD);
675
+ }
676
+ }
677
+ if (NTD) {
678
+ if (!reportRelatedRef (NTD, IdLoc, isImplicit, Relations, Related))
661
679
return false ;
662
680
}
663
681
return true ;
664
682
}
665
683
666
684
if (Ty.getType ()) {
667
685
if (auto nominal = Ty.getType ()->getAnyNominal ())
668
- if (!reportRelatedRef (nominal, Ty.getLoc (), Relations, Related))
686
+ if (!reportRelatedRef (nominal, Ty.getLoc (), /* isImplicit= */ false , Relations, Related))
669
687
return false ;
670
688
}
671
689
return true ;
@@ -752,8 +770,8 @@ bool IndexSwiftASTWalker::reportExtension(ExtensionDecl *D) {
752
770
if (!startEntity (D, Info))
753
771
return false ;
754
772
755
- if (!reportRelatedRef (NTD, Loc, (SymbolRoleSet)SymbolRole::RelationExtendedBy ,
756
- D))
773
+ if (!reportRelatedRef (NTD, Loc, /* isImplicit= */ false ,
774
+ (SymbolRoleSet)SymbolRole::RelationExtendedBy, D))
757
775
return false ;
758
776
if (!reportInheritedTypeRefs (D->getInherited (), D))
759
777
return false ;
0 commit comments