Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Singleton visibility #1080

Merged
merged 2 commits into from
Jan 7, 2024
Merged

Singleton visibility #1080

merged 2 commits into from
Jan 7, 2024

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)

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
24 checks passed
@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
Development

Successfully merging this pull request may close these issues.

1 participant