feat: support super keyword in class methods with module include#326
Merged
takaokouji merged 4 commits intodevelopfrom Mar 16, 2026
Merged
feat: support super keyword in class methods with module include#326takaokouji merged 4 commits intodevelopfrom
takaokouji merged 4 commits intodevelopfrom
Conversation
Add support for `super(args)` and bare `super` (ForwardingSuperNode) in class methods that override included module methods. super is syntactic sugar for calling the same-named method in an included module. Key changes: - Ruby→Blocks: visitSuperNode/visitForwardingSuperNode handlers with validation (v2-only, sprite-only, method-only, matching module method) - Module method renaming: _super_methodName_N_ pattern when class overrides with super - Blocks→Ruby: @ruby:super and @ruby:super:forwarding comments generate correct super calls; @ruby:module_source:Mod:super_of:func restores original method name in module output - Return value propagation for methods ending with super calls Closes #325 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
🚀 Preview deployed: https://smalruby.jp/smalruby3-editor/feature/super-keyword/ |
When super(args) is the last expression in a method, the generator now correctly outputs just 'super(args)' as the implicit return instead of the internal return variable reference. Uses returnCallCache_ to pass the super call code from procedures_definition to data_setvariableto. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The generator adds a blank line between method end and class end when the method has no event handlers following it. Adjust the expected output to match. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
github-actions bot
pushed a commit
that referenced
this pull request
Mar 16, 2026
…-keyword feat: support super keyword in class methods with module include
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.
Summary
moduleをincludeした class でsuper(args)および引数転送superを使えるようにする機能を実装。super は「モジュールの同名メソッドを呼び出すシンタックスシュガー」として動作する。Changes Made
Ruby → Blocks 変換
visitSuperNode/visitForwardingSuperNodeハンドラー追加(バリデーション含む)_super_methodName_N_パターンで一意な名前に変更@ruby:module_source:Mod:super_of:funcコメントで元のメソッド名を記録Blocks → Ruby 生成
@ruby:superコメント →super(args)出力@ruby:super:forwardingコメント →super出力(引数なし)@ruby:module_source:Mod:super_of:func→ 元のメソッド名funcでmodule Mod内に出力バリデーション
テスト
Implementation Steps
Definition of Done
コード例
Closes #325