Skip to content

Commit

Permalink
Merge pull request #897 from ruby/pz-alias-call-seq
Browse files Browse the repository at this point in the history
Fix call-seq for aliased method with similar names
  • Loading branch information
peterzhu2118 committed Jul 18, 2022
2 parents 92c04ce + 1148988 commit a3523b7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/rdoc/any_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -350,12 +350,12 @@ def deduplicate_call_seq(call_seq)
ignore << is_alias_for.name
ignore.concat is_alias_for.aliases.map(&:name)
end
ignore.map! { |n| n =~ /\A\[/ ? n[0, 1] : n}
ignore.map! { |n| n =~ /\A\[/ ? /\[.*\]/ : n}
ignore.delete(method_name)
ignore = Regexp.union(ignore)

matching = entries.reject do |entry|
entry =~ /^\w*\.?#{ignore}/ or
entry =~ /^\w*\.?#{ignore}[$\(\s]/ or
entry =~ /\s#{ignore}\s/
end

Expand Down
14 changes: 14 additions & 0 deletions test/rdoc/test_rdoc_any_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ def test_call_seq_equals
assert_equal 'foo', m.call_seq
end

def test_call_seq_alias_for
a = RDoc::AnyMethod.new nil, "each"
m = RDoc::AnyMethod.new nil, "each_line"

a.call_seq = <<-CALLSEQ
each(foo)
each_line(foo)
CALLSEQ

m.is_alias_for = a

assert_equal "each_line(foo)", m.call_seq
end

def test_full_name
assert_equal 'C1::m', @c1.method_list.first.full_name
end
Expand Down

0 comments on commit a3523b7

Please sign in to comment.