Skip to content

Add rewrite_methods to Redefiner, replacing untyped_methods when type checking is off - #45

Open
obsidiannnn wants to merge 2 commits into
low-rb:mainfrom
obsidiannnn:feature/method-rewriter
Open

Add rewrite_methods to Redefiner, replacing untyped_methods when type checking is off#45
obsidiannnn wants to merge 2 commits into
low-rb:mainfrom
obsidiannnn:feature/method-rewriter

Conversation

@obsidiannnn

Copy link
Copy Markdown
Contributor

Summary

Implements rewrite_methods in Low::Redefiner as the new code path when
LowType.config.type_checking is false. Foundational piece for #38.

Changes

lib/definitions/redefiner.rb

  • Added rewrite_methods - calls method_proxy.rewrite_signature to strip type
    annotations from the shared lines array, then uses klass.class_eval(method_proxy.export)
    to redefine the method directly on the class
  • Preserves private visibility for methods below private_start_line
  • redefine now accepts optional klass: keyword and routes to rewrite_methods
    when type checking is off

lib/low_type.rb

  • Both redefine calls now pass klass: through
  • Result guarded with if result since rewrite_methods returns nil, not a Module

Depends on

Tests

122 examples, 0 failures

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