@@ -1252,7 +1252,7 @@ bool ArchetypeBuilder::addSameTypeRequirementToConcrete(
12521252 }
12531253
12541254 // Make sure the concrete type fulfills the requirements on the archetype.
1255- DenseMap<ProtocolDecl *, ProtocolConformance* > conformances;
1255+ DenseMap<ProtocolDecl *, ProtocolConformanceRef > conformances;
12561256 if (!Concrete->is <ArchetypeType>()) {
12571257 for (auto conforms : T->getConformsTo ()) {
12581258 auto protocol = conforms.first ;
@@ -1265,8 +1265,7 @@ bool ArchetypeBuilder::addSameTypeRequirementToConcrete(
12651265 return true ;
12661266 }
12671267
1268- assert (conformance->isConcrete () && " Abstract conformance?" );
1269- conformances[protocol] = conformance->getConcrete ();
1268+ conformances.insert ({protocol, *conformance});
12701269 }
12711270 }
12721271
@@ -1288,9 +1287,16 @@ bool ArchetypeBuilder::addSameTypeRequirementToConcrete(
12881287 } else {
12891288 assert (conformances.count (assocType->getProtocol ()) > 0
12901289 && " missing conformance?" );
1291- auto witness = conformances[assocType->getProtocol ()]
1292- ->getTypeWitness (assocType, getLazyResolver ());
1293- auto witnessType = witness.getReplacement ();
1290+ auto conformance = conformances.find (assocType->getProtocol ())->second ;
1291+ Type witnessType;
1292+ if (conformance.isConcrete ()) {
1293+ witnessType = conformance.getConcrete ()
1294+ ->getTypeWitness (assocType, getLazyResolver ())
1295+ .getReplacement ();
1296+ } else {
1297+ witnessType = DependentMemberType::get (Concrete, assocType);
1298+ }
1299+
12941300 if (auto witnessPA = resolveArchetype (witnessType)) {
12951301 addSameTypeRequirementBetweenArchetypes (nested.second .front (),
12961302 witnessPA,
0 commit comments