Skip to content

Support module_function in the indexer #2653

@vinistock

Description

@vinistock

When module_function is invoked, the given method becomes available in the singleton class and it is turned into a private method on including namespaces. For example:

module A
  def foo; end
  module_function :foo
end

A.foo # okay!

class Something
  include A
end

Something.new.foo # not okay, instance method foo is private

We need to add processing for module_function here. Essentially, when we find an invocation to module_function, we want to:

  1. Get the method entry that was already inserted in the index. Update the visibility to private
  2. Add a new method entry for the same method, but in this case the owner is the singleton class

Metadata

Metadata

Assignees

Labels

good-first-issueGood for newcomershelp-wantedExtra attention is neededpinnedThis issue or pull request is pinned and won't be marked as stale

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions