@@ -207,22 +207,22 @@ AssociatedTypeInference::inferTypeWitnessesViaValueWitnesses(
207
207
if (extendedNominal == nullptr )
208
208
return true ;
209
209
210
- // FIXME: The extension may not have a generic signature set up yet as
211
- // resolving signatures may trigger associated type inference. This cycle
212
- // is now detectable and we should look into untangling it
213
- // - see rdar://55263708
214
- if (!extension->hasComputedGenericSignature ())
215
- return true ;
216
-
217
- // Retrieve the generic signature of the extension.
218
- const auto extensionSig = extension->getGenericSignature ();
219
-
220
210
auto *proto = dyn_cast<ProtocolDecl>(extendedNominal);
221
211
222
212
// If the extension is bound to the nominal the conformance is
223
213
// declared on, it is viable for inference when its conditional
224
214
// requirements are satisfied by those of the conformance context.
225
215
if (!proto) {
216
+ // FIXME: The extension may not have a generic signature set up yet as
217
+ // resolving signatures may trigger associated type inference. This cycle
218
+ // is now detectable and we should look into untangling it
219
+ // - see rdar://55263708
220
+ if (!extension->hasComputedGenericSignature ())
221
+ return true ;
222
+
223
+ // Retrieve the generic signature of the extension.
224
+ const auto extensionSig = extension->getGenericSignature ();
225
+
226
226
// Extensions of non-generic nominals are always viable for inference.
227
227
if (!extensionSig)
228
228
return true ;
@@ -261,9 +261,6 @@ AssociatedTypeInference::inferTypeWitnessesViaValueWitnesses(
261
261
return true ;
262
262
};
263
263
264
- auto typeInContext =
265
- conformance->getDeclContext ()->mapTypeIntoContext (conformance->getType ());
266
-
267
264
for (auto witness :
268
265
checker.lookupValueWitnesses (req, /* ignoringNames=*/ nullptr )) {
269
266
LLVM_DEBUG (llvm::dbgs () << " Inferring associated types from decl:\n " ;
@@ -319,6 +316,10 @@ AssociatedTypeInference::inferTypeWitnessesViaValueWitnesses(
319
316
if (!associatedTypesAreSameEquivalenceClass (dmt->getAssocType (),
320
317
result.first ))
321
318
return false ;
319
+
320
+ auto typeInContext =
321
+ conformance->getDeclContext ()->mapTypeIntoContext (conformance->getType ());
322
+
322
323
if (!dmt->getBase ()->isEqual (typeInContext))
323
324
return false ;
324
325
0 commit comments