Skip to content

Type inference: Filter away psuedo types in getTypeMentionRoot - #22694

Open
hvitved wants to merge 1 commit into
github:mainfrom
hvitved:type-inference-filter-pseudo
Open

hvitved wants to merge 1 commit into
github:mainfrom
hvitved:type-inference-filter-pseudo

Conversation

@hvitved

@hvitved hvitved commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

This PR fixes an issue uncovered by unified DCA nightly for the project soto-project/soto where we mistakenly matched TypeMentions that cannot resolve (in that case they are interpreted as "resolving" to UnknownType).

DCA cannot confirm that soto-project/soto now works because it already fails to analyze on the baseline, but I have verified that it works locally. It does show a significant speedup on signalapp/Signal-iOS though.

DCA for rust also shows a speedup.

@hvitved
hvitved force-pushed the type-inference-filter-pseudo branch from c2ae6ee to e0cd79a Compare September 29, 2026 10:07
@hvitved hvitved changed the title Type inference: Filter away psuedo types in more places Type inference: Filter away psuedo types in getTypeMentionRoot Sep 29, 2026
@hvitved
hvitved requested a balanced review from Copilot September 29, 2026 10:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The behavioral change lacks regression coverage, and its documentation is now inaccurate.

Review effort: Balanced
Findings: 2 Low severity

Open (2)
What changed in this PR

Filters pseudo types from root type mentions during shared type inference.

Changes:

  • Excludes PseudoType roots.
  • 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.

Comment on lines +371 to +373
private Type getTypeMentionRoot(TypeMention tm) {
result = tm.getTypeAt(TypePath::nil()) and
not result instanceof PseudoType
private Type getTypeMentionRoot(TypeMention tm) { result = tm.getTypeAt(TypePath::nil()) }
private Type getTypeMentionRoot(TypeMention tm) {
result = tm.getTypeAt(TypePath::nil()) and
not result instanceof PseudoType
@hvitved hvitved added the no-change-note-required This PR does not need a change note label Sep 29, 2026
@hvitved
hvitved marked this pull request as ready for review September 29, 2026 13:43
@hvitved
hvitved requested a review from a team as a code owner September 29, 2026 13:43
typeConstraint(type, constraint) and typeCondition(type, abs, condition)
)
) and
conditionSatisfiesConstraint(_, _, constraint, true)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An unrelated small piece of manual magic; I suspect this is what causes the marginal Rust speedup.

@hvitved
hvitved requested a review from paldepind September 29, 2026 13:56

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-change-note-required This PR does not need a change note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants