Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 6 additions & 17 deletions rewriter/TEnum.cc
Original file line number Diff line number Diff line change
Expand Up @@ -238,22 +238,11 @@ void TEnum::run(core::MutableContext ctx, ast::ClassDef *klass) {
}
}
}
if (core::isa_type<core::ClassType>(serializeReturnType) && !serializeReturnType.isUntyped() &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this is a serious deviation from the upstream:

scip-ruby/rewriter/TEnum.cc

Lines 241 to 257 in 0a7b175

if (core::isa_type<core::ClassType>(serializeReturnType) && !serializeReturnType.isUntyped() &&
!serializeReturnType.isBottom()) {
auto serializeReturnTypeClass = core::cast_type_nonnull<core::ClassType>(serializeReturnType);
ast::ExpressionPtr return_type_ast = ast::MK::Constant(klass->declLoc, serializeReturnTypeClass.symbol);
auto sig = ast::MK::Sig0(klass->declLoc, std::move(return_type_ast));
auto method = ast::MK::SyntheticMethod0(klass->loc, klass->declLoc, core::Names::serialize(),
ast::MK::RaiseTypedUnimplemented(klass->declLoc));
ast::Send::ARGS_store nargs;
ast::Send::Flags flags;
flags.isPrivateOk = true;
auto visibility = ast::MK::Send(klass->declLoc, ast::MK::Self(klass->declLoc), core::Names::public_(),
klass->declLoc, 0, std::move(nargs), flags);
klass->rhs.emplace_back(std::move(visibility));
klass->rhs.emplace_back(std::move(sig));
klass->rhs.emplace_back(std::move(method));
}

This is not bad but something worth noting. I hope this doesn't break anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we need to track this in case of rebases. We have this commit including PR and reasons why this has been removed

!serializeReturnType.isBottom()) {
auto serializeReturnTypeClass = core::cast_type_nonnull<core::ClassType>(serializeReturnType);
ast::ExpressionPtr return_type_ast = ast::MK::Constant(klass->declLoc, serializeReturnTypeClass.symbol);
auto sig = ast::MK::Sig0(klass->declLoc, std::move(return_type_ast));
auto method = ast::MK::SyntheticMethod0(klass->loc, klass->declLoc, klass->name.loc(), core::Names::serialize(),
ast::MK::RaiseTypedUnimplemented(klass->declLoc));
ast::Send::ARGS_store nargs;
ast::Send::Flags flags;
flags.isPrivateOk = true;
auto visibility = ast::MK::Send(klass->declLoc, ast::MK::Self(klass->declLoc), core::Names::public_(),
klass->declLoc, 0, std::move(nargs), flags);

klass->rhs.emplace_back(std::move(visibility));
klass->rhs.emplace_back(std::move(sig));
klass->rhs.emplace_back(std::move(method));
}
// NOTE: We intentionally skip generating the synthetic serialize() method definition here.
// T::Enum provides serialize() but emitting a definition at the class declaration location
// causes overlapping definitions with the class itself, which breaks Find References in
// Sourcegraph UI. Since serialize() is a Sorbet stdlib method (not user-defined), omitting
// the definition is acceptable - users can still navigate via the class inheritance.
(void)serializeReturnType; // Silence unused variable warning
}
}; // namespace sorbet::rewriter
5 changes: 1 addition & 4 deletions test/scip/testdata/alias.snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ def myfunction(myparam)

class X < T::Enum
# ^ definition [..] X#
# ^ definition [..] X#serialize().
# ^ reference [..] T#
# ^^^^ reference [..] Module#public().
# ^^^^ reference [..] String#
# ^^^^ reference [..] T#Enum#
enums do
A = new("A")
Expand All @@ -70,7 +67,7 @@ class X < T::Enum
# ^^^ definition [..] X#All.
# ^ reference [..] X#A.
# ^ reference [..] X#B.
# ^^^^^^^^ definition local 4$119448696
# ^^^^^^^^ definition local 3$119448696
# ^ reference [..] X#
end

Expand Down
5 changes: 1 addition & 4 deletions test/scip/testdata/enum.snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

class X < T::Enum
# ^ definition [..] X#
# ^ definition [..] X#serialize().
# ^ reference [..] T#
# ^^^^ reference [..] Module#public().
# ^^^^ reference [..] String#
# ^^^^ reference [..] T#Enum#
enums do
A = new("A")
Expand All @@ -24,7 +21,7 @@ class X < T::Enum
# ^^^ definition [..] X#All.
# ^ reference [..] X#A.
# ^ reference [..] X#B.
# ^^^^^^^^ definition local 4$119448696
# ^^^^^^^^ definition local 3$119448696
# ^ reference [..] X#
end

Expand Down
Loading