@@ -809,8 +809,6 @@ AssociatedTypeDecl *AssociatedTypeInference::findDefaultedAssociatedType(
809
809
Type AssociatedTypeInference::computeFixedTypeWitness (
810
810
AssociatedTypeDecl *assocType) {
811
811
Type resultType;
812
- auto *const structuralTy = DependentMemberType::get (
813
- proto->getSelfInterfaceType (), assocType->getName ());
814
812
815
813
// Look at all of the inherited protocols to determine whether they
816
814
// require a fixed type for this associated type.
@@ -823,17 +821,23 @@ Type AssociatedTypeInference::computeFixedTypeWitness(
823
821
824
822
// FIXME: The RequirementMachine will assert on re-entrant construction.
825
823
// We should find a more principled way of breaking this cycle.
826
- if (ctx.isRecursivelyConstructingRequirementMachine (sig.getCanonicalSignature ()))
824
+ if (ctx.isRecursivelyConstructingRequirementMachine (sig.getCanonicalSignature ()) ||
825
+ conformedProto->isComputingRequirementSignature ())
827
826
continue ;
828
827
828
+ auto selfTy = conformedProto->getSelfInterfaceType ();
829
+ if (!sig->requiresProtocol (selfTy, assocType->getProtocol ()))
830
+ continue ;
831
+
832
+ auto structuralTy = DependentMemberType::get (selfTy, assocType->getName ());
829
833
const auto ty = sig->getCanonicalTypeInContext (structuralTy);
830
834
831
835
// A dependent member type with an identical base and name indicates that
832
836
// the protocol does not same-type constrain it in any way; move on to
833
837
// the next protocol.
834
838
if (auto *const memberTy = ty->getAs <DependentMemberType>()) {
835
- if (memberTy->getBase ()->isEqual (structuralTy-> getBase () ) &&
836
- memberTy->getName () == structuralTy ->getName ())
839
+ if (memberTy->getBase ()->isEqual (selfTy ) &&
840
+ memberTy->getName () == assocType ->getName ())
837
841
continue ;
838
842
}
839
843
0 commit comments