Skip to content

Commit

Permalink
Remove all code related to generic_class Sorbet flag
Browse files Browse the repository at this point in the history
Since sorbet/sorbet#6781 was merged and released as 0.5.10820, we no longer need to check for the existence of generic class support in Sorbet. Since we are moving to >= 0.5.10820, we can remove all code related to the `generic_class` flag.
  • Loading branch information
paracycle committed Dec 20, 2023
1 parent 1e3c9ac commit 1b7afe2
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 71 deletions.
3 changes: 1 addition & 2 deletions lib/tapioca/dsl/compilers/active_record_delegated_types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,10 @@ def populate_role_accessors(mod, role, types)
return_type: "ActiveSupport::StringInquirer",
)

return_type = sorbet_supports?(:generic_class) ? "T::Class[T.anything]" : "Class"
mod.create_method(
"#{role}_class",
parameters: [],
return_type: return_type,
return_type: "T::Class[T.anything]",
)

mod.create_method(
Expand Down
1 change: 0 additions & 1 deletion lib/tapioca/helpers/sorbet_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ module SorbetHelper
FEATURE_REQUIREMENTS = T.let(
{
# feature_name: ::Gem::Requirement.new(">= ___"), # https://github.com/sorbet/sorbet/pull/___
generic_class: ::Gem::Requirement.new(">= 0.5.10820"), # https://github.com/sorbet/sorbet/pull/6781
}.freeze,
T::Hash[Symbol, ::Gem::Requirement],
)
Expand Down
62 changes: 0 additions & 62 deletions spec/tapioca/cli/backwards_compatibility_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,68 +27,6 @@ def foo(foo)
@project.destroy!
end

describe "serialization of T::Class and T.anything" do
before do
foo = mock_gem("foo", "0.0.1") do
write!("lib/foo.rb", <<~RB)
Foo = T.type_alias { T.any(T.anything, T::Class[String]) }
RB
end
@project.require_mock_gem(foo)
end

it "serializes both as untyped with Sorbet < 0.5.10782" do
@project.require_real_gem("sorbet-static", "0.5.10780")
@project.bundle_install!

@project.tapioca("gem foo")

assert_project_file_equal("sorbet/rbi/gems/foo@0.0.1.rbi", <<~RBI)
# typed: true
# DO NOT EDIT MANUALLY
# This is an autogenerated file for types exported from the `foo` gem.
# Please instead update this file by running `bin/tapioca gem foo`.
Foo = T.type_alias { T.untyped }
RBI
end

it "serializes T::Class as untyped with Sorbet >= 0.5.10782 and < 0.5.10820" do
@project.require_real_gem("sorbet-static", "0.5.10800")
@project.bundle_install!

@project.tapioca("gem foo")

assert_project_file_equal("sorbet/rbi/gems/foo@0.0.1.rbi", <<~RBI)
# typed: true
# DO NOT EDIT MANUALLY
# This is an autogenerated file for types exported from the `foo` gem.
# Please instead update this file by running `bin/tapioca gem foo`.
Foo = T.type_alias { T.any(T.anything, T.untyped) }
RBI
end

it "serializes them correctly with Sorbet >= 0.5.10820" do
@project.require_real_gem("sorbet-static", "0.5.10860")
@project.bundle_install!

@project.tapioca("gem foo")

assert_project_file_equal("sorbet/rbi/gems/foo@0.0.1.rbi", <<~RBI)
# typed: true
# DO NOT EDIT MANUALLY
# This is an autogenerated file for types exported from the `foo` gem.
# Please instead update this file by running `bin/tapioca gem foo`.
Foo = T.type_alias { T.any(T.anything, T::Class[::String]) }
RBI
end
end

describe "compilation of constants of generic types" do
before do
@expected_out = <<~OUT
Expand Down
6 changes: 0 additions & 6 deletions spec/tapioca/runtime/generic_type_registry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,13 @@ class GenericTypeRegistrySpec < Minitest::Spec
Tapioca::TypeVariableModule::Type::Member,
:invariant,
nil,
nil,
nil,
nil,
)

fake_type_member2 = Tapioca::TypeVariableModule.new(
not_actually_generic,
Tapioca::TypeVariableModule::Type::Member,
:invariant,
nil,
nil,
nil,
nil,
)

GenericTypeRegistry.register_type_variable(not_actually_generic, fake_type_member1)
Expand Down

0 comments on commit 1b7afe2

Please sign in to comment.