Skip to content

Add receiverless method call support#20

Merged
dak2 merged 1 commit into
mainfrom
implicit-self-call
Feb 14, 2026
Merged

Add receiverless method call support#20
dak2 merged 1 commit into
mainfrom
implicit-self-call

Conversation

@dak2

@dak2 dak2 commented Feb 14, 2026

Copy link
Copy Markdown
Owner

Ruby methods are frequently called without an explicit receiver (e.g., name instead of self.name). Without handling these, many method return types could not be resolved by the type inference engine.

Changes:

  • Add ImplicitSelfCall variant to NeedsChildKind
  • Dispatch receiver-less CallNode as ImplicitSelfCall, synthesizing an implicit self receiver from the current class/module scope (falls back to Object at top-level)
  • Skip attr_reader/attr_writer/attr_accessor (deferred to next phase)
  • Extract process_method_call_common to share logic between MethodCall and ImplicitSelfCall
  • Hoist block/arguments extraction before receiver branch to eliminate duplication
  • Add 8 tests covering: basic resolution, arguments, nested class, module, block scope, top-level, attr_* skip, and super independence

Ruby methods are frequently called without an explicit receiver
(e.g., `name` instead of `self.name`). Without handling these,
many method return types could not be resolved by the type
inference engine.

## Changes:
- Add ImplicitSelfCall variant to NeedsChildKind
- Dispatch receiver-less CallNode as ImplicitSelfCall, synthesizing
  an implicit self receiver from the current class/module scope
  (falls back to Object at top-level)
- Skip attr_reader/attr_writer/attr_accessor (deferred to next phase)
- Extract process_method_call_common to share logic between
  MethodCall and ImplicitSelfCall
- Hoist block/arguments extraction before receiver branch to
  eliminate duplication
- Add 8 tests covering: basic resolution, arguments, nested class,
  module, block scope, top-level, attr_* skip, and super independence
@dak2 dak2 changed the title Add receiverless method call support (ImplicitSelfCall) Add receiverless method call support Feb 14, 2026
@dak2 dak2 merged commit 0e679d6 into main Feb 14, 2026
2 checks passed
@dak2 dak2 deleted the implicit-self-call branch February 14, 2026 08:37
@dak2 dak2 mentioned this pull request Feb 16, 2026
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