@@ -1229,11 +1229,8 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
1229
1229
predicate relevantAccessConstraint (
1230
1230
Access a , Declaration target , AccessPosition apos , TypePath path , Type constraint
1231
1231
) {
1232
- exists ( DeclarationPosition dpos |
1233
- accessDeclarationPositionMatch ( apos , dpos ) and
1234
- target = a .getTarget ( ) and
1235
- typeParameterConstraintHasTypeParameter ( target , dpos , path , _, constraint , _, _)
1236
- )
1232
+ target = a .getTarget ( ) and
1233
+ typeParameterConstraintHasTypeParameter ( target , apos , path , constraint , _, _)
1237
1234
}
1238
1235
1239
1236
private newtype TRelevantAccess =
@@ -1276,12 +1273,11 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
1276
1273
}
1277
1274
1278
1275
predicate satisfiesConstraintType (
1279
- Access a , AccessPosition apos , TypePath prefix , Type constraint , TypePath path , Type t
1276
+ Access a , Declaration target , AccessPosition apos , TypePath prefix , Type constraint ,
1277
+ TypePath path , Type t
1280
1278
) {
1281
- exists ( RelevantAccess at | at = MkRelevantAccess ( a , _, apos , prefix ) |
1282
- SatisfiesConstraint< RelevantAccess , SatisfiesConstraintInput > :: satisfiesConstraintType ( at ,
1283
- constraint , path , t )
1284
- )
1279
+ SatisfiesConstraint< RelevantAccess , SatisfiesConstraintInput > :: satisfiesConstraintType ( MkRelevantAccess ( a ,
1280
+ target , apos , prefix ) , constraint , path , t )
1285
1281
}
1286
1282
}
1287
1283
@@ -1370,37 +1366,38 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
1370
1366
}
1371
1367
1372
1368
/**
1373
- * Holds if `tp1` and `tp2` are distinct type parameters of `target`, the
1374
- * declared type at `dpos` mentions `tp1` at `path1`, `tp1` has a base
1375
- * type mention of type `constraint` that mentions `tp2` at the path
1376
- * `path2`.
1369
+ * Holds if the declared type of `target` contains a type parameter at
1370
+ * `apos` and `pathToConstrained` that must satisfy `constraint` and `tp`
1371
+ * occurs at `pathToTp` in `constraint`.
1377
1372
*
1378
- * For this example
1373
+ * For example, in
1379
1374
* ```csharp
1380
1375
* interface IFoo<A> { }
1381
1376
* T1 M<T1, T2>(T2 item) where T2 : IFoo<T1> { }
1382
1377
* ```
1383
- * with the method declaration being the target and the for the first
1384
- * parameter position , we have the following
1385
- * - `path1 = ""`,
1386
- * - `tp1 = T2 `,
1378
+ * with the method declaration being the target and with `apos`
1379
+ * corresponding to `item` , we have the following
1380
+ * - `pathToConstrained = ""`,
1381
+ * - `tp = T1 `,
1387
1382
* - `constraint = IFoo`,
1388
- * - `path2 = "A"`, and
1389
- * - `tp2 = T1`.
1383
+ * - `pathToTp = "A"`.
1390
1384
*/
1391
1385
pragma [ nomagic]
1392
1386
private predicate typeParameterConstraintHasTypeParameter (
1393
- Declaration target , DeclarationPosition dpos , TypePath path1 , TypeParameter tp1 ,
1394
- Type constraint , TypePath path2 , TypeParameter tp2
1387
+ Declaration target , AccessPosition apos , TypePath pathToConstrained , Type constraint ,
1388
+ TypePath pathToTp , TypeParameter tp
1395
1389
) {
1396
- tp1 = target .getTypeParameter ( _) and
1397
- tp2 = target .getTypeParameter ( _) and
1398
- tp1 != tp2 and
1399
- tp1 = target .getDeclaredType ( dpos , path1 ) and
1400
- exists ( TypeMention tm |
1401
- tm = getATypeParameterConstraint ( tp1 ) and
1402
- tm .resolveTypeAt ( path2 ) = tp2 and
1403
- constraint = resolveTypeMentionRoot ( tm )
1390
+ exists ( DeclarationPosition dpos , TypeParameter constrainedTp |
1391
+ accessDeclarationPositionMatch ( apos , dpos ) and
1392
+ constrainedTp = target .getTypeParameter ( _) and
1393
+ tp = target .getTypeParameter ( _) and
1394
+ constrainedTp != tp and
1395
+ constrainedTp = target .getDeclaredType ( dpos , pathToConstrained ) and
1396
+ exists ( TypeMention tm |
1397
+ tm = getATypeParameterConstraint ( constrainedTp ) and
1398
+ tm .resolveTypeAt ( pathToTp ) = tp and
1399
+ constraint = resolveTypeMentionRoot ( tm )
1400
+ )
1404
1401
)
1405
1402
}
1406
1403
@@ -1409,15 +1406,9 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
1409
1406
Access a , Declaration target , TypePath path , Type t , TypeParameter tp
1410
1407
) {
1411
1408
not exists ( getTypeArgument ( a , target , tp , _) ) and
1412
- target = a .getTarget ( ) and
1413
- exists (
1414
- Type constraint , AccessPosition apos , DeclarationPosition dpos , TypePath pathToTp ,
1415
- TypePath pathToTp2
1416
- |
1417
- accessDeclarationPositionMatch ( apos , dpos ) and
1418
- typeParameterConstraintHasTypeParameter ( target , dpos , pathToTp2 , _, constraint , pathToTp ,
1419
- tp ) and
1420
- AccessConstraint:: satisfiesConstraintType ( a , apos , pathToTp2 , constraint ,
1409
+ exists ( Type constraint , AccessPosition apos , TypePath pathToTp , TypePath pathToTp2 |
1410
+ typeParameterConstraintHasTypeParameter ( target , apos , pathToTp2 , constraint , pathToTp , tp ) and
1411
+ AccessConstraint:: satisfiesConstraintType ( a , target , apos , pathToTp2 , constraint ,
1421
1412
pathToTp .appendInverse ( path ) , t )
1422
1413
)
1423
1414
}
0 commit comments