@@ -309,7 +309,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
309
309
* ```
310
310
* the type parameter `T` has the constraint `IComparable<T>`.
311
311
*/
312
- TypeMention getTypeParameterConstraint ( TypeParameter tp ) ;
312
+ TypeMention getATypeParameterConstraint ( TypeParameter tp ) ;
313
313
314
314
/**
315
315
* Holds if
@@ -510,29 +510,6 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
510
510
)
511
511
}
512
512
513
- /**
514
- * Holds if all the places where the same type parameter occurs in `tm`
515
- * are equal in `app`.
516
- *
517
- * TODO: As of now this only checks equality at the root of the types
518
- * instantiated for type parameters. So, for instance, `Pair<Vec<i64>, Vec<bool>>`
519
- * is mistakenly considered an instantiation of `Pair<A, A>`.
520
- */
521
- pragma [ nomagic]
522
- private predicate typeParametersHaveEqualInstantiation (
523
- App app , TypeAbstraction abs , TypeMention tm
524
- ) {
525
- // We only need to check equality if the concrete types are satisfied.
526
- satisfiesConcreteTypes ( app , abs , tm ) and
527
- (
528
- not exists ( getNthTypeParameter ( abs , _) )
529
- or
530
- exists ( int n | n = max ( int i | exists ( getNthTypeParameter ( abs , i ) ) ) |
531
- typeParametersHaveEqualInstantiationFromIndex ( app , abs , tm , n )
532
- )
533
- )
534
- }
535
-
536
513
/**
537
514
* Holds if `app` is a possible instantiation of `tm`. That is, by making
538
515
* appropriate substitutions for the free type parameters in `tm` given by
@@ -546,8 +523,21 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
546
523
* - `Pair<int, string>` is _not_ an instantiation of `Pair<string, string>`
547
524
*/
548
525
predicate isInstantiationOf ( App app , TypeAbstraction abs , TypeMention tm ) {
549
- // `typeParametersHaveEqualInstantiation` suffices as it implies `satisfiesConcreteTypes`.
550
- typeParametersHaveEqualInstantiation ( app , abs , tm )
526
+ // We only need to check equality if the concrete types are satisfied.
527
+ satisfiesConcreteTypes ( app , abs , tm ) and
528
+ // Check if all the places where the same type parameter occurs in `tm`
529
+ // are equal in `app`.
530
+ //
531
+ // TODO: As of now this only checks equality at the root of the types
532
+ // instantiated for type parameters. So, for instance, `Pair<Vec<i64>, Vec<bool>>`
533
+ // is mistakenly considered an instantiation of `Pair<A, A>`.
534
+ (
535
+ not exists ( getNthTypeParameter ( abs , _) )
536
+ or
537
+ exists ( int n | n = max ( int i | exists ( getNthTypeParameter ( abs , i ) ) ) |
538
+ typeParametersHaveEqualInstantiationFromIndex ( app , abs , tm , n )
539
+ )
540
+ )
551
541
}
552
542
}
553
543
@@ -599,8 +589,8 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
599
589
}
600
590
601
591
/**
602
- * The type mention `condition` satisfies `constraint` with the type `t`
603
- * at the path `path`.
592
+ * Holds if the type mention `condition` satisfies `constraint` with the
593
+ * type `t` at the path `path`.
604
594
*/
605
595
predicate conditionSatisfiesConstraintTypeAt (
606
596
TypeAbstraction abs , TypeMention condition , TypeMention constraint , TypePath path , Type t
@@ -1207,7 +1197,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
1207
1197
tp1 != tp2 and
1208
1198
tp1 = target .getDeclaredType ( dpos , path1 ) and
1209
1199
exists ( TypeMention tm |
1210
- tm = getTypeParameterConstraint ( tp1 ) and
1200
+ tm = getATypeParameterConstraint ( tp1 ) and
1211
1201
tm .resolveTypeAt ( path2 ) = tp2 and
1212
1202
constraint = resolveTypeMentionRoot ( tm )
1213
1203
)
0 commit comments