Open
Conversation
st0012
reviewed
May 20, 2025
06d9ce0 to
46c9aa2
Compare
Previously, singleton type arguments could not be supported by RBS. This adds support for them, enabling syntax like `singleton(Array)[String, Integer]`.
46c9aa2 to
91eafe8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ticket: https://github.com/Shopify/team-ruby-dx/issues/1460
Add support for parameterized singleton types
This PR adds support for type parameters on singleton types to match the functionality available in Sorbet's
T.class_of(X)[Y]syntax. With this change, RBS now supports the equivalent syntax:singleton(X)[Y].Changes
Examples
Previously, only this was supported:
Now this is also supported:
Questions
Should the
Applicationmodule be included in theClassSingletonclass, similar to how it's included inClassInstanceandInterface? Currently, I've implemented the necessary methods directly.Are there additional methods such as
map_typeandeach_typethat should be added to theClassSingletonclass?