Resolve module_function visibility#802
Merged
Merged
Conversation
alexcrocha
force-pushed
the
05-11-resolve_module_function_visibility
branch
from
May 12, 2026 16:53
f1516b0 to
f4f9a77
Compare
alexcrocha
marked this pull request as ready for review
May 12, 2026 16:54
soutaro
reviewed
May 18, 2026
alexcrocha
force-pushed
the
05-11-resolve_module_function_visibility
branch
from
July 10, 2026 21:12
f4f9a77 to
cdc2a76
Compare
vinistock
reviewed
Jul 14, 2026
vinistock
left a comment
Member
There was a problem hiding this comment.
Do we already support module function and the other visibility operations in the RBS indexer?
Contributor
Author
|
I pushed a new commit simplifying the logic, which was a bit complex to grok. There's no more target/declaration owner split, and declaration creation is now next to the method match. There's some duplication now, which is what I was trying to eliminate in the previous version. Let me know if this is more readable. (Clippy complains that the function has too many lines. I'll fix it once we are happy with the shape of implementation) |
vinistock
reviewed
Jul 16, 2026
vinistock
left a comment
Member
There was a problem hiding this comment.
Looks good in general, I'm just wondering if we can unify the method visibility handling into a single loop
`module_function :bar` makes `Foo#bar` private and adds `Foo.bar` as a public singleton method. The indexer emits two `MethodVisibility` defs at the call site so resolution and reverse-lookup invalidation handle each side independently.
alexcrocha
force-pushed
the
05-11-resolve_module_function_visibility
branch
from
July 16, 2026 22:25
71b877e to
320080b
Compare
vinistock
approved these changes
Jul 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Closes #89 and finishes the singleton-method visibility resolution work started in #780/#781/#782. This PR resolves retroactive
module_functionvisibility:Foo#barbecomes private andFoo.baris added as a public singleton method.One definition per side
The indexer emits two
MethodVisibilitydefinitions at themodule_function :barcall site: one forFoo#barand one forFoo::<Foo>#bar. The singleton-side definition uses the existingSINGLETON_METHOD_VISIBILITYflag; both carryVisibility::ModuleFunction.The definitions must remain separate because reverse lookup maps each definition to one declaration. Giving each side its own definition lets invalidation detach the instance and singleton declarations independently when the source method or
module_functioncall is removed. The flag bits are included inMethodVisibilityDefinition::id()so the two definitions at the same source location have distinct IDs.Resolution
The instance-side definition follows the existing method-visibility path. The singleton-side definition looks for the same instance method, then attaches a declaration to the singleton class.
Graph::visibility()exposes these asPrivateandPublic, respectively.The singleton class is created only after the target method is found. For
module_function :missing, the instance side emits the diagnostic while the singleton side stays silent, leaving no emptyFoo::<Foo>namespace behind.The existing inline form (
module_function def bar; end) is unchanged. Regression coverage verifies that its singleton companion can still be changed by a later singleton visibility call.Known difference from Ruby
Rubydex resolves each argument independently. For
module_function :a, :missing, it makesFoo#aprivate, adds the publicFoo.a, and reports:missing. Ruby makesFoo#aprivate before raising, but creates no singleton copies for the call. Resolving independently preserves useful information while code is incomplete in an editor.