Skip to content

Conversation

@nobu
Copy link
Member

@nobu nobu commented Jan 7, 2024

For this code, M.foo and M.bar are parsed as private class methods, while both are defined as public.

module M
  private

  class << self
    def foo
    end
  end

  def self.bar
  end
end

p M.methods(false)

nobu added 2 commits January 7, 2024 19:44
Each singleton method definition of the form `def recv.method` has
visibility separate from the outer scope and is set to `public` by
default.
Even for singleton class definition such as `class << self` that
shares the same container with the outer scope, its visibility is
separated and set to `public` by default.
@nobu nobu merged commit baf2636 into ruby:master Jan 7, 2024
@nobu nobu deleted the singleton-visibility branch January 7, 2024 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant