@@ -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);
@@ -696,7 +696,7 @@ bool IndexSwiftASTWalker::visitImports(
696
696
return true ;
697
697
}
698
698
699
- bool IndexSwiftASTWalker::handleValueWitnesses (Decl *D, SmallVectorImpl<ValueWitness > &explicitValueWitnesses ) {
699
+ bool IndexSwiftASTWalker::handleWitnesses (Decl *D, SmallVectorImpl<IndexedWitness > &explicitWitnesses ) {
700
700
auto DC = dyn_cast<DeclContext>(D);
701
701
if (!DC)
702
702
return true ;
@@ -720,11 +720,26 @@ bool IndexSwiftASTWalker::handleValueWitnesses(Decl *D, SmallVectorImpl<ValueWit
720
720
return ;
721
721
722
722
if (decl->getDeclContext () == DC) {
723
- explicitValueWitnesses.push_back (ValueWitness{decl, req});
723
+ explicitWitnesses.push_back ({decl, req});
724
+ } else {
725
+ reportImplicitConformance (decl, req, D);
726
+ }
727
+ });
728
+
729
+ normal->forEachTypeWitness (nullptr ,
730
+ [&](AssociatedTypeDecl *assoc, Type type, TypeDecl *typeDecl) {
731
+ if (Cancelled)
732
+ return true ;
733
+ if (typeDecl == nullptr )
734
+ return false ;
735
+
736
+ if (typeDecl->getDeclContext () == DC) {
737
+ explicitWitnesses.push_back ({typeDecl, assoc});
724
738
} else {
725
739
// Report the implicit conformance.
726
- reportImplicitValueConformance (decl, req , D);
740
+ reportImplicitConformance (typeDecl, assoc , D);
727
741
}
742
+ return false ;
728
743
});
729
744
}
730
745
@@ -742,12 +757,12 @@ bool IndexSwiftASTWalker::startEntity(Decl *D, IndexSymbol &Info, bool IsRef) {
742
757
case swift::index::IndexDataConsumer::Skip:
743
758
return false ;
744
759
case swift::index::IndexDataConsumer::Continue: {
745
- SmallVector<ValueWitness , 6 > explicitValueWitnesses ;
760
+ SmallVector<IndexedWitness , 6 > explicitWitnesses ;
746
761
if (!IsRef) {
747
- if (!handleValueWitnesses (D, explicitValueWitnesses ))
762
+ if (!handleWitnesses (D, explicitWitnesses ))
748
763
return false ;
749
764
}
750
- EntitiesStack.push_back ({D, Info.symInfo , Info.roles , std::move (explicitValueWitnesses ), {}});
765
+ EntitiesStack.push_back ({D, Info.symInfo , Info.roles , std::move (explicitWitnesses ), {}});
751
766
return true ;
752
767
}
753
768
}
@@ -782,7 +797,7 @@ bool IndexSwiftASTWalker::startEntityDecl(ValueDecl *D) {
782
797
}
783
798
784
799
if (auto Parent = getParentDecl ()) {
785
- for (const ValueWitness &witness : EntitiesStack.back ().ExplicitValueWitnesses ) {
800
+ for (const IndexedWitness &witness : EntitiesStack.back ().ExplicitWitnesses ) {
786
801
if (witness.Member == D)
787
802
addRelation (Info, (SymbolRoleSet) SymbolRole::RelationOverrideOf, witness.Requirement );
788
803
}
@@ -1105,8 +1120,8 @@ bool IndexSwiftASTWalker::reportRef(ValueDecl *D, SourceLoc Loc,
1105
1120
return finishCurrentEntity ();
1106
1121
}
1107
1122
1108
- bool IndexSwiftASTWalker::reportImplicitValueConformance (ValueDecl *witness, ValueDecl *requirement,
1109
- Decl *container) {
1123
+ bool IndexSwiftASTWalker::reportImplicitConformance (ValueDecl *witness, ValueDecl *requirement,
1124
+ Decl *container) {
1110
1125
if (!shouldIndex (witness, /* IsRef=*/ true ))
1111
1126
return true ; // keep walking
1112
1127
0 commit comments