Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/irb/source_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def method_target(owner_receiver, super_level, method, type)
when "owner"
target_method = owner_receiver.instance_method(method)
when "receiver"
target_method = owner_receiver.method(method)
target_method = Kernel.instance_method(:method).bind_call(owner_receiver, method)
end
super_level.times do |s|
target_method = target_method.super_method if target_method
Expand Down
17 changes: 17 additions & 0 deletions test/irb/command/test_show_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,23 @@ def test_show_source_shows_binary_source
assert_match(%r[Defined in binary file:.+io/console], out)
end

def test_show_source_method_overrided
write_ruby <<~RUBY
class Request
def method; 'POST'; end
def path; '/'; end
end
request = Request.new
binding.irb
RUBY

out = run_ruby_file do
type "show_source request.path"
type "exit"
end
assert_match(%r[#{@ruby_file.to_path}:3\s+def path; '/'; end], out)
end

def test_show_source_with_constant_lookup
write_ruby <<~RUBY
X = 1
Expand Down
Loading