Skip to content

Add super call type inference support#59

Merged
dak2 merged 1 commit intomainfrom
add-super-call-support
Mar 14, 2026
Merged

Add super call type inference support#59
dak2 merged 1 commit intomainfrom
add-super-call-support

Conversation

@dak2
Copy link
Owner

@dak2 dak2 commented Mar 14, 2026

Summary

  • Add type inference for super calls (SuperNode and ForwardingSuperNode), which were previously unhandled and caused false-positive TypeErrors on method chains like super.upcase
  • Extract and record superclass names from class Child < Parent declarations into the class scope
  • Introduce super_calls.rs as a dedicated handler and refactor argument collection into a shared collect_arguments() helper reused by both regular and super calls
  • Add current_method_name() / current_superclass() scope helpers for resolving super context

Test plan

  • Rust unit tests for ScopeManager#current_method_name and #current_superclass (including nested block scenarios)
  • Rust integration tests: basic super, super with method chain, super with arguments, multi-level inheritance, qualified superclass (Animals::Pet), edge cases (super outside method, super without superclass)
  • Ruby integration tests: no-error cases (basic, method chain, arguments, multi-level) and error detection (super.even? on String)

🤖 Generated with Claude Code

Previously, `super` calls (both SuperNode and ForwardingSuperNode) were
unhandled by the analyzer, causing the return type of `super` to be
unknown. This meant any method chain on a super call (e.g. `super.upcase`)
would produce a false-positive TypeError, since the receiver type could
not be resolved.

This change:
- Extracts the superclass name from `class Child < Parent` declarations
  and records it in the class scope
- Adds `current_method_name()` and `current_superclass()` helpers to
  ScopeManager for resolving super calls in context
- Introduces `super_calls.rs` to handle SuperNode and ForwardingSuperNode
  by dispatching to the parent class's same-named method
- Refactors argument collection into a shared `collect_arguments()` helper
  reused by both regular method calls and super calls

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dak2 dak2 merged commit a1a0a1d into main Mar 14, 2026
2 checks passed
@dak2 dak2 deleted the add-super-call-support branch March 14, 2026 09:59
@dak2 dak2 mentioned this pull request Mar 15, 2026
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant