Skip to content

Unified: Treat super as an alias for self in local name binding - #23010

Merged
hvitved merged 3 commits into
github:mainfrom
hvitved:unified/super-as-self
Nov 4, 2026
Merged

hvitved merged 3 commits into
github:mainfrom
hvitved:unified/super-as-self

Conversation

@hvitved

@hvitved hvitved commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

No description provided.

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.

🟢 Approval recommended

No active review issues are reported for the Swift super name-binding and data-flow changes.

No open issues 🎉

What changed in this PR

Updates Unified’s Swift analysis to treat super as an alias for self during local name binding, supporting data flow through inherited members while preserving superclass typing.

Changes:

  • Add a language-plugin hook for resolving super to the receiver’s local name.
  • Exclude super accesses from receiver-variable type propagation.
  • Add name-binding and data-flow cases and update expected results.
File Description
unified/​ql/​test/​library-tests/​local-name-binding/​self_access.swift Adds a superclass-call binding case.
unified/​ql/​test/​library-tests/​dataflow/​test.expected Updates expected data-flow results.
unified/​ql/​test/​library-tests/​dataflow/​accessors_instance.swift Adds flow through superclass property writes and reads.
unified/​ql/​lib/​codeql/​unified/​internal/​typeinference/​TypeInference.qll Preserves separate superclass typing for super.
unified/​ql/​lib/​codeql/​unified/​internal/​NameBindingPluginSwift.qll Maps Swift super accesses to self.
unified/​ql/​lib/​codeql/​unified/​internal/​NameBindingPlugin.qll Defines the superclass receiver-name hook.
unified/​ql/​lib/​codeql/​unified/​internal/​LocalNameBinding.qll Extends potential local accesses to include super.

Review effort: Max

@hvitved hvitved added the no-change-note-required This PR does not need a change note label Nov 4, 2026
@hvitved
hvitved marked this pull request as ready for review November 4, 2026 08:21
@hvitved
hvitved requested a review from a team as a code owner November 4, 2026 08:21
@hvitved
hvitved requested a review from asgerf November 4, 2026 08:21
* Gets the name to be used when resolving `super` expressions, for example
* `this` or `self`.
*/
string getSuperLocalName() { none() }

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.

Could we parameterize this by SuperExpr so the plugin has a way to restrict it to Swift files?

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.

Done.

asgerf
asgerf previously approved these changes Nov 4, 2026
@hvitved
hvitved merged commit dea08cb into github:main Nov 4, 2026
11 of 12 checks passed
@hvitved
hvitved deleted the unified/super-as-self branch November 4, 2026 14:42
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 Unified

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants