Skip to content

Expose method reference receivers#754

Open
vinistock wants to merge 1 commit intomainfrom
04-17-expose_method_reference_receivers
Open

Expose method reference receivers#754
vinistock wants to merge 1 commit intomainfrom
04-17-expose_method_reference_receivers

Conversation

@vinistock
Copy link
Copy Markdown
Member

@vinistock vinistock commented Apr 17, 2026

This PR exposes the resolved declaration for method receivers. When there's no receiver or it's unresolved, we return nil. This helps us provide more accurate find references in the Ruby LSP.

Note: exposing the receiver as Declaration? is probably not 100% correct, but since we cannot know the type of method receivers until there's type inference, it's a decent mid-point.

I also prototyped changing the receiver to be a constant reference ID (instead of a name ID), but it leads to a lot of other issues. For example:

class Foo
  def bar
    # In this method reference, the receiver is Foo. However, is the `self` considered
    # a constant reference to Foo? Not really...
    #
    # It would be pretty surprising to have this should up in find references and
    # much worse in a rename request.
    self.baz
  end
end

Maybe, in the future, the self would be something like a TypeRef? Anyway, it's clearly too early to model this so I went with a compromise.

Copy link
Copy Markdown
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@vinistock vinistock self-assigned this Apr 17, 2026
@vinistock vinistock added the enhancement New feature or request label Apr 17, 2026
@vinistock vinistock marked this pull request as ready for review April 17, 2026 16:10
@vinistock vinistock requested a review from a team as a code owner April 17, 2026 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant