Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RBI -> RBS translation for generics #430

Merged
merged 2 commits into from
Mar 10, 2025
Merged

Fix RBI -> RBS translation for generics #430

merged 2 commits into from
Mar 10, 2025

Conversation

Morriar
Copy link
Collaborator

@Morriar Morriar commented Mar 6, 2025

Two fixes in there:

  1. Properly translate generic classes so RBS Foo[A, B] is not just translated as Foo
  2. Translate generic Array to T::Array and friends

Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
@Morriar Morriar added the bugfix Fix a bug label Mar 6, 2025
@Morriar Morriar self-assigned this Mar 6, 2025
@Morriar Morriar requested a review from a team as a code owner March 6, 2025 21:08
Comment on lines 155 to 176
case type_name
when "Array"
"T::Array"
when "Class"
"T::Class"
when "Enumerable"
"T::Enumerable"
when "Enumerator"
"T::Enumerator"
when "Hash"
"T::Hash"
when "Set"
"T::Set"
when "Range"
"T::Range"
else
type_name
end
Copy link
Member

Choose a reason for hiding this comment

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

I think we are missing T::Enumerator::Chain and T::Enumerator::Lazy here: https://github.com/sorbet/sorbet/blob/master/rbi/sorbet/t.rbi#L323-L376

Copy link
Member

Choose a reason for hiding this comment

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

Also, what if the name was fully qualified, like ::Array[String]?

Copy link
Contributor

@KaanOzkan KaanOzkan left a comment

Choose a reason for hiding this comment

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

Able to generate correct sigs for ruby-lsp with this branch 👍

Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
@Morriar Morriar force-pushed the at-fix-rbs-generic branch from 843e550 to d672b0b Compare March 7, 2025 14:48
@Morriar Morriar requested a review from KaanOzkan March 7, 2025 14:48
@Morriar Morriar merged commit 29f5daa into main Mar 10, 2025
8 checks passed
@Morriar Morriar deleted the at-fix-rbs-generic branch March 10, 2025 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Fix a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants