Skip to content

Refinement with super vs. inheritance #5221

@palkan

Description

@palkan

Environment

  • JRuby version: jruby 9.2.0.0 (2.5.0) 2018-05-24 81156a8 OpenJDK 64-Bit Server VM 25.171-b11 on 1.8.0_171-8u171-b11-1~deb9u1-b11 +jit [linux-x86_64]
  • Operating system and platform: Linux 3971953e9581 4.9.49-moby break script engine #1 SMP Fri Dec 8 13:40:02 UTC 2017 x86_64 GNU/Linux

Expected Behavior

The code below print "foo-o-o" (as in CRuby):

class A
  def foo
    "foo"
  end
end

class B < A; end

module SuperExt
  refine A do
    def foo
      super + "-o-o"
    end
  end
end

using SuperExt

p B.new.foo

Actual Behavior

It doesn't activate the refinement and prints "foo".

When calling on a A class instance works as expected:

class A
  def foo
    "foo"
  end
end

module SuperExt
  refine A do
    def foo
      super + "-o-o"
    end
  end
end

using SuperExt

p A.new.foo #=> "foo-o-o"

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