Require RBI::Type objects throughout the model - #646
Open
Morriar wants to merge 5 commits into
Open
Conversation
Morriar
force-pushed
the
type-only-model
branch
2 times, most recently
from
August 4, 2026 20:12
270706d to
72dcac3
Compare
KaanOzkan
approved these changes
Aug 5, 2026
| sig { returns(::RBI::Type) } | ||
| def return_type; end | ||
|
|
||
| def return_type=(_arg0); end |
Contributor
There was a problem hiding this comment.
FYI I think this is coming from an attr_accessor above and even though the reader is typed the writer isn't.
Morriar
force-pushed
the
type-only-model
branch
from
August 5, 2026 18:22
72dcac3 to
a7abc71
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.
What
This PR removes the backwards-compatible support for passing type strings to RBI model objects. APIs that previously accepted
RBI::Type | Stringnow accept onlyRBI::Type.It also migrates internal producers and consumers to the new contract:
RBI::Typeobjects usingType.parse_string.T::Structfields are represented asType.TypeAPI.Typeobjects directly.Typeobjects.Why
RBI::Typewas introduced while retaining String support for backwards compatibility. Keeping both representations means every consumer must handle two possible types and allows unparsed type syntax to flow through the model.Using a single representation:
Output changes
Parsing and printing an RBI now uses
Type#to_rbi, which canonicalizes Sorbet helpers with an absolute::Tprefix.For example:
This preserves the existing
Type#to_rbibehavior and prevents a locally definedTconstant from shadowing Sorbet’s top-levelT.Generic names whose qualification is represented directly by the parsed type remain unchanged, such as
T::Array[String].Breaking changes
Callers must replace type strings with
RBI::Typeobjects:The affected APIs include:
RBI::Method#add_sigRBI::Sig#initializeRBI::Sig#return_type=RBI::Sig#add_paramRBI::SigParam#initializeRBI::TStructConst#initializeRBI::TStructProp#initializeRBI::TStructField#type=