Type inference: Filter away psuedo types in getTypeMentionRoot - #22694
Conversation
c2ae6ee to
e0cd79a
Compare
getTypeMentionRoot
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The behavioral change lacks regression coverage, and its documentation is now inaccurate.
Review effort: Balanced
Findings: 2
Open (2)
What changed in this PR
Filters pseudo types from root type mentions during shared type inference.
Changes:
- Excludes
PseudoTyperoots. - Limits instantiation candidates to transitive constraints.
| File | Description |
|---|---|
shared/typeinference/codeql/typeinference/internal/TypeInference.qll |
Refines root-type and constraint matching. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| typeConstraint(type, constraint) and typeCondition(type, abs, condition) | ||
| ) | ||
| ) and | ||
| conditionSatisfiesConstraint(_, _, constraint, true) |
There was a problem hiding this comment.
An unrelated small piece of manual magic; I suspect this is what causes the marginal Rust speedup.
Why do we not address that directly? I.e., make sure that no type mentions resolve to pseudo types to begin with, instead of filtering them out after the fact? |
Because we want to allow for cases where type annotated entities are allowed to have their types inferred from the context whenever the annotation cannot be resolved (for whatever reason). For example in let x : Vec<Unresolved> = Vec::new();
x.push(foo());we will allow for the element type to be inferred from the return type of |
|
Thanks, that makes sense. I think it's worth adding that explanation in a comment before the added |
…doRoot` and extend doc
Good idea, done. |
paldepind
left a comment
There was a problem hiding this comment.
LGTM and I think the final version is much clearer and explicit 👍

This PR fixes an issue uncovered by unified DCA nightly for the project
soto-project/sotowhere we mistakenly matchedTypeMentions that cannot resolve (in that case they are interpreted as "resolving" toUnknownType).DCA cannot confirm that
soto-project/sotonow works because it already fails to analyze on the baseline, but I have verified that it works locally. It does show a significant speedup onsignalapp/Signal-iOSthough.DCA for rust also shows a speedup.