Skip to content

Singleton visibility - #1080

Merged
nobu merged 2 commits into
ruby:masterfrom
nobu:singleton-visibility
Jan 7, 2024
Merged

nobu merged 2 commits into
ruby:masterfrom
nobu:singleton-visibility

Conversation

@nobu

@nobu nobu commented Jan 7, 2024

Copy link
Copy Markdown
Member

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

This branch was previously deployed

1 inactive deployment
github-pages — baf26363 Deployed Jan 7, 2024 by nobu
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