Skip to content

Commit

Permalink
Remove all code that supports pre-T::Utils::Private module addition
Browse files Browse the repository at this point in the history
Since sorbet/sorbet#6559 was merged and released as 0.5.10554, we no longer need to check if `T::Utils::Private` is defined before using it. Since we are moving to >= 0.5.10820, there is no reason for us to support old behaviour anymore.
  • Loading branch information
paracycle committed Dec 20, 2023
1 parent ef62097 commit 5097d55
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 91 deletions.
28 changes: 4 additions & 24 deletions lib/tapioca/sorbet_ext/generic_name_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,29 +84,9 @@ def name
end

module Utils
# This duplication is required to preserve backwards compatibility with sorbet-runtime versions prior to the
# introduction of the `Private` module in https://github.com/sorbet/sorbet/pull/6559.
if defined?(T::Utils::Private)
module Private
module PrivateCoercePatch
def coerce_and_check_module_types(val, check_val, check_module_type)
if val.is_a?(Tapioca::TypeVariableModule)
val.coerce_to_type_variable
elsif val.respond_to?(:__tapioca_override_type)
val.__tapioca_override_type
else
super
end
end
end

class << self
prepend(PrivateCoercePatch)
end
end
else
module CoercePatch
def coerce(val)
module Private
module PrivateCoercePatch
def coerce_and_check_module_types(val, check_val, check_module_type)
if val.is_a?(Tapioca::TypeVariableModule)
val.coerce_to_type_variable
elsif val.respond_to?(:__tapioca_override_type)
Expand All @@ -118,7 +98,7 @@ def coerce(val)
end

class << self
prepend(CoercePatch)
prepend(PrivateCoercePatch)
end
end
end
Expand Down
68 changes: 1 addition & 67 deletions spec/tapioca/cli/backwards_compatibility_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,6 @@

module Tapioca
class BackwardsCompatibilitySpec < SpecWithProject
GENERIC_TYPE_RB = <<~RB
class GenericType
extend T::Sig
extend T::Generic
Elem = type_member
sig { params(foo: Elem).void }
def foo(foo)
end
end
RB

before do
@project = mock_project(sorbet_dependency: false)
end
Expand All @@ -27,59 +14,6 @@ def foo(foo)
@project.destroy!
end

describe "compilation of constants of generic types" do
before do
@expected_out = <<~OUT
Compiled generic_type
create sorbet/rbi/gems/generic_type@0.0.1.rbi
OUT

@expected_rbi = <<~RBI
# typed: true
# DO NOT EDIT MANUALLY
# This is an autogenerated file for types exported from the `generic_type` gem.
# Please instead update this file by running `bin/tapioca gem generic_type`.
class GenericType
extend T::Generic
Elem = type_member
sig { params(foo: Elem).void }
def foo(foo); end
end
RBI

generic_type = mock_gem("generic_type", "0.0.1") do
write!("lib/generic_type.rb", GENERIC_TYPE_RB)
end
@project.require_mock_gem(generic_type)
end

it "must succeed on sorbet-runtime < 0.5.10554" do
@project.require_real_gem("sorbet-static-and-runtime", "=0.5.10539")
@project.bundle_install!

result = @project.tapioca("gem generic_type", enforce_typechecking: false)

assert_stdout_includes(result, @expected_out)
assert_project_file_equal("sorbet/rbi/gems/generic_type@0.0.1.rbi", @expected_rbi)
assert_empty_stderr(result)
assert_success_status(result)
end

it "must succeed on sorbet-runtime >= 0.5.10554" do
@project.require_real_gem("sorbet-static-and-runtime", ">=0.5.10554")
@project.bundle_install!

result = @project.tapioca("gem generic_type", enforce_typechecking: false)

assert_stdout_includes(result, @expected_out)
assert_project_file_equal("sorbet/rbi/gems/generic_type@0.0.1.rbi", @expected_rbi)
assert_empty_stderr(result)
assert_success_status(result)
end
end
# Add backcompat tests here
end
end

0 comments on commit 5097d55

Please sign in to comment.