@@ -614,6 +614,8 @@ void PropertyMap::concretizeTypeWitnessInConformance(
614614
615615 MutableTerm constraintType;
616616
617+ RewritePath path;
618+
617619 auto simplify = [&](CanType t) -> CanType {
618620 return CanType (t.transformRec ([&](Type t) -> Optional<Type> {
619621 if (!t->isTypeParameter ())
@@ -640,10 +642,10 @@ void PropertyMap::concretizeTypeWitnessInConformance(
640642 } else {
641643 constraintType = computeConstraintTermForTypeWitness (
642644 key, concreteType, typeWitness, subjectType,
643- substitutions);
645+ substitutions, path );
644646 }
645647
646- inducedRules.emplace_back (subjectType, constraintType );
648+ inducedRules.emplace_back (constraintType, subjectType, path );
647649 if (Debug.contains (DebugFlags::ConcretizeNestedTypes)) {
648650 llvm::dbgs () << " ^^ Induced rule " << constraintType
649651 << " => " << subjectType << " \n " ;
@@ -720,7 +722,8 @@ RewriteSystem::getConcreteTypeWitness(unsigned index) const {
720722// / T.[P:A] => V
721723MutableTerm PropertyMap::computeConstraintTermForTypeWitness (
722724 Term key, CanType concreteType, CanType typeWitness,
723- const MutableTerm &subjectType, ArrayRef<Term> substitutions) const {
725+ const MutableTerm &subjectType, ArrayRef<Term> substitutions,
726+ RewritePath &path) const {
724727 if (!typeWitness->hasTypeParameter ()) {
725728 // Check if we have a shorter representative we can use.
726729 auto domain = key.getRootProtocols ();
@@ -767,6 +770,14 @@ MutableTerm PropertyMap::computeConstraintTermForTypeWitness(
767770 Symbol::forConcreteType (
768771 typeWitnessSchema, result, Context));
769772
773+ RewriteSystem::ConcreteTypeWitness witness (*(constraintType.end () - 3 ),
774+ *(constraintType.end () - 2 ),
775+ *(constraintType.end () - 1 ));
776+ unsigned index = System.recordConcreteTypeWitness (witness);
777+
778+ path.add (RewriteStep::forConcreteTypeWitness (
779+ index, /* inverse=*/ false ));
780+
770781 return constraintType;
771782}
772783
0 commit comments