File tree Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -863,7 +863,13 @@ def find_local_symbol(symbol)
863
863
# Finds a method named +name+ with singleton value +singleton+.
864
864
865
865
def find_method ( name , singleton )
866
- @method_list . find { |m | m . name == name && m . singleton == singleton }
866
+ @method_list . find { |m |
867
+ if m . singleton
868
+ m . name == name && m . singleton == singleton
869
+ else
870
+ m . name == name && !m . singleton && !singleton
871
+ end
872
+ }
867
873
end
868
874
869
875
##
Original file line number Diff line number Diff line change @@ -151,6 +151,19 @@ def test_marshal_load_aliased_method
151
151
assert aliased_method . display?
152
152
end
153
153
154
+ def test_marshal_load_aliased_method_with_nil_singleton
155
+ aliased_method = Marshal . load Marshal . dump ( @c2_a )
156
+
157
+ aliased_method . store = @store
158
+ aliased_method . is_alias_for = [ "C2" , nil , "b" ]
159
+
160
+ assert_equal 'C2#a' , aliased_method . full_name
161
+ assert_equal 'C2' , aliased_method . parent_name
162
+ assert_equal '()' , aliased_method . params
163
+ assert_equal @c2_b , aliased_method . is_alias_for , 'is_alias_for'
164
+ assert aliased_method . display?
165
+ end
166
+
154
167
def test_marshal_load_class_method
155
168
class_method = Marshal . load Marshal . dump ( @c1 . method_list . first )
156
169
Original file line number Diff line number Diff line change @@ -559,6 +559,14 @@ def test_find_local_symbol
559
559
assert_equal @c2_c3 , @c2 . find_local_symbol ( 'C3' )
560
560
end
561
561
562
+ def test_find_method
563
+ loaded_c2 = Marshal . load Marshal . dump @c2
564
+ assert_equal @c2_a , loaded_c2 . find_method ( 'a' , false )
565
+ assert_equal @c2_b , loaded_c2 . find_method ( 'b' , false )
566
+ assert_equal @c2_a , loaded_c2 . find_method ( 'a' , nil )
567
+ assert_equal @c2_b , loaded_c2 . find_method ( 'b' , nil )
568
+ end
569
+
562
570
def test_find_method_named
563
571
assert_equal true , @c1 . find_method_named ( 'm' ) . singleton
564
572
end
You can’t perform that action at this time.
0 commit comments