@@ -1103,29 +1103,6 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
11031103 bindingset [ apos]
11041104 bindingset [ dpos]
11051105 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- }
11291106 }
11301107
11311108 /**
@@ -1142,14 +1119,11 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
11421119 * in `a` is `t` after adjustment by `target`.
11431120 */
11441121 pragma [ nomagic]
1145- private predicate adjustedAccessType (
1122+ private predicate accessType (
11461123 Access a , State state , AccessPosition apos , Declaration target , TypePath path , Type t
11471124 ) {
11481125 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 )
11531127 }
11541128
11551129 /**
@@ -1182,7 +1156,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
11821156 exists ( AccessPosition apos , DeclarationPosition dpos , TypePath pathToTypeParam |
11831157 tp = target .getDeclaredType ( dpos , pathToTypeParam ) and
11841158 accessDeclarationPositionMatch ( apos , dpos ) and
1185- adjustedAccessType ( a , state , apos , target , pathToTypeParam .appendInverse ( path ) , t )
1159+ accessType ( a , state , apos , target , pathToTypeParam .appendInverse ( path ) , t )
11861160 )
11871161 }
11881162
@@ -1193,7 +1167,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
11931167 */
11941168 private predicate relevantAccess ( Access a , State state , AccessPosition apos , Type base ) {
11951169 exists ( Declaration target , DeclarationPosition dpos |
1196- adjustedAccessType ( a , state , apos , target , _, _) and
1170+ accessType ( a , state , apos , target , _, _) and
11971171 accessDeclarationPositionMatch ( apos , dpos ) and
11981172 declarationBaseType ( target , dpos , base , _, _)
11991173 )
@@ -1268,10 +1242,8 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
12681242 }
12691243
12701244 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 , _)
12751247 }
12761248
12771249 /**
@@ -1281,18 +1253,19 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
12811253 private class RelevantAccess extends MkRelevantAccess {
12821254 Access a ;
12831255 State state ;
1284- Declaration target ;
12851256 AccessPosition apos ;
12861257 TypePath path ;
12871258
1288- RelevantAccess ( ) { this = MkRelevantAccess ( a , state , target , apos , path ) }
1259+ RelevantAccess ( ) { this = MkRelevantAccess ( a , state , apos , path ) }
12891260
12901261 Type getTypeAt ( TypePath suffix ) {
1291- adjustedAccessType ( a , state , apos , target , path .appendInverse ( suffix ) , result )
1262+ accessType ( a , state , apos , _ , path .appendInverse ( suffix ) , result )
12921263 }
12931264
12941265 /** 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+ }
12961269
12971270 string toString ( ) {
12981271 result = a .toString ( ) + ", " + apos .toString ( ) + ", " + path .toString ( )
@@ -1305,16 +1278,20 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
13051278 SatisfiesConstraintInputSig< RelevantAccess >
13061279 {
13071280 predicate relevantConstraint ( RelevantAccess at , Type constraint ) {
1308- constraint = at .getConstraint ( )
1281+ constraint = at .getConstraint ( _ )
13091282 }
13101283 }
13111284
13121285 predicate satisfiesConstraintType (
13131286 Access a , State state , Declaration target , AccessPosition apos , TypePath prefix ,
13141287 Type constraint , TypePath path , Type t
13151288 ) {
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+ )
13181295 }
13191296 }
13201297
@@ -1605,29 +1582,6 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
16051582 bindingset [ apos]
16061583 bindingset [ dpos]
16071584 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- }
16311585 }
16321586
16331587 /**
@@ -1641,8 +1595,6 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
16411595 private import codeql.util.Unit
16421596 import Input
16431597
1644- predicate adjustAccessType = Input:: adjustAccessType / 6 ;
1645-
16461598 class State = Unit ;
16471599
16481600 final private class AccessFinal = Input:: Access ;
0 commit comments