@@ -272,61 +272,31 @@ SubstitutionMap::lookupConformance(CanType type, ProtocolDecl *proto) const {
272272
273273 auto path = genericSig->getConformancePath (type, proto);
274274
275- ProtocolConformanceRef conformance;
276- for (const auto &step : path) {
277- // For the first step, grab the initial conformance.
278- if (conformance.isInvalid ()) {
279- if (auto initialConformance = getSignatureConformance (
280- step.first , step.second )) {
281- conformance = *initialConformance;
282- continue ;
283- }
284-
285- // We couldn't find the initial conformance, fail.
286- return ProtocolConformanceRef::forInvalid ();
287- }
288-
289- // If we've hit an abstract conformance, everything from here on out is
290- // abstract.
291- // FIXME: This may not always be true, but it holds for now.
292- if (conformance.isAbstract ()) {
293- // FIXME: Rip this out once we can get a concrete conformance from
294- // an archetype.
295- return swift::lookupConformance (type.subst (*this ), proto);
296- }
297-
298- // For the second step, we're looking into the requirement signature for
299- // this protocol.
300- if (conformance.isPack ()) {
301- auto pack = conformance.getPack ();
302- conformance = ProtocolConformanceRef (
303- pack->getAssociatedConformance (step.first , step.second ));
304- if (conformance.isInvalid ())
305- return conformance;
306-
307- continue ;
308- }
309-
310- auto concrete = conformance.getConcrete ();
311- auto normal = concrete->getRootNormalConformance ();
312-
313- // If we haven't set the signature conformances yet, force the issue now.
314- if (!normal->hasComputedAssociatedConformances ()) {
315- // If we're in the process of checking the type witnesses, fail
316- // gracefully.
317- //
318- // FIXME: This is unsound, because we may not have diagnosed anything but
319- // still end up with an ErrorType in the AST.
320- if (proto->getASTContext ().evaluator .hasActiveRequest (
321- ResolveTypeWitnessesRequest{normal})) {
322- return ProtocolConformanceRef::forInvalid ();
275+ // For the first step, grab the initial conformance.
276+ auto iter = path.begin ();
277+ const auto step = *iter++;
278+
279+ ProtocolConformanceRef conformance =
280+ *getSignatureConformance (step.first , step.second );
281+
282+ // For each remaining step, project an associated conformance.
283+ while (iter != path.end ()) {
284+ // FIXME: Remove this hack. It is unsound, because we may not have diagnosed
285+ // anything but still end up with an ErrorType in the AST.
286+ if (conformance.isConcrete ()) {
287+ auto concrete = conformance.getConcrete ();
288+ auto normal = concrete->getRootNormalConformance ();
289+
290+ if (!normal->hasComputedAssociatedConformances ()) {
291+ if (proto->getASTContext ().evaluator .hasActiveRequest (
292+ ResolveTypeWitnessesRequest{normal})) {
293+ return ProtocolConformanceRef::forInvalid ();
294+ }
323295 }
324296 }
325297
326- // Get the associated conformance.
327- conformance = concrete->getAssociatedConformance (step.first , step.second );
328- if (conformance.isInvalid ())
329- return conformance;
298+ const auto step = *iter++;
299+ conformance = conformance.getAssociatedConformance (step.first , step.second );
330300 }
331301
332302 return conformance;
0 commit comments