Skip to content

Wrong #inspect is used in Method#inspect #4995

@apotonick

Description

@apotonick

Environment

  • JRuby version jruby 9.1.7.0 (2.3.1) 2017-01-11 68056ae OpenJDK 64-Bit Server VM 25.151-b12 on 1.8.0_151-8u151-b12-0ubuntu0.16.04.2-b12 +jit [linux-x86_64]
  • Ubuntu 16.04

Expected Behavior

I override Module.inspect via a module (Inspect), A.inspect produces the correct result.

module Inspect
  def inspect
    "nice view!"
  end
end

module A
  extend Inspect

  def self.a
  end
end

A.inspect #=> "nice view!"

I am expecting the same inspect being used when inspecting a method instance from A.

puts A.method(:a).inspect #=> #<Method: nice view!.a>

This is the behavior in Ruby 2.5.

Actual Behavior

However, in Jruby it seems as if inspect doesn't use the correct version of A.inspect, but the original one.

# jruby 9.1.7
puts A.method(:a).inspect #=> #<Method: A.a>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions