Skip to content

Add rewriter option to erase generics#946

Draft
dejmedus wants to merge 3 commits into
mainfrom
jb-erase-generic-types
Draft

Add rewriter option to erase generics#946
dejmedus wants to merge 3 commits into
mainfrom
jb-erase-generic-types

Conversation

@dejmedus

@dejmedus dejmedus commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

WIP, RBI changes need to go in first

Sorbet erases generic types at runtime as they cannot be enforced. This means in runtime contexts
we can drop generic types entirely, simplifying the RBS to Sorbet signature translation

This PR adds an erase_generic_types option to the RBSCommentsToSorbetSigs rewriter and --erase-generic-types flag to CLI

@dejmedus dejmedus force-pushed the jb-erase-generic-types branch 2 times, most recently from 507f839 to 31c1d26 Compare June 16, 2026 16:48
dejmedus added 3 commits June 16, 2026 15:25
Sorbet erases generic types at runtime as they cannot
be enforced. This means in runtime contexts
we can drop generic types entirely, simplifying
the rbs to sorbet signature translation

This commit adds an `erase_generic_types` option to
the `RBSCommentsToSorbetSigs` rewriter. When set,
generic args are dropped from translated sigs
(`Box[Integer]` to `Box`) and `extend T::Generic`
is not added
Expose a flag to set the `erase_generic_types` option
in `Spoom::Sorbet::Translate.rbs_comments_to_sorbet_sigs`
so CLI users can drop generic types when translating
from RBS to RBI
When erasing generic types we replace `type_member`s
with a `T.anything` type alias of the same name.
Qualifying `T.type_alias` to `::T.type_alias` ensures
we avoid conflicts like `T = T.type_alias`. This
matches
@dejmedus dejmedus force-pushed the jb-erase-generic-types branch from 31c1d26 to 2146722 Compare June 16, 2026 21:39
@dejmedus dejmedus changed the base branch from main to jb-refactor-type-translator June 16, 2026 21:40
@dejmedus

dejmedus commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

Base automatically changed from jb-refactor-type-translator to main June 16, 2026 21:57
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.

1 participant