@@ -614,6 +614,8 @@ void PropertyMap::concretizeTypeWitnessInConformance(
614
614
615
615
MutableTerm constraintType;
616
616
617
+ RewritePath path;
618
+
617
619
auto simplify = [&](CanType t) -> CanType {
618
620
return CanType (t.transformRec ([&](Type t) -> Optional<Type> {
619
621
if (!t->isTypeParameter ())
@@ -640,10 +642,10 @@ void PropertyMap::concretizeTypeWitnessInConformance(
640
642
} else {
641
643
constraintType = computeConstraintTermForTypeWitness (
642
644
key, concreteType, typeWitness, subjectType,
643
- substitutions);
645
+ substitutions, path );
644
646
}
645
647
646
- inducedRules.emplace_back (subjectType, constraintType );
648
+ inducedRules.emplace_back (constraintType, subjectType, path );
647
649
if (Debug.contains (DebugFlags::ConcretizeNestedTypes)) {
648
650
llvm::dbgs () << " ^^ Induced rule " << constraintType
649
651
<< " => " << subjectType << " \n " ;
@@ -720,7 +722,8 @@ RewriteSystem::getConcreteTypeWitness(unsigned index) const {
720
722
// / T.[P:A] => V
721
723
MutableTerm PropertyMap::computeConstraintTermForTypeWitness (
722
724
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 {
724
727
if (!typeWitness->hasTypeParameter ()) {
725
728
// Check if we have a shorter representative we can use.
726
729
auto domain = key.getRootProtocols ();
@@ -767,6 +770,14 @@ MutableTerm PropertyMap::computeConstraintTermForTypeWitness(
767
770
Symbol::forConcreteType (
768
771
typeWitnessSchema, result, Context));
769
772
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
+
770
781
return constraintType;
771
782
}
772
783
0 commit comments