@@ -309,7 +309,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
309309 * ```
310310 * the type parameter `T` has the constraint `IComparable<T>`.
311311 */
312- TypeMention getTypeParameterConstraint ( TypeParameter tp ) ;
312+ TypeMention getATypeParameterConstraint ( TypeParameter tp ) ;
313313
314314 /**
315315 * Holds if
@@ -510,29 +510,6 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
510510 )
511511 }
512512
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-
536513 /**
537514 * Holds if `app` is a possible instantiation of `tm`. That is, by making
538515 * appropriate substitutions for the free type parameters in `tm` given by
@@ -546,8 +523,21 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
546523 * - `Pair<int, string>` is _not_ an instantiation of `Pair<string, string>`
547524 */
548525 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+ )
551541 }
552542 }
553543
@@ -599,8 +589,8 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
599589 }
600590
601591 /**
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`.
604594 */
605595 predicate conditionSatisfiesConstraintTypeAt (
606596 TypeAbstraction abs , TypeMention condition , TypeMention constraint , TypePath path , Type t
@@ -1207,7 +1197,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
12071197 tp1 != tp2 and
12081198 tp1 = target .getDeclaredType ( dpos , path1 ) and
12091199 exists ( TypeMention tm |
1210- tm = getTypeParameterConstraint ( tp1 ) and
1200+ tm = getATypeParameterConstraint ( tp1 ) and
12111201 tm .resolveTypeAt ( path2 ) = tp2 and
12121202 constraint = resolveTypeMentionRoot ( tm )
12131203 )
0 commit comments