@@ -145,6 +145,10 @@ signature module InputSig1<LocationSig Location> {
145145 Location getLocation ( ) ;
146146 }
147147
148+ /**
149+ * Holds if `t` is a pseudo type. Pseudo types are skipped when checking for
150+ * non-instantiations in `isNotInstantiationOf`.
151+ */
148152 predicate isPseudoType ( Type t ) ;
149153
150154 /** A type parameter. */
@@ -415,7 +419,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
415419 * not at the path `"T2"`.
416420 */
417421 predicate typeAbstractionHasAmbiguousConstraintAt (
418- TypeAbstraction abs , Type constraint , TypeAbstraction other , TypePath path
422+ TypeAbstraction abs , Type constraint , TypePath path
419423 ) ;
420424
421425 /**
@@ -639,7 +643,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
639643 }
640644
641645 pragma [ nomagic]
642- private Type getNonPseudoTypeAt2 (
646+ private Type getNonPseudoTypeAtTypeParameter (
643647 App app , TypeAbstraction abs , Constraint constraint , TypeParameter tp , TypePath path
644648 ) {
645649 hasTypeParameterAt ( app , abs , constraint , path , tp ) and
@@ -665,18 +669,19 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
665669 predicate isNotInstantiationOf (
666670 App app , TypeAbstraction abs , Constraint constraint , TypePath path
667671 ) {
668- // `app` and `constraint` differ on a concrete type
672+ // `app` and `constraint` differ on a non-pseudo concrete type
669673 exists ( Type t , Type t2 |
670674 t = getTypeAt ( app , abs , constraint , path ) and
671675 not t = abs .getATypeParameter ( ) and
672676 t2 = getNonPseudoTypeAt ( app , path ) and
673677 t2 != t
674678 )
675679 or
676- // satisfiesConcreteTypes(app, abs, constraint) and
680+ // `app` has different instantiations of a type parameter mentioned at two
681+ // different paths
677682 exists ( TypeParameter tp , TypePath path2 , Type t , Type t2 |
678- t = getNonPseudoTypeAt2 ( app , abs , constraint , tp , path ) and
679- t2 = getNonPseudoTypeAt2 ( app , abs , constraint , tp , path2 ) and
683+ t = getNonPseudoTypeAtTypeParameter ( app , abs , constraint , tp , path ) and
684+ t2 = getNonPseudoTypeAtTypeParameter ( app , abs , constraint , tp , path2 ) and
680685 t != t2 and
681686 path != path2
682687 )
@@ -1027,122 +1032,24 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
10271032 )
10281033 }
10291034
1030- private module TermIsInstantiationOfConditionInput2 implements
1031- IsInstantiationOfInputSig< Term , TypeMention >
1032- {
1033- predicate potentialInstantiationOf ( Term term , TypeAbstraction abs , TypeMention cond ) {
1034- TermIsInstantiationOfConditionInput:: potentialInstantiationOf ( term , abs , cond ) and
1035- exists (
1036- TypeMention sub , Type constraintRoot , TypeMention constraintMention ,
1037- TypeAbstraction abs2
1038- |
1039- hasConstraintMention ( term , abs2 , sub , _, constraintRoot , constraintMention ) and
1040- conditionSatisfiesConstraintTypeAt ( abs2 , sub , constraintMention , _, _) and
1041- typeAbstractionHasAmbiguousConstraintAt ( abs2 , constraintRoot , abs , _)
1042- )
1043- }
1044-
1045- predicate relevantConstraint ( TypeMention constraint ) {
1046- TermIsInstantiationOfConditionInput:: relevantConstraint ( constraint )
1047- }
1048- }
1049-
1050- private module TermIsInstantiationOfCondition2 =
1051- IsInstantiationOf< Term , TypeMention , TermIsInstantiationOfConditionInput2 > ;
1052-
10531035 pragma [ nomagic]
10541036 private predicate satisfiesConstraintTypeMention0 (
10551037 Term term , Constraint constraint , TypeMention constraintMention , TypeAbstraction abs ,
10561038 TypeMention sub , TypePath path , Type t , boolean ambiguous
10571039 ) {
10581040 exists ( Type constraintRoot |
10591041 hasConstraintMention ( term , abs , sub , constraint , constraintRoot , constraintMention ) and
1060- conditionSatisfiesConstraintTypeAt ( abs , sub , constraintMention , path , t )
1061- |
1062- exists ( TypePath prefix , TypeAbstraction other |
1063- typeAbstractionHasAmbiguousConstraintAt ( abs , constraintRoot , other , prefix ) and
1064- prefix .isPrefixOf ( path ) and
1065- TermIsInstantiationOfCondition2:: isInstantiationOf ( term , other , _)
1066- // hasConstraintMention(term, other, _, _, constraintRoot, _)
1067- ) and
1068- ambiguous = true
1069- or
1070- forall ( TypePath prefix , TypeAbstraction other |
1071- typeAbstractionHasAmbiguousConstraintAt ( abs , constraintRoot , other , prefix ) and
1072- prefix .isPrefixOf ( path )
1073- |
1074- TermIsInstantiationOfCondition2:: isNotInstantiationOf ( term , other , _, _)
1075- ) and
1076- ambiguous = false
1042+ conditionSatisfiesConstraintTypeAt ( abs , sub , constraintMention , path , t ) and
1043+ if
1044+ exists ( TypePath prefix |
1045+ typeAbstractionHasAmbiguousConstraintAt ( abs , constraintRoot , prefix ) and
1046+ prefix .isPrefixOf ( path )
1047+ )
1048+ then ambiguous = true
1049+ else ambiguous = false
10771050 )
10781051 }
10791052
1080- // private predicate testsatisfiesConstraintTypeMention0(
1081- // Term term, Constraint constraint, TypeMention constraintMention, TypeAbstraction abs,
1082- // TypeMention sub, TypePath path, Type t, boolean ambiguous
1083- // ) {
1084- // exists(string filepath, int startline, int startcolumn, int endline, int endcolumn |
1085- // term.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) and
1086- // filepath.matches("%/main.rs") and
1087- // startline = 435
1088- // ) and
1089- // satisfiesConstraintTypeMention0(term, constraint, constraintMention, abs, sub, path, t,
1090- // ambiguous)
1091- // }
1092- // private predicate testsatisfiesConstraintTypeMention1(
1093- // Term term, Constraint constraint, TypeMention constraintMention, TypeAbstraction abs,
1094- // TypeMention sub, TypePath path, Type t, boolean ambiguous, TypePath prefix,
1095- // TypeAbstraction other, TypePath path2
1096- // ) {
1097- // exists(string filepath, int startline, int startcolumn, int endline, int endcolumn |
1098- // term.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) and
1099- // filepath.matches("%/main.rs") and
1100- // startline = 435
1101- // ) and
1102- // exists(Type constraintRoot |
1103- // hasConstraintMention(term, abs, sub, constraint, constraintRoot, constraintMention) and
1104- // conditionSatisfiesConstraintTypeAt(abs, sub, constraintMention, path, t)
1105- // |
1106- // // if
1107- // // exists(TypePath prefix, TypeAbstraction other |
1108- // // typeAbstractionHasAmbiguousConstraintAt(abs, constraintRoot, other, prefix) and
1109- // // prefix.isPrefixOf(path)
1110- // // )
1111- // // then ambiguous = true
1112- // // else ambiguous = false
1113- // typeAbstractionHasAmbiguousConstraintAt(abs, constraintRoot, other, prefix) and
1114- // // isNotInstantiationOf(term, other, _, constraintRoot) and
1115- // // TermIsInstantiationOfConditionInput::potentialInstantiationOf(term, other, _) and
1116- // prefix.isPrefixOf(path) and
1117- // TermIsInstantiationOfCondition::isNotInstantiationOf(term, other, _, path2) and
1118- // // not isNotInstantiationOf(term, other, _, constraintRoot) and
1119- // ambiguous = false
1120- // // exists(TypePath prefix, TypeAbstraction other |
1121- // // typeAbstractionHasAmbiguousConstraintAt(abs, constraintRoot, other, prefix) and
1122- // // prefix.isPrefixOf(path) and
1123- // // hasConstraintMention(term, other, _, _, constraintRoot, _)
1124- // // ) and
1125- // // ambiguous = true
1126- // // or
1127- // // forall(TypePath prefix, TypeAbstraction other |
1128- // // typeAbstractionHasAmbiguousConstraintAt(abs, constraintRoot, other, prefix)
1129- // // |
1130- // // not prefix.isPrefixOf(path)
1131- // // or
1132- // // // exists(Type type | hasTypeConstraint(term, type, constraint, constraintRoot) |
1133- // // // // countConstraintImplementations(type, constraintRoot) = 0
1134- // // // // or
1135- // // // // not rootTypesSatisfaction(type, constraintRoot, _, _, _)
1136- // // // // or
1137- // // // multipleConstraintImplementations(type, constraintRoot) and
1138- // // // isNotInstantiationOf(term, other, _, constraintRoot)
1139- // // // )
1140- // // isNotInstantiationOf(term, other, _, constraintRoot)
1141- // // // TermIsInstantiationOfCondition::isNotInstantiationOf(term, other, _, _)
1142- // // ) and
1143- // // ambiguous = false
1144- // )
1145- // }
11461053 pragma [ nomagic]
11471054 private predicate conditionSatisfiesConstraintTypeAtForDisambiguation (
11481055 TypeAbstraction abs , TypeMention condition , TypeMention constraint , TypePath path , Type t
0 commit comments