@@ -26,13 +26,17 @@ class << self
2626 # @param [Binding] b
2727 # @return [Boolean]
2828 def normal_method? ( method , b )
29- method && ( method . source_file && method . source_range rescue false ) &&
30- File . expand_path ( method . source_file ) == File . expand_path ( b . eval ( '__FILE__' ) ) &&
31- method . source_range . include? ( b . eval ( '__LINE__' ) )
29+ if method and method . source_file and method . source_range
30+ binding_file , binding_line = b . eval ( '__FILE__' ) , b . eval ( '__LINE__' )
31+ File . expand_path ( method . source_file ) == File . expand_path ( binding_file ) and
32+ method . source_range . include? ( binding_line )
33+ end
34+ rescue
35+ false
3236 end
3337
3438 def weird_method? ( method , b )
35- ! normal_method? ( method , b )
39+ not normal_method? ( method , b )
3640 end
3741 end
3842
@@ -61,6 +65,11 @@ def lost_method?
6165
6266 private
6367
68+ def skip_superclass_search?
69+ target_mod = @target . eval ( 'self' ) . class
70+ target_mod . ancestors . take_while { |mod | mod != target_mod } . any?
71+ end
72+
6473 def normal_method? ( method )
6574 self . class . normal_method? ( method , target )
6675 end
@@ -98,7 +107,9 @@ def pry_file?
98107 # superclass method.
99108 def find_method_in_superclass
100109 guess = method
101-
110+ if skip_superclass_search?
111+ return guess
112+ end
102113 while guess
103114 # needs rescue if this is a Disowned method or a C method or something...
104115 # TODO: Fix up the exception handling so we don't need a bare rescue
0 commit comments