Skip to content

Commit 1148988

Browse files
committed
Fix call-seq for aliased method with similar names
deduplicate_call_seq has a bug that skips call-seq for methods where the alias is a prefix of the method name. For example, if the alias name is "each" and the current method name is "each_line", then deduplicate_call_seq will skip all call-seq for "each_line" since it will believe that it is for the alias.
1 parent 92c04ce commit 1148988

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lib/rdoc/any_method.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,12 +350,12 @@ def deduplicate_call_seq(call_seq)
350350
ignore << is_alias_for.name
351351
ignore.concat is_alias_for.aliases.map(&:name)
352352
end
353-
ignore.map! { |n| n =~ /\A\[/ ? n[0, 1] : n}
353+
ignore.map! { |n| n =~ /\A\[/ ? /\[.*\]/ : n}
354354
ignore.delete(method_name)
355355
ignore = Regexp.union(ignore)
356356

357357
matching = entries.reject do |entry|
358-
entry =~ /^\w*\.?#{ignore}/ or
358+
entry =~ /^\w*\.?#{ignore}[$\(\s]/ or
359359
entry =~ /\s#{ignore}\s/
360360
end
361361

test/rdoc/test_rdoc_any_method.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,20 @@ def test_call_seq_equals
5151
assert_equal 'foo', m.call_seq
5252
end
5353

54+
def test_call_seq_alias_for
55+
a = RDoc::AnyMethod.new nil, "each"
56+
m = RDoc::AnyMethod.new nil, "each_line"
57+
58+
a.call_seq = <<-CALLSEQ
59+
each(foo)
60+
each_line(foo)
61+
CALLSEQ
62+
63+
m.is_alias_for = a
64+
65+
assert_equal "each_line(foo)", m.call_seq
66+
end
67+
5468
def test_full_name
5569
assert_equal 'C1::m', @c1.method_list.first.full_name
5670
end

0 commit comments

Comments
 (0)