@@ -866,16 +866,18 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
866
866
867
867
private import BaseTypes
868
868
869
- signature module SatisfiesConstraintSig < HasTypeTreeSig TypeTree > {
869
+ signature module SatisfiesConstraintInputSig < HasTypeTreeSig HasTypeTree > {
870
870
/** Holds if it is relevant to know if `term` satisfies `constraint`. */
871
- predicate relevantConstraint ( TypeTree term , Type constraint ) ;
871
+ predicate relevantConstraint ( HasTypeTree term , Type constraint ) ;
872
872
}
873
873
874
- module SatisfiesConstraint< HasTypeTreeSig TypeTree, SatisfiesConstraintSig< TypeTree > Input> {
875
- import Input
874
+ module SatisfiesConstraint<
875
+ HasTypeTreeSig HasTypeTree, SatisfiesConstraintInputSig< HasTypeTree > Input>
876
+ {
877
+ private import Input
876
878
877
- private module IsInstantiationOfInput implements IsInstantiationOfInputSig< TypeTree > {
878
- predicate potentialInstantiationOf ( TypeTree tt , TypeAbstraction abs , TypeMention cond ) {
879
+ private module IsInstantiationOfInput implements IsInstantiationOfInputSig< HasTypeTree > {
880
+ predicate potentialInstantiationOf ( HasTypeTree tt , TypeAbstraction abs , TypeMention cond ) {
879
881
exists ( Type constraint , Type type |
880
882
type = tt .getTypeAt ( TypePath:: nil ( ) ) and
881
883
relevantConstraint ( tt , constraint ) and
@@ -891,7 +893,8 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
891
893
}
892
894
893
895
/** Holds if the type tree has the type `type` and should satisfy `constraint`. */
894
- private predicate hasTypeConstraint ( TypeTree term , Type type , Type constraint ) {
896
+ pragma [ nomagic]
897
+ private predicate hasTypeConstraint ( HasTypeTree term , Type type , Type constraint ) {
895
898
type = term .getTypeAt ( TypePath:: nil ( ) ) and
896
899
relevantConstraint ( term , constraint )
897
900
}
@@ -901,7 +904,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
901
904
*/
902
905
pragma [ nomagic]
903
906
private predicate hasConstraintMention (
904
- TypeTree tt , TypeAbstraction abs , TypeMention sub , Type constraint ,
907
+ HasTypeTree tt , TypeAbstraction abs , TypeMention sub , Type constraint ,
905
908
TypeMention constraintMention
906
909
) {
907
910
exists ( Type type | hasTypeConstraint ( tt , type , constraint ) |
@@ -916,14 +919,15 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
916
919
// constraint we need to find the right implementation, which is the
917
920
// one where the type instantiates the precondition.
918
921
if countConstraintImplementations ( type , constraint ) > 1
919
- then IsInstantiationOf< TypeTree , IsInstantiationOfInput > :: isInstantiationOf ( tt , abs , sub )
922
+ then
923
+ IsInstantiationOf< HasTypeTree , IsInstantiationOfInput > :: isInstantiationOf ( tt , abs , sub )
920
924
else any ( )
921
925
)
922
926
}
923
927
924
928
pragma [ nomagic]
925
929
private predicate satisfiesConstraintTypeMention0 (
926
- TypeTree tt , Type constraint , TypeAbstraction abs , TypeMention sub , TypePath path , Type t
930
+ HasTypeTree tt , Type constraint , TypeAbstraction abs , TypeMention sub , TypePath path , Type t
927
931
) {
928
932
exists ( TypeMention constraintMention |
929
933
hasConstraintMention ( tt , abs , sub , constraint , constraintMention ) and
@@ -933,7 +937,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
933
937
934
938
pragma [ nomagic]
935
939
private predicate satisfiesConstraintTypeMention1 (
936
- TypeTree tt , Type constraint , TypePath path , TypePath pathToTypeParamInSub
940
+ HasTypeTree tt , Type constraint , TypePath path , TypePath pathToTypeParamInSub
937
941
) {
938
942
exists ( TypeAbstraction abs , TypeMention sub , TypeParameter tp |
939
943
satisfiesConstraintTypeMention0 ( tt , constraint , abs , sub , path , tp ) and
@@ -947,7 +951,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
947
951
* with the type `t` at `path`.
948
952
*/
949
953
pragma [ nomagic]
950
- predicate satisfiesConstraintTypeMention ( TypeTree tt , Type constraint , TypePath path , Type t ) {
954
+ predicate satisfiesConstraintType ( HasTypeTree tt , Type constraint , TypePath path , Type t ) {
951
955
exists ( TypeAbstraction abs |
952
956
satisfiesConstraintTypeMention0 ( tt , constraint , abs , _, path , t ) and
953
957
not t = abs .getATypeParameter ( )
@@ -958,6 +962,9 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
958
962
tt .getTypeAt ( pathToTypeParamInSub .appendInverse ( suffix ) ) = t and
959
963
path = prefix0 .append ( suffix )
960
964
)
965
+ or
966
+ tt .getTypeAt ( TypePath:: nil ( ) ) = constraint and
967
+ t = tt .getTypeAt ( path )
961
968
}
962
969
}
963
970
@@ -1234,17 +1241,19 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
1234
1241
Location getLocation ( ) { result = a .getLocation ( ) }
1235
1242
}
1236
1243
1237
- private module SatisfiesConstraintInput implements SatisfiesConstraintSig< RelevantAccess > {
1244
+ private module SatisfiesConstraintInput implements
1245
+ SatisfiesConstraintInputSig< RelevantAccess >
1246
+ {
1238
1247
predicate relevantConstraint ( RelevantAccess at , Type constraint ) {
1239
1248
constraint = at .getConstraint ( )
1240
1249
}
1241
1250
}
1242
1251
1243
- predicate satisfiesConstraintTypeMention (
1252
+ predicate satisfiesConstraintType (
1244
1253
Access a , AccessPosition apos , TypePath prefix , Type constraint , TypePath path , Type t
1245
1254
) {
1246
1255
exists ( RelevantAccess at | at = MkRelevantAccess ( a , _, apos , prefix ) |
1247
- SatisfiesConstraint< RelevantAccess , SatisfiesConstraintInput > :: satisfiesConstraintTypeMention ( at ,
1256
+ SatisfiesConstraint< RelevantAccess , SatisfiesConstraintInput > :: satisfiesConstraintType ( at ,
1248
1257
constraint , path , t )
1249
1258
)
1250
1259
}
@@ -1382,7 +1391,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
1382
1391
accessDeclarationPositionMatch ( apos , dpos ) and
1383
1392
typeParameterConstraintHasTypeParameter ( target , dpos , pathToTp2 , _, constraint , pathToTp ,
1384
1393
tp ) and
1385
- AccessConstraint:: satisfiesConstraintTypeMention ( a , apos , pathToTp2 , constraint ,
1394
+ AccessConstraint:: satisfiesConstraintType ( a , apos , pathToTp2 , constraint ,
1386
1395
pathToTp .appendInverse ( path ) , t )
1387
1396
)
1388
1397
}
0 commit comments