@@ -878,6 +878,10 @@ class IndexSwiftASTWalker : public SourceEntityWalker {
878
878
auto AfterDollar = Loc.getAdvancedLoc (1 );
879
879
reportRef (Wrapped, AfterDollar, Info, None);
880
880
}
881
+ } else if (auto *TAD = dyn_cast<TypeAliasDecl>(D)) {
882
+ TypeLoc TL (TAD->getUnderlyingTypeRepr (), TAD->getUnderlyingType ());
883
+ if (!reportRelatedTypeRef (TL, (SymbolRoleSet)SymbolRole::Reference, D, /* isImplicit=*/ true , Loc))
884
+ return false ;
881
885
}
882
886
883
887
return true ;
@@ -962,7 +966,8 @@ class IndexSwiftASTWalker : public SourceEntityWalker {
962
966
bool startEntityDecl (ValueDecl *D);
963
967
964
968
bool reportRelatedRef (ValueDecl *D, SourceLoc Loc, bool isImplicit, SymbolRoleSet Relations, Decl *Related);
965
- bool reportRelatedTypeRef (const TypeLoc &Ty, SymbolRoleSet Relations, Decl *Related);
969
+ bool reportRelatedTypeRef (const TypeLoc &Ty, SymbolRoleSet Relations, Decl *Related,
970
+ bool isImplicit=false , const Optional<SourceLoc> Loc=Optional<SourceLoc>());
966
971
bool reportInheritedTypeRefs (
967
972
ArrayRef<InheritedEntry> Inherited, Decl *Inheritee);
968
973
NominalTypeDecl *getTypeLocAsNominalTypeDecl (const TypeLoc &Ty);
@@ -1372,32 +1377,43 @@ bool IndexSwiftASTWalker::reportRelatedRef(ValueDecl *D, SourceLoc Loc, bool isI
1372
1377
1373
1378
bool IndexSwiftASTWalker::reportInheritedTypeRefs (ArrayRef<InheritedEntry> Inherited, Decl *Inheritee) {
1374
1379
for (auto Base : Inherited) {
1375
- if (auto *composite = llvm::dyn_cast_or_null<CompositionTypeRepr>(Base.getTypeRepr ())) {
1376
- for (auto *type : composite->getTypes ())
1377
- if (!reportRelatedTypeRef (type, (SymbolRoleSet) SymbolRole::RelationBaseOf, Inheritee))
1378
- return false ;
1379
- } else {
1380
- if (!reportRelatedTypeRef (Base, (SymbolRoleSet) SymbolRole::RelationBaseOf, Inheritee))
1381
- return false ;
1382
- }
1380
+ if (!reportRelatedTypeRef (Base, (SymbolRoleSet) SymbolRole::RelationBaseOf, Inheritee))
1381
+ return false ;
1383
1382
}
1384
1383
return true ;
1385
1384
}
1386
1385
1387
- bool IndexSwiftASTWalker::reportRelatedTypeRef (const TypeLoc &Ty, SymbolRoleSet Relations, Decl *Related) {
1388
- if (auto *declRefTR = dyn_cast_or_null<DeclRefTypeRepr>(Ty.getTypeRepr ())) {
1389
- SourceLoc IdLoc = declRefTR->getLoc ();
1386
+ bool IndexSwiftASTWalker::reportRelatedTypeRef (const TypeLoc &Ty, SymbolRoleSet Relations,
1387
+ Decl *Related, bool Implicit, const Optional<SourceLoc> Loc) {
1388
+ if (auto *composite = llvm::dyn_cast_or_null<CompositionTypeRepr>(Ty.getTypeRepr ())) {
1389
+ SourceLoc IdLoc = Loc.value_or (composite->getSourceLoc ());
1390
+ for (auto *Type : composite->getTypes ())
1391
+ if (!reportRelatedTypeRef (Type, Relations, Related, /* isImplicit=*/ Implicit, IdLoc))
1392
+ return false ;
1393
+
1394
+ return true ;
1395
+ } else if (auto *declRefTR = dyn_cast_or_null<DeclRefTypeRepr>(Ty.getTypeRepr ())) {
1396
+ SourceLoc IdLoc = Loc.value_or (declRefTR->getLoc ());
1390
1397
NominalTypeDecl *NTD = nullptr ;
1391
- bool isImplicit = false ;
1398
+ bool isImplicit = Implicit ;
1392
1399
if (auto *VD = declRefTR->getBoundDecl ()) {
1393
1400
if (auto *TAD = dyn_cast<TypeAliasDecl>(VD)) {
1394
1401
IndexSymbol Info;
1402
+ Info.roles |= Relations;
1403
+ if (isImplicit)
1404
+ Info.roles |= (unsigned )SymbolRole::Implicit;
1395
1405
if (!reportRef (TAD, IdLoc, Info, None))
1396
1406
return false ;
1397
1407
if (auto Ty = TAD->getUnderlyingType ()) {
1398
1408
NTD = Ty->getAnyNominal ();
1399
1409
isImplicit = true ;
1400
1410
}
1411
+
1412
+ if (isa<CompositionTypeRepr>(TAD->getUnderlyingTypeRepr ())) {
1413
+ TypeLoc TL (TAD->getUnderlyingTypeRepr (), TAD->getUnderlyingType ());
1414
+ if (!reportRelatedTypeRef (TL, Relations, Related, /* isImplicit=*/ true , IdLoc))
1415
+ return false ;
1416
+ }
1401
1417
} else {
1402
1418
NTD = dyn_cast<NominalTypeDecl>(VD);
1403
1419
}
0 commit comments