Skip to content

Refinement does not self-refine properly #7526

@headius

Description

@headius

Encountered while writing up some small benchmarks:

class RefinedFibber
end

module FibRefinement
  # using FibRefinement # without this we cannot recurse
  refine(RefinedFibber) do
    def fib_recursive(a)
      a < 2 ? a : fib_recursive(a - 1) + fib_recursive(a - 2)
    end
  end
end

class RefinedFibberUser
  using FibRefinement
  def initialize
    @refined_fibber = RefinedFibber.new
  end

  def fib_recursive(a)
    @refined_fibber.fib_recursive(a)
  end
end

RefinedFibberUser.new.fib_recursive(30) # => NoMethodError

The annotated line here is necessary for the refinement to see its own methods. This is likely the cause of various small refinement bugs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions