Skip to content

Commit 05ce686

Browse files
committed
Type inference: Small join-order tweak
1 parent 0a02b16 commit 05ce686

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

shared/typeinference/codeql/typeinference/internal/TypeInference.qll

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,7 +1416,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
14161416
tp = target.getDeclaredType(dpos, pathToTp) and
14171417
conditionSatisfiesConstraintTypeAt(_, condition, constraint, TypePath::nil(),
14181418
constraintRootType) and
1419-
constraintRootType = target.getDeclaredType(dpos, TypePath::nil()) and
1419+
constraintRootType.getATypeParameter() = pathToTp.getHead() and
14201420
argRootType = condition.getTypeAt(TypePath::nil())
14211421
)
14221422
}
@@ -1445,19 +1445,19 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
14451445
}
14461446

14471447
pragma[nomagic]
1448-
private predicate argRootTypeSatisfiesTargetTypeCand(
1449-
Type argRootType, Access a, AccessEnvironment e, Declaration target, AccessPosition apos,
1450-
TypeParameter tp, TypePath pathToTp
1448+
private predicate accessTargetsWithArgRootType(
1449+
Access a, AccessEnvironment e, Declaration target, AccessPosition apos, Type t
14511450
) {
14521451
target = a.getTarget(e) and
1453-
argRootTypeSatisfiesTargetTypeCand(argRootType, target, apos, tp, pathToTp) and
1454-
not exists(getTypeArgument(a, target, tp, _))
1452+
t = a.getInferredType(e, apos, TypePath::nil())
14551453
}
14561454

14571455
private newtype TRelevantAccess =
14581456
MkRelevantAccess(Access a, AccessPosition apos, AccessEnvironment e) {
1459-
argRootTypeSatisfiesTargetTypeCand(a.getInferredType(e, apos, TypePath::nil()), a, e, _,
1460-
apos, _, _)
1457+
exists(Declaration target, Type t |
1458+
accessTargetsWithArgRootType(a, e, target, apos, t) and
1459+
argRootTypeSatisfiesTargetTypeCand(t, target, apos, _, _)
1460+
)
14611461
}
14621462

14631463
private class RelevantAccess extends MkRelevantAccess {
@@ -1525,9 +1525,11 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
15251525
Access a, AccessEnvironment e, Declaration target, TypePath path, Type t, TypeParameter tp
15261526
) {
15271527
exists(AccessPosition apos, TypePath pathToTp |
1528-
argRootTypeSatisfiesTargetTypeCand(_, a, e, target, apos, tp, pathToTp) and
1529-
SatisfiesParameterConstraint::satisfiesConstraint(MkRelevantAccess(a, apos, e),
1530-
MkRelevantTarget(target, apos), pathToTp.appendInverse(path), t)
1528+
argRootTypeSatisfiesTargetTypeCand(_, target, pragma[only_bind_into](apos), tp, pathToTp) and
1529+
SatisfiesParameterConstraint::satisfiesConstraint(MkRelevantAccess(a,
1530+
pragma[only_bind_into](apos), e),
1531+
MkRelevantTarget(target, pragma[only_bind_into](apos)), pathToTp.appendInverse(path),
1532+
t)
15311533
)
15321534
}
15331535
}

0 commit comments

Comments
 (0)