Skip to content

Implement RBS prepend support with comprehensive tests #332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sinsoku
Copy link
Contributor

@sinsoku sinsoku commented Aug 9, 2025

This commit adds full support for RBS::AST::Members::Prepend to properly handle prepended modules in type checking and method resolution.

Key changes:

  • Add SigPrependNode class to handle prepend declarations
  • Separate prepended_modules from included_modules in ModuleEntity
  • Fix method resolution order: prepended modules → class → included modules
  • Update type compatibility checking to recognize prepended modules
  • Fix prepend module ordering (last prepended = first in ancestor chain)
  • Add break after finding first matching prepended method

Testing:

  • Add test for basic prepend functionality
  • Add test for multiple prepended modules
  • Add test for prepend and include combination

This ensures that when a class prepends a module, instances of that class are correctly recognized as compatible with the module type, and methods from prepended modules properly override class methods following Ruby semantics.

🤖 Generated with Claude Code

This commit adds full support for RBS::AST::Members::Prepend to properly handle
prepended modules in type checking and method resolution.

Key changes:
- Add SigPrependNode class to handle prepend declarations
- Separate prepended_modules from included_modules in ModuleEntity
- Fix method resolution order: prepended modules → class → included modules
- Update type compatibility checking to recognize prepended modules
- Fix prepend module ordering (last prepended = first in ancestor chain)
- Add break after finding first matching prepended method

Testing:
- Add test for basic prepend functionality
- Add test for multiple prepended modules
- Add test for prepend and include combination

This ensures that when a class prepends a module, instances of that class
are correctly recognized as compatible with the module type, and methods
from prepended modules properly override class methods following Ruby semantics.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
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