@@ -314,6 +314,14 @@ MutableTerm PropertyMap::computeConstraintTermForTypeWitness(
314314 return result;
315315 }
316316
317+ // Compute the concrete type symbol [concrete: C.X].
318+ SmallVector<Term, 3 > result;
319+ auto typeWitnessSchema =
320+ Context.getRelativeSubstitutionSchemaFromType (typeWitness, substitutions,
321+ result);
322+ auto typeWitnessSymbol =
323+ Symbol::forConcreteType (typeWitnessSchema, result, Context);
324+
317325 // If the type witness is completely concrete, check if one of our prefix
318326 // types has the same concrete type, and if so, introduce a same-type
319327 // requirement between the subject type and the prefix.
@@ -326,10 +334,14 @@ MutableTerm PropertyMap::computeConstraintTermForTypeWitness(
326334 if (auto *props = lookUpProperties (prefix)) {
327335 if (props->isConcreteType () &&
328336 props->getConcreteType () == typeWitness) {
329- auto result = props->getKey ();
337+ // Record a relation U.[concrete: C.X] =>> U.V.[concrete: C : P].[P:X]
338+ // where U is the parent such that U.[concrete: C:X] => U.
339+ MutableTerm result (props->getKey ());
340+ result.add (typeWitnessSymbol);
330341
331342 unsigned relationID = System.recordRelation (
332- result, Term::get (subjectType, Context));
343+ Term::get (result, Context),
344+ Term::get (subjectType, Context));
333345 path.add (RewriteStep::forRelation (
334346 /* startOffset=*/ 0 , relationID,
335347 /* inverse=*/ false ));
@@ -339,7 +351,7 @@ MutableTerm PropertyMap::computeConstraintTermForTypeWitness(
339351 << result << " \n " ;
340352 }
341353
342- return MutableTerm ( result) ;
354+ return result;
343355 }
344356 }
345357
@@ -350,14 +362,6 @@ MutableTerm PropertyMap::computeConstraintTermForTypeWitness(
350362 // Otherwise the type witness is concrete, but may contain type
351363 // parameters in structural position.
352364
353- // Compute the concrete type symbol [concrete: C.X].
354- SmallVector<Term, 3 > result;
355- auto typeWitnessSchema =
356- Context.getRelativeSubstitutionSchemaFromType (typeWitness, substitutions,
357- result);
358- auto typeWitnessSymbol =
359- Symbol::forConcreteType (typeWitnessSchema, result, Context);
360-
361365 auto concreteConformanceSymbol = *(subjectType.end () - 2 );
362366 auto associatedTypeSymbol = *(subjectType.end () - 1 );
363367
0 commit comments