@@ -129,7 +129,7 @@ class SourceFileOrModule {
129
129
}
130
130
};
131
131
132
- struct ValueWitness {
132
+ struct IndexedWitness {
133
133
ValueDecl *Member;
134
134
ValueDecl *Requirement;
135
135
};
@@ -146,7 +146,7 @@ class IndexSwiftASTWalker : public SourceEntityWalker {
146
146
Decl *D;
147
147
SymbolInfo SymInfo;
148
148
SymbolRoleSet Roles;
149
- SmallVector<ValueWitness , 6 > ExplicitValueWitnesses ;
149
+ SmallVector<IndexedWitness , 6 > ExplicitWitnesses ;
150
150
SmallVector<SourceLoc, 6 > RefsToSuppress;
151
151
};
152
152
SmallVector<Entity, 6 > EntitiesStack;
@@ -462,8 +462,8 @@ class IndexSwiftASTWalker : public SourceEntityWalker {
462
462
bool reportExtension (ExtensionDecl *D);
463
463
bool reportRef (ValueDecl *D, SourceLoc Loc, IndexSymbol &Info,
464
464
Optional<AccessKind> AccKind);
465
- bool reportImplicitValueConformance (ValueDecl *witness, ValueDecl *requirement,
466
- Decl *container);
465
+ bool reportImplicitConformance (ValueDecl *witness, ValueDecl *requirement,
466
+ Decl *container);
467
467
468
468
bool startEntity (Decl *D, IndexSymbol &Info, bool IsRef);
469
469
bool startEntityDecl (ValueDecl *D);
@@ -535,7 +535,7 @@ class IndexSwiftASTWalker : public SourceEntityWalker {
535
535
// / members.
536
536
// /
537
537
// / \returns false if AST visitation should stop.
538
- bool handleValueWitnesses (Decl *D, SmallVectorImpl<ValueWitness > &explicitValueWitnesses );
538
+ bool handleWitnesses (Decl *D, SmallVectorImpl<IndexedWitness > &explicitWitnesses );
539
539
540
540
void getModuleHash (SourceFileOrModule SFOrMod, llvm::raw_ostream &OS);
541
541
llvm::hash_code hashModule (llvm::hash_code code, SourceFileOrModule SFOrMod);
@@ -695,7 +695,7 @@ bool IndexSwiftASTWalker::visitImports(
695
695
return true ;
696
696
}
697
697
698
- bool IndexSwiftASTWalker::handleValueWitnesses (Decl *D, SmallVectorImpl<ValueWitness > &explicitValueWitnesses ) {
698
+ bool IndexSwiftASTWalker::handleWitnesses (Decl *D, SmallVectorImpl<IndexedWitness > &explicitWitnesses ) {
699
699
auto DC = dyn_cast<DeclContext>(D);
700
700
if (!DC)
701
701
return true ;
@@ -719,11 +719,26 @@ bool IndexSwiftASTWalker::handleValueWitnesses(Decl *D, SmallVectorImpl<ValueWit
719
719
return ;
720
720
721
721
if (decl->getDeclContext () == DC) {
722
- explicitValueWitnesses.push_back (ValueWitness{decl, req});
722
+ explicitWitnesses.push_back ({decl, req});
723
+ } else {
724
+ reportImplicitConformance (decl, req, D);
725
+ }
726
+ });
727
+
728
+ normal->forEachTypeWitness (nullptr ,
729
+ [&](AssociatedTypeDecl *assoc, Type type, TypeDecl *typeDecl) {
730
+ if (Cancelled)
731
+ return true ;
732
+ if (typeDecl == nullptr )
733
+ return false ;
734
+
735
+ if (typeDecl->getDeclContext () == DC) {
736
+ explicitWitnesses.push_back ({typeDecl, assoc});
723
737
} else {
724
738
// Report the implicit conformance.
725
- reportImplicitValueConformance (decl, req , D);
739
+ reportImplicitConformance (typeDecl, assoc , D);
726
740
}
741
+ return false ;
727
742
});
728
743
}
729
744
@@ -741,12 +756,12 @@ bool IndexSwiftASTWalker::startEntity(Decl *D, IndexSymbol &Info, bool IsRef) {
741
756
case swift::index::IndexDataConsumer::Skip:
742
757
return false ;
743
758
case swift::index::IndexDataConsumer::Continue: {
744
- SmallVector<ValueWitness , 6 > explicitValueWitnesses ;
759
+ SmallVector<IndexedWitness , 6 > explicitWitnesses ;
745
760
if (!IsRef) {
746
- if (!handleValueWitnesses (D, explicitValueWitnesses ))
761
+ if (!handleWitnesses (D, explicitWitnesses ))
747
762
return false ;
748
763
}
749
- EntitiesStack.push_back ({D, Info.symInfo , Info.roles , std::move (explicitValueWitnesses ), {}});
764
+ EntitiesStack.push_back ({D, Info.symInfo , Info.roles , std::move (explicitWitnesses ), {}});
750
765
return true ;
751
766
}
752
767
}
@@ -781,7 +796,7 @@ bool IndexSwiftASTWalker::startEntityDecl(ValueDecl *D) {
781
796
}
782
797
783
798
if (auto Parent = getParentDecl ()) {
784
- for (const ValueWitness &witness : EntitiesStack.back ().ExplicitValueWitnesses ) {
799
+ for (const IndexedWitness &witness : EntitiesStack.back ().ExplicitWitnesses ) {
785
800
if (witness.Member == D)
786
801
addRelation (Info, (SymbolRoleSet) SymbolRole::RelationOverrideOf, witness.Requirement );
787
802
}
@@ -1104,8 +1119,8 @@ bool IndexSwiftASTWalker::reportRef(ValueDecl *D, SourceLoc Loc,
1104
1119
return finishCurrentEntity ();
1105
1120
}
1106
1121
1107
- bool IndexSwiftASTWalker::reportImplicitValueConformance (ValueDecl *witness, ValueDecl *requirement,
1108
- Decl *container) {
1122
+ bool IndexSwiftASTWalker::reportImplicitConformance (ValueDecl *witness, ValueDecl *requirement,
1123
+ Decl *container) {
1109
1124
if (!shouldIndex (witness, /* IsRef=*/ true ))
1110
1125
return true ; // keep walking
1111
1126
0 commit comments