Project

General

Profile

Actions

Bug #18600

closed

Aliased method visibility issue on Ruby 3.1

Added by gmcgibbon (Gannon McGibbon) about 2 years ago. Updated almost 2 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:107722]

Description

It seems methods on classes that were originally private in the parent and made public in the child can no longer be aliased correctly:

class C
  public :system
  alias_method :bar, :system
  alias_method :system, :bar
end

p RUBY_VERSION
p [C.new.respond_to?(:system), C.new.respond_to?(:system, true)]

On Ruby <= 3.0.3, this returns [true, true], but on Ruby >= 3.1.0 this returns [false, true]. The aliased method seems to revert visibility to the parent.

Actions #2

Updated by byroot (Jean Boussier) about 2 years ago

  • Backport changed from 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN to 2.6: DONTNEED, 2.7: DONTNEED, 3.0: DONTNEED, 3.1: UNKNOWN

Updated by jeremyevans0 (Jeremy Evans) about 2 years ago

Thanks for the report. I bisected this to 71c746379d5872e250d90ae45c585760afaf9516 (which looks like it matches the 4149 PR). That commit was done for performance, so we probably don't want to just revert it. It probably needs a tweak to make sure the visibility is set correctly in this corner case.

Actions #4

Updated by jeremyevans0 (Jeremy Evans) about 2 years ago

  • Backport changed from 2.6: DONTNEED, 2.7: DONTNEED, 3.0: DONTNEED, 3.1: UNKNOWN to 2.6: DONTNEED, 2.7: DONTNEED, 3.0: DONTNEED, 3.1: REQUIRED

Updated by jeremyevans0 (Jeremy Evans) about 2 years ago

I've submitted a pull request to fix this: https://github.com/ruby/ruby/pull/5592

Actions #6

Updated by jeremyevans (Jeremy Evans) about 2 years ago

  • Status changed from Open to Closed

Applied in changeset git|0c6e24d102e894a7211a596e6aa95828b1cf4406.


Fix visibility of alias of zsuper methods

This was broken by 71c746379d5872e250d90ae45c585760afaf9516.

Fixes [Bug #18600]

Updated by nagachika (Tomoyuki Chikanaga) almost 2 years ago

  • Backport changed from 2.6: DONTNEED, 2.7: DONTNEED, 3.0: DONTNEED, 3.1: REQUIRED to 2.6: DONTNEED, 2.7: DONTNEED, 3.0: DONTNEED, 3.1: DONE

ruby_3_1 9d11ddcf6ace6676cea7cac836b4302240e3efb4 merged revision(s) 0c6e24d102e894a7211a596e6aa95828b1cf4406.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0