mirror of
https://github.com/github/codeql.git
synced 2026-03-30 20:28:15 +02:00
Address review comments
This commit is contained in:
@@ -1033,7 +1033,7 @@ pragma[nomagic]
|
||||
private Type inferStructExprType0(AstNode n, FunctionPosition pos, TypePath path) {
|
||||
exists(StructExprMatchingInput::Access a, StructExprMatchingInput::AccessPosition apos |
|
||||
n = a.getNodeAt(apos) and
|
||||
if apos.isStructPos() then pos.isReturn() else pos.asPosition() = 0 // the acutal position doesn't matter, as long as it is positional
|
||||
if apos.isStructPos() then pos.isReturn() else pos.asPosition() = 0 // the actual position doesn't matter, as long as it is positional
|
||||
|
|
||||
result = StructExprMatching::inferAccessType(a, apos, path)
|
||||
or
|
||||
@@ -1229,12 +1229,9 @@ private module ContextTyping {
|
||||
result = inferCallNonReturnType(n, pos, prefix, path) and
|
||||
hasUnknownTypeAt(n, prefix)
|
||||
|
|
||||
pos.isPosition()
|
||||
or
|
||||
// Never propagate type information directly into the receiver, since its type
|
||||
// must already have been known in order to resolve the call
|
||||
pos.isSelf() and
|
||||
not prefix.isEmpty()
|
||||
if pos.isSelf() then not prefix.isEmpty() else any()
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -2648,12 +2645,12 @@ private Type inferMethodCallTypeNonSelf(AstNode n, FunctionPosition pos, TypePat
|
||||
* empty, at which point the inferred type can be applied back to `n`.
|
||||
*/
|
||||
pragma[nomagic]
|
||||
private Type inferMethodCallTypeSelf(AstNode n, DerefChain derefChain, TypePath path) {
|
||||
private Type inferMethodCallTypeSelf(MethodCall mc, AstNode n, DerefChain derefChain, TypePath path) {
|
||||
exists(
|
||||
MethodCallMatchingInput::AccessPosition apos, string derefChainBorrow, BorrowKind borrow,
|
||||
TypePath path0
|
||||
|
|
||||
result = inferMethodCallType0(_, apos, n, derefChainBorrow, path0) and
|
||||
result = inferMethodCallType0(mc, apos, n, derefChainBorrow, path0) and
|
||||
apos.isSelf() and
|
||||
MethodCallMatchingInput::decodeDerefChainBorrow(derefChainBorrow, derefChain, borrow)
|
||||
|
|
||||
@@ -2672,7 +2669,7 @@ private Type inferMethodCallTypeSelf(AstNode n, DerefChain derefChain, TypePath
|
||||
DerefChain derefChain0, Type t0, TypePath path0, DerefImplItemNode impl, Type selfParamType,
|
||||
TypePath selfPath
|
||||
|
|
||||
t0 = inferMethodCallTypeSelf(n, derefChain0, path0) and
|
||||
t0 = inferMethodCallTypeSelf(mc, n, derefChain0, path0) and
|
||||
derefChain0.isCons(impl, derefChain) and
|
||||
selfParamType = impl.resolveSelfTypeAt(selfPath)
|
||||
|
|
||||
@@ -2692,8 +2689,10 @@ private Type inferMethodCallTypeSelf(AstNode n, DerefChain derefChain, TypePath
|
||||
private Type inferMethodCallTypePreCheck(AstNode n, FunctionPosition pos, TypePath path) {
|
||||
result = inferMethodCallTypeNonSelf(n, pos, path)
|
||||
or
|
||||
result = inferMethodCallTypeSelf(n, DerefChain::nil(), path) and
|
||||
pos.isSelf()
|
||||
exists(MethodCall mc |
|
||||
result = inferMethodCallTypeSelf(mc, n, DerefChain::nil(), path) and
|
||||
if mc instanceof CallExpr then pos.asPosition() = 0 else pos.isSelf()
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2691,7 +2691,7 @@ mod context_typed {
|
||||
let y = Default::default(); // $ type=y:i32 target=default
|
||||
x.push(y); // $ target=push
|
||||
|
||||
let s = Default::default(); // $ MISSING: target=default type=s:S
|
||||
let s = Default::default(); // $ target=default type=s:S
|
||||
S::f(s); // $ target=f
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12100,7 +12100,10 @@ inferType
|
||||
| main.rs:2692:9:2692:9 | x | T | {EXTERNAL LOCATION} | i32 |
|
||||
| main.rs:2692:9:2692:17 | x.push(...) | | {EXTERNAL LOCATION} | () |
|
||||
| main.rs:2692:16:2692:16 | y | | {EXTERNAL LOCATION} | i32 |
|
||||
| main.rs:2694:13:2694:13 | s | | main.rs:2639:5:2640:13 | S |
|
||||
| main.rs:2694:17:2694:34 | ...::default(...) | | main.rs:2639:5:2640:13 | S |
|
||||
| main.rs:2695:9:2695:15 | ...::f(...) | | {EXTERNAL LOCATION} | () |
|
||||
| main.rs:2695:14:2695:14 | s | | main.rs:2639:5:2640:13 | S |
|
||||
| main.rs:2702:14:2702:17 | SelfParam | | main.rs:2700:5:2708:5 | Self [trait MyTrait] |
|
||||
| main.rs:2705:14:2705:18 | SelfParam | | {EXTERNAL LOCATION} | & |
|
||||
| main.rs:2705:14:2705:18 | SelfParam | TRef | main.rs:2700:5:2708:5 | Self [trait MyTrait] |
|
||||
|
||||
Reference in New Issue
Block a user