Skip to content

Conversation

@chrapkowski-sg
Copy link
Contributor

@chrapkowski-sg chrapkowski-sg commented Feb 3, 2026

Removes the synthetic serialize() definition generation.

Motivation

When users click "Find References" on a T::Enum class name in Sourcegraph, the UI sometimes shows references to the serialize() method instead of references to the class itself.

This happens because scip-ruby emits two definitions at the exact same source location:

  1. The class definition (e.g., Foo#)
  2. The synthetic serialize() method (e.g., Foo#serialize().)

When the Sourcegraph frontend queries for the symbol at a position and finds multiple overlapping definitions, it may pick the wrong one, causing Find References to return incorrect results.

Now only definition for the class is provided:

Problem

The synthetic serialize() method definition was emitted at the T::Enum class
declaration location, causing overlapping definitions with the class itself.
This broke Find References in Sourcegraph UI, which would pick up serialize
references instead of class references.

Before

class Foo < T::Enum
#     ^^^ definition [..] Foo#
#     ^^^ definition [..] Foo#serialize().
#           ^ reference [..] T#
#              ^^^^ reference [..] Module#public().
#              ^^^^ reference [..] String#
#              ^^^^ reference [..] T#Enum#

After

class Foo < T::Enum
#     ^^^ definition [..] Foo#
#           ^ reference [..] T#
#              ^^^^ reference [..] T#Enum#

Test plan

See included automated tests.

@chrapkowski-sg
Copy link
Contributor Author

chrapkowski-sg commented Feb 3, 2026

@chrapkowski-sg chrapkowski-sg force-pushed the fix-avoid-overlapping-definition branch from f978d5f to 63c20ad Compare February 3, 2026 18:37
@chrapkowski-sg chrapkowski-sg requested a review from jupblb February 3, 2026 18:46
@chrapkowski-sg chrapkowski-sg changed the base branch from scip-ruby/master to ci-fix February 3, 2026 19:02
@chrapkowski-sg chrapkowski-sg force-pushed the fix-avoid-overlapping-definition branch from 63c20ad to e870522 Compare February 3, 2026 19:02
@chrapkowski-sg chrapkowski-sg marked this pull request as ready for review February 3, 2026 19:02
@chrapkowski-sg chrapkowski-sg force-pushed the fix-avoid-overlapping-definition branch from e870522 to 2391c4c Compare February 3, 2026 19:04
@chrapkowski-sg chrapkowski-sg force-pushed the fix-avoid-overlapping-definition branch from 2391c4c to 15e48fc Compare February 3, 2026 19:14
Base automatically changed from ci-fix to scip-ruby/master February 3, 2026 22:11
chrapkowski-sg and others added 2 commits February 3, 2026 23:52
…ping symbols

## Problem

The synthetic serialize() method definition was emitted at the same location
as the class name, causing two overlapping definitions. This broke Find
References in Sourcegraph UI, which would pick up serialize references
instead of class references.

## Solution

Remove the synthetic serialize() method generation entirely. Since serialize()
is a Sorbet stdlib method (not user-defined), omitting the definition is
acceptable - users can still navigate via the class inheritance chain.

## Before

```ruby
 class Foo < T::Enum
#      ^^^ definition [..] Foo#
#      ^^^ definition [..] Foo#serialize().
#            ^ reference [..] T#
#               ^^^^ reference [..] Module#public().
#               ^^^^ reference [..] String#
#               ^^^^ reference [..] T#Enum#
```

## After

```ruby
 class Foo < T::Enum
#      ^^^ definition [..] Foo#
#            ^ reference [..] T#
#               ^^^^ reference [..] T#Enum#
```

Fixes CU-2372

Amp-Thread-ID: https://ampcode.com/threads/T-019c2423-1e50-751d-9ebb-17cbf138874d
Co-authored-by: Amp <[email protected]>
@chrapkowski-sg chrapkowski-sg force-pushed the fix-avoid-overlapping-definition branch from 15e48fc to d7969ce Compare February 3, 2026 22:52
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.

2 participants