File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -191,6 +191,27 @@ class alignas(1 << DeclAlignInBits) ProtocolConformance
191
191
return false ;
192
192
}
193
193
194
+ // / Apply the given function object to each associated conformance requirement
195
+ // / within this protocol conformance.
196
+ // /
197
+ // / \returns true if the function ever returned true
198
+ template <typename F>
199
+ bool forEachAssociatedConformance (F f) const {
200
+ const ProtocolDecl *protocol = getProtocol ();
201
+ unsigned index = 0 ;
202
+ for (auto req : protocol->getRequirementSignature ().getRequirements ()) {
203
+ if (req.getKind () != RequirementKind::Conformance)
204
+ continue ;
205
+
206
+ if (f (req.getFirstType (), req.getProtocolDecl (), index))
207
+ return true ;
208
+
209
+ ++index;
210
+ }
211
+
212
+ return false ;
213
+ }
214
+
194
215
// / Retrieve the value witness declaration corresponding to the given
195
216
// / requirement.
196
217
ValueDecl *getWitnessDecl (ValueDecl *requirement) const ;
You can’t perform that action at this time.
0 commit comments