objc: add explicit-class super sends - #534
Merged
Merged
Conversation
Member
Author
|
@TotallyGamerJet PTAL |
Contributor
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The macOS test hard-codes clang and should resolve or skip unavailable configured compilers.
Review effort: Lite
Findings: None
What changed in this PR
Adds explicit-class Objective-C super-send helpers to prevent recursive dispatch through inherited overrides while preserving legacy behavior.
Changes:
- Adds
SendSuper1andSendSuper2APIs and generic helpers. - Adds dispatch, inheritance, forwarding, and struct-return regression tests.
- Updates examples to use explicit class anchors.
| File | Summary |
|---|---|
objc/testdata/super.m |
Adds Objective-C struct-return fixtures. |
objc/super_darwin_test.go |
Adds super-dispatch and ABI regression coverage. |
objc/objc_runtime_darwin.go |
Implements explicit super-dispatch APIs. |
objc/objc_runtime_darwin_test.go |
Updates API tests and examples. |
examples/objc/main_darwin.go |
Migrates the example to explicit dispatch. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Add SendSuper1 and SendSuper2 methods and generic helpers matching objc_msgSendSuper and objc_msgSendSuper2. Explicit class arguments let inherited overrides dispatch to their defining class's superclass without recursively reentering the override. Deprecate SendSuper while preserving its existing behavior. Cover direct and inherited calls, receiver and argument forwarding, and struct returns, including the amd64 stret path. Update examples to show the different class arguments in a three-level hierarchy. Closes #533 Co-Authored-By: Codex <noreply@openai.com>
hajimehoshi
force-pushed
the
codex/objc-super-dispatch
branch
from
September 22, 2026 15:22
97ab6fc to
96da3b0
Compare
7 tasks
Member
Author
|
I've added an explanation about the background #533 (comment) Apparently |
Add an ID.SendSuper1 example showing direct and inherited receivers in a three-level class hierarchy. Keep the ID.SendSuper2 example focused on its own method and defining-class argument. Co-Authored-By: Codex <noreply@openai.com>
Remove SendSuper1 and its runtime bindings. SendSuper2 covers Objective-C super dispatch using the defining class directly, without a separate superclass lookup. Update examples and regression tests to use SendSuper2, retaining coverage for inherited overrides and struct returns. Keep the legacy SendSuper helpers deprecated and behavior-compatible. Co-Authored-By: Codex <noreply@openai.com>
Clarify the three-level inheritance example and the defining-class argument to SendSuper2. Simplify the dispatch test by removing its mode loop and conditional dispatch, while retaining argument and receiver forwarding, return-value, and compatibility checks. Co-Authored-By: Codex <noreply@openai.com>
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.
What issue is this addressing?
Closes #533
What type of issue is this addressing?
bug
What this PR does | solves
An override that calls SendSuper can recursively reenter itself when the
receiver inherits the override, because dispatch uses the receiver's
runtime class instead of the class defining the method.
Add SendSuper1 and SendSuper2, each as an ID method and a generic helper.
SendSuper1 invokes objc_msgSendSuper and starts lookup in the supplied
superclass. SendSuper2 invokes objc_msgSendSuper2 and starts lookup in
the supplied defining class's superclass. Deprecate SendSuper while
preserving its behavior for compatibility; callers must migrate to an
explicit-class helper to handle inherited overrides correctly.
Add regression tests for direct and inherited calls, receiver and
argument forwarding, return values, and amd64 struct-return dispatch.
Update examples, including a three-level hierarchy showing the class
arguments required by the two helpers.
Validation:
Authored by Codex (OpenAI), on behalf of @hajimehoshi.