Repository navigation
Unified: Treat super as an alias for self in local name binding - #23010
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 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
superto the receiver’s local name. - Exclude
superaccesses 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
asgerf
reviewed
Nov 4, 2026
| * Gets the name to be used when resolving `super` expressions, for example | ||
| * `this` or `self`. | ||
| */ | ||
| string getSuperLocalName() { none() } |
Contributor
There was a problem hiding this comment.
Could we parameterize this by SuperExpr so the plugin has a way to restrict it to Swift files?
asgerf
previously approved these changes
Nov 4, 2026
jketema
approved these changes
Nov 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.