|
| 1 | +From f360b43dedfb38b386180fe5847a77b90e823faa Mon Sep 17 00:00:00 2001 |
| 2 | +From: Adam Chrapkowski <adam.chrapkowski@sourcegraph.com> |
| 3 | +Date: Mon, 2 Feb 2026 18:03:53 +0100 |
| 4 | +Subject: [PATCH] fix: avoid overlapping definition for T::Enum synthetic |
| 5 | + serialize() method |
| 6 | + |
| 7 | +--- |
| 8 | + rewriter/TEnum.cc | 5 ++++- |
| 9 | + test/scip/testdata/alias.snapshot.rb | 2 +- |
| 10 | + test/scip/testdata/enum.snapshot.rb | 2 +- |
| 11 | + 3 files changed, 6 insertions(+), 3 deletions(-) |
| 12 | + |
| 13 | +diff --git a/rewriter/TEnum.cc b/rewriter/TEnum.cc |
| 14 | +index 8fa0bdd7f..cdc460ae9 100644 |
| 15 | +--- a/rewriter/TEnum.cc |
| 16 | ++++ b/rewriter/TEnum.cc |
| 17 | +@@ -243,7 +243,10 @@ void TEnum::run(core::MutableContext ctx, ast::ClassDef *klass) { |
| 18 | + auto serializeReturnTypeClass = core::cast_type_nonnull<core::ClassType>(serializeReturnType); |
| 19 | + ast::ExpressionPtr return_type_ast = ast::MK::Constant(klass->declLoc, serializeReturnTypeClass.symbol); |
| 20 | + auto sig = ast::MK::Sig0(klass->declLoc, std::move(return_type_ast)); |
| 21 | +- auto method = ast::MK::SyntheticMethod0(klass->loc, klass->declLoc, klass->name.loc(), core::Names::serialize(), |
| 22 | ++ // Use zero-length location for the synthetic serialize() method name to avoid |
| 23 | ++ // overlapping with the class name definition. Overlapping definitions cause |
| 24 | ++ // issues in the Sourcegraph UI where Find References picks up the wrong symbol. |
| 25 | ++ auto method = ast::MK::SyntheticMethod0(klass->loc, klass->declLoc, locZero, core::Names::serialize(), |
| 26 | + ast::MK::RaiseTypedUnimplemented(klass->declLoc)); |
| 27 | + ast::Send::ARGS_store nargs; |
| 28 | + ast::Send::Flags flags; |
| 29 | +diff --git a/test/scip/testdata/alias.snapshot.rb b/test/scip/testdata/alias.snapshot.rb |
| 30 | +index c1640f11f..f88ee7ef7 100644 |
| 31 | +--- a/test/scip/testdata/alias.snapshot.rb |
| 32 | ++++ b/test/scip/testdata/alias.snapshot.rb |
| 33 | +@@ -48,8 +48,8 @@ def myfunction(myparam) |
| 34 | + |
| 35 | + class X < T::Enum |
| 36 | + # ^ definition [..] X# |
| 37 | +-# ^ definition [..] X#serialize(). |
| 38 | + # ^ reference [..] T# |
| 39 | ++# ^^^^ definition [..] X#serialize(). |
| 40 | + # ^^^^ reference [..] Module#public(). |
| 41 | + # ^^^^ reference [..] String# |
| 42 | + # ^^^^ reference [..] T#Enum# |
| 43 | +diff --git a/test/scip/testdata/enum.snapshot.rb b/test/scip/testdata/enum.snapshot.rb |
| 44 | +index 38076423c..a191952b5 100644 |
| 45 | +--- a/test/scip/testdata/enum.snapshot.rb |
| 46 | ++++ b/test/scip/testdata/enum.snapshot.rb |
| 47 | +@@ -2,8 +2,8 @@ |
| 48 | + |
| 49 | + class X < T::Enum |
| 50 | + # ^ definition [..] X# |
| 51 | +-# ^ definition [..] X#serialize(). |
| 52 | + # ^ reference [..] T# |
| 53 | ++# ^^^^ definition [..] X#serialize(). |
| 54 | + # ^^^^ reference [..] Module#public(). |
| 55 | + # ^^^^ reference [..] String# |
| 56 | + # ^^^^ reference [..] T#Enum# |
| 57 | +-- |
| 58 | +2.48.1 |
| 59 | + |
0 commit comments