@@ -1103,29 +1103,6 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
1103
1103
bindingset [ apos]
1104
1104
bindingset [ dpos]
1105
1105
predicate accessDeclarationPositionMatch ( AccessPosition apos , DeclarationPosition dpos ) ;
1106
-
1107
- /**
1108
- * Holds if matching an inferred type `t` at `path` inside an access at `apos`
1109
- * against the declaration `target` means that the type should be adjusted to
1110
- * `tAdj` at `pathAdj`.
1111
- *
1112
- * For example, in
1113
- *
1114
- * ```csharp
1115
- * void M(int? i) {}
1116
- * M(42);
1117
- * ```
1118
- *
1119
- * the inferred type of `42` is `int`, but it should be adjusted to `int?`
1120
- * when matching against `M`.
1121
- */
1122
- bindingset [ apos, target, path, t]
1123
- default predicate adjustAccessType (
1124
- AccessPosition apos , Declaration target , TypePath path , Type t , TypePath pathAdj , Type tAdj
1125
- ) {
1126
- pathAdj = path and
1127
- tAdj = t
1128
- }
1129
1106
}
1130
1107
1131
1108
/**
@@ -1142,14 +1119,11 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
1142
1119
* in `a` is `t` after adjustment by `target`.
1143
1120
*/
1144
1121
pragma [ nomagic]
1145
- private predicate adjustedAccessType (
1122
+ private predicate accessType (
1146
1123
Access a , State state , AccessPosition apos , Declaration target , TypePath path , Type t
1147
1124
) {
1148
1125
target = a .getTarget ( state ) and
1149
- exists ( TypePath path0 , Type t0 |
1150
- t0 = a .getInferredType ( state , apos , path0 ) and
1151
- adjustAccessType ( apos , target , path0 , t0 , path , t )
1152
- )
1126
+ t = a .getInferredType ( state , apos , path )
1153
1127
}
1154
1128
1155
1129
/**
@@ -1182,7 +1156,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
1182
1156
exists ( AccessPosition apos , DeclarationPosition dpos , TypePath pathToTypeParam |
1183
1157
tp = target .getDeclaredType ( dpos , pathToTypeParam ) and
1184
1158
accessDeclarationPositionMatch ( apos , dpos ) and
1185
- adjustedAccessType ( a , state , apos , target , pathToTypeParam .appendInverse ( path ) , t )
1159
+ accessType ( a , state , apos , target , pathToTypeParam .appendInverse ( path ) , t )
1186
1160
)
1187
1161
}
1188
1162
@@ -1193,7 +1167,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
1193
1167
*/
1194
1168
private predicate relevantAccess ( Access a , State state , AccessPosition apos , Type base ) {
1195
1169
exists ( Declaration target , DeclarationPosition dpos |
1196
- adjustedAccessType ( a , state , apos , target , _, _) and
1170
+ accessType ( a , state , apos , target , _, _) and
1197
1171
accessDeclarationPositionMatch ( apos , dpos ) and
1198
1172
declarationBaseType ( target , dpos , base , _, _)
1199
1173
)
@@ -1268,10 +1242,8 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
1268
1242
}
1269
1243
1270
1244
private newtype TRelevantAccess =
1271
- MkRelevantAccess (
1272
- Access a , State state , Declaration target , AccessPosition apos , TypePath path
1273
- ) {
1274
- relevantAccessConstraint ( a , state , target , apos , path , _)
1245
+ MkRelevantAccess ( Access a , State state , AccessPosition apos , TypePath path ) {
1246
+ relevantAccessConstraint ( a , state , _, apos , path , _)
1275
1247
}
1276
1248
1277
1249
/**
@@ -1281,18 +1253,19 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
1281
1253
private class RelevantAccess extends MkRelevantAccess {
1282
1254
Access a ;
1283
1255
State state ;
1284
- Declaration target ;
1285
1256
AccessPosition apos ;
1286
1257
TypePath path ;
1287
1258
1288
- RelevantAccess ( ) { this = MkRelevantAccess ( a , state , target , apos , path ) }
1259
+ RelevantAccess ( ) { this = MkRelevantAccess ( a , state , apos , path ) }
1289
1260
1290
1261
Type getTypeAt ( TypePath suffix ) {
1291
- adjustedAccessType ( a , state , apos , target , path .appendInverse ( suffix ) , result )
1262
+ accessType ( a , state , apos , _ , path .appendInverse ( suffix ) , result )
1292
1263
}
1293
1264
1294
1265
/** Holds if this relevant access should satisfy `constraint`. */
1295
- Type getConstraint ( ) { relevantAccessConstraint ( a , state , target , apos , path , result ) }
1266
+ Type getConstraint ( Declaration target ) {
1267
+ relevantAccessConstraint ( a , state , target , apos , path , result )
1268
+ }
1296
1269
1297
1270
string toString ( ) {
1298
1271
result = a .toString ( ) + ", " + apos .toString ( ) + ", " + path .toString ( )
@@ -1305,16 +1278,20 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
1305
1278
SatisfiesConstraintInputSig< RelevantAccess >
1306
1279
{
1307
1280
predicate relevantConstraint ( RelevantAccess at , Type constraint ) {
1308
- constraint = at .getConstraint ( )
1281
+ constraint = at .getConstraint ( _ )
1309
1282
}
1310
1283
}
1311
1284
1312
1285
predicate satisfiesConstraintType (
1313
1286
Access a , State state , Declaration target , AccessPosition apos , TypePath prefix ,
1314
1287
Type constraint , TypePath path , Type t
1315
1288
) {
1316
- SatisfiesConstraint< RelevantAccess , SatisfiesConstraintInput > :: satisfiesConstraintType ( MkRelevantAccess ( a ,
1317
- state , target , apos , prefix ) , constraint , path , t )
1289
+ exists ( RelevantAccess ra |
1290
+ ra = MkRelevantAccess ( a , state , apos , prefix ) and
1291
+ SatisfiesConstraint< RelevantAccess , SatisfiesConstraintInput > :: satisfiesConstraintType ( ra ,
1292
+ constraint , path , t ) and
1293
+ constraint = ra .getConstraint ( target )
1294
+ )
1318
1295
}
1319
1296
}
1320
1297
@@ -1605,29 +1582,6 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
1605
1582
bindingset [ apos]
1606
1583
bindingset [ dpos]
1607
1584
predicate accessDeclarationPositionMatch ( AccessPosition apos , DeclarationPosition dpos ) ;
1608
-
1609
- /**
1610
- * Holds if matching an inferred type `t` at `path` inside an access at `apos`
1611
- * against the declaration `target` means that the type should be adjusted to
1612
- * `tAdj` at `pathAdj`.
1613
- *
1614
- * For example, in
1615
- *
1616
- * ```csharp
1617
- * void M(int? i) {}
1618
- * M(42);
1619
- * ```
1620
- *
1621
- * the inferred type of `42` is `int`, but it should be adjusted to `int?`
1622
- * when matching against `M`.
1623
- */
1624
- bindingset [ apos, target, path, t]
1625
- default predicate adjustAccessType (
1626
- AccessPosition apos , Declaration target , TypePath path , Type t , TypePath pathAdj , Type tAdj
1627
- ) {
1628
- pathAdj = path and
1629
- tAdj = t
1630
- }
1631
1585
}
1632
1586
1633
1587
/**
@@ -1641,8 +1595,6 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
1641
1595
private import codeql.util.Unit
1642
1596
import Input
1643
1597
1644
- predicate adjustAccessType = Input:: adjustAccessType / 6 ;
1645
-
1646
1598
class State = Unit ;
1647
1599
1648
1600
final private class AccessFinal = Input:: Access ;
0 commit comments