@@ -177,26 +177,26 @@ AssociatedTypeDecl *RewriteContext::getAssociatedTypeForSymbol(Symbol symbol) {
177177 // The associated type An' is then the canonical associated type
178178 // representative of the associated type symbol [P0&...&Pn:A].
179179 //
180- for (auto *proto : symbol.getProtocols ()) {
181- auto checkOtherAssocType = [&](AssociatedTypeDecl *otherAssocType) {
182- otherAssocType = otherAssocType->getAssociatedTypeAnchor ();
180+ auto *proto = symbol.getProtocol ();
183181
184- if (otherAssocType->getName () == name &&
185- (assocType == nullptr ||
186- TypeDecl::compare (otherAssocType->getProtocol (),
187- assocType->getProtocol ()) < 0 )) {
188- assocType = otherAssocType;
189- }
190- };
182+ auto checkOtherAssocType = [&](AssociatedTypeDecl *otherAssocType) {
183+ otherAssocType = otherAssocType->getAssociatedTypeAnchor ();
191184
192- for (auto *otherAssocType : proto->getAssociatedTypeMembers ()) {
193- checkOtherAssocType (otherAssocType);
185+ if (otherAssocType->getName () == name &&
186+ (assocType == nullptr ||
187+ TypeDecl::compare (otherAssocType->getProtocol (),
188+ assocType->getProtocol ()) < 0 )) {
189+ assocType = otherAssocType;
194190 }
191+ };
195192
196- for (auto *inheritedProto : getInheritedProtocols (proto)) {
197- for (auto *otherAssocType : inheritedProto->getAssociatedTypeMembers ()) {
198- checkOtherAssocType (otherAssocType);
199- }
193+ for (auto *otherAssocType : proto->getAssociatedTypeMembers ()) {
194+ checkOtherAssocType (otherAssocType);
195+ }
196+
197+ for (auto *inheritedProto : getInheritedProtocols (proto)) {
198+ for (auto *otherAssocType : inheritedProto->getAssociatedTypeMembers ()) {
199+ checkOtherAssocType (otherAssocType);
200200 }
201201 }
202202
@@ -318,8 +318,8 @@ getTypeForSymbolRange(const Symbol *begin, const Symbol *end, Type root,
318318#ifndef NDEBUG
319319 // Ensure that the domain of the suffix contains P.
320320 if (iter + 1 < end) {
321- auto protos = (iter + 1 )->getProtocols ();
322- assert (std::find (protos. begin (), protos. end (), symbol.getProtocol () ));
321+ auto proto = (iter + 1 )->getProtocol ();
322+ assert (proto == symbol.getProtocol ());
323323 }
324324#endif
325325 continue ;
@@ -350,10 +350,9 @@ getTypeForSymbolRange(const Symbol *begin, const Symbol *end, Type root,
350350 // of protocols that the prefix conforms to.
351351 #ifndef NDEBUG
352352 auto conformsTo = props->getConformsTo ();
353- for (auto *otherProto : symbol.getProtocols ()) {
354- assert (std::find (conformsTo.begin (), conformsTo.end (), otherProto)
355- != conformsTo.end ());
356- }
353+ assert (std::find (conformsTo.begin (), conformsTo.end (),
354+ symbol.getProtocol ())
355+ != conformsTo.end ());
357356 #endif
358357
359358 assocType = props->getAssociatedType (symbol.getName ());
0 commit comments