Skip to content

Commit ac1467b

Browse files
fix: avoid overlapping definition for T::Enum synthetic serialize() method
1 parent db7c6fd commit ac1467b

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

‎rewriter/TEnum.cc‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,10 @@ void TEnum::run(core::MutableContext ctx, ast::ClassDef *klass) {
243243
auto serializeReturnTypeClass = core::cast_type_nonnull<core::ClassType>(serializeReturnType);
244244
ast::ExpressionPtr return_type_ast = ast::MK::Constant(klass->declLoc, serializeReturnTypeClass.symbol);
245245
auto sig = ast::MK::Sig0(klass->declLoc, std::move(return_type_ast));
246-
auto method = ast::MK::SyntheticMethod0(klass->loc, klass->declLoc, klass->name.loc(), core::Names::serialize(),
246+
// Use zero-length location for the synthetic serialize() method name to avoid
247+
// overlapping with the class name definition. Overlapping definitions cause
248+
// issues in the Sourcegraph UI where Find References picks up the wrong symbol.
249+
auto method = ast::MK::SyntheticMethod0(klass->loc, klass->declLoc, locZero, core::Names::serialize(),
247250
ast::MK::RaiseTypedUnimplemented(klass->declLoc));
248251
ast::Send::ARGS_store nargs;
249252
ast::Send::Flags flags;

‎test/scip/testdata/alias.snapshot.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ def myfunction(myparam)
4848

4949
class X < T::Enum
5050
# ^ definition [..] X#
51-
# ^ definition [..] X#serialize().
5251
# ^ reference [..] T#
52+
# ^^^^ definition [..] X#serialize().
5353
# ^^^^ reference [..] Module#public().
5454
# ^^^^ reference [..] String#
5555
# ^^^^ reference [..] T#Enum#

‎test/scip/testdata/enum.snapshot.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
class X < T::Enum
44
# ^ definition [..] X#
5-
# ^ definition [..] X#serialize().
65
# ^ reference [..] T#
6+
# ^^^^ definition [..] X#serialize().
77
# ^^^^ reference [..] Module#public().
88
# ^^^^ reference [..] String#
99
# ^^^^ reference [..] T#Enum#

0 commit comments

Comments
 (0)