@@ -314,6 +314,14 @@ MutableTerm PropertyMap::computeConstraintTermForTypeWitness(
314
314
return result;
315
315
}
316
316
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
+
317
325
// If the type witness is completely concrete, check if one of our prefix
318
326
// types has the same concrete type, and if so, introduce a same-type
319
327
// requirement between the subject type and the prefix.
@@ -326,10 +334,14 @@ MutableTerm PropertyMap::computeConstraintTermForTypeWitness(
326
334
if (auto *props = lookUpProperties (prefix)) {
327
335
if (props->isConcreteType () &&
328
336
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);
330
341
331
342
unsigned relationID = System.recordRelation (
332
- result, Term::get (subjectType, Context));
343
+ Term::get (result, Context),
344
+ Term::get (subjectType, Context));
333
345
path.add (RewriteStep::forRelation (
334
346
/* startOffset=*/ 0 , relationID,
335
347
/* inverse=*/ false ));
@@ -339,7 +351,7 @@ MutableTerm PropertyMap::computeConstraintTermForTypeWitness(
339
351
<< result << " \n " ;
340
352
}
341
353
342
- return MutableTerm ( result) ;
354
+ return result;
343
355
}
344
356
}
345
357
@@ -350,14 +362,6 @@ MutableTerm PropertyMap::computeConstraintTermForTypeWitness(
350
362
// Otherwise the type witness is concrete, but may contain type
351
363
// parameters in structural position.
352
364
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
-
361
365
auto concreteConformanceSymbol = *(subjectType.end () - 2 );
362
366
auto associatedTypeSymbol = *(subjectType.end () - 1 );
363
367
0 commit comments