@@ -809,8 +809,6 @@ AssociatedTypeDecl *AssociatedTypeInference::findDefaultedAssociatedType(
809809Type AssociatedTypeInference::computeFixedTypeWitness (
810810 AssociatedTypeDecl *assocType) {
811811 Type resultType;
812- auto *const structuralTy = DependentMemberType::get (
813- proto->getSelfInterfaceType (), assocType->getName ());
814812
815813 // Look at all of the inherited protocols to determine whether they
816814 // require a fixed type for this associated type.
@@ -823,17 +821,23 @@ Type AssociatedTypeInference::computeFixedTypeWitness(
823821
824822 // FIXME: The RequirementMachine will assert on re-entrant construction.
825823 // 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 ())
827826 continue ;
828827
828+ auto selfTy = conformedProto->getSelfInterfaceType ();
829+ if (!sig->requiresProtocol (selfTy, assocType->getProtocol ()))
830+ continue ;
831+
832+ auto structuralTy = DependentMemberType::get (selfTy, assocType->getName ());
829833 const auto ty = sig->getCanonicalTypeInContext (structuralTy);
830834
831835 // A dependent member type with an identical base and name indicates that
832836 // the protocol does not same-type constrain it in any way; move on to
833837 // the next protocol.
834838 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 ())
837841 continue ;
838842 }
839843
0 commit comments