Skip to content

Commit

Permalink
Remove all code related to non_generic_weak_map Sorbet flag
Browse files Browse the repository at this point in the history
Since sorbet/sorbet#6610 was merged and released as 0.5.10588, we no longer need to check for the existence of non generic `WeakMap` definition in Sorbet. Since we are moving to
>= 0.5.10820, we can remove all code related to `ObjectSpace::WeakMap[T.untyped]`.
  • Loading branch information
paracycle committed Dec 20, 2023
1 parent 794ee7d commit 1e3c9ac
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 53 deletions.
4 changes: 1 addition & 3 deletions lib/tapioca/gem/pipeline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,7 @@ def compile_object(name, value)

klass = class_of(value)

klass_name = if klass == ObjectSpace::WeakMap
sorbet_supports?(:non_generic_weak_map) ? "ObjectSpace::WeakMap" : "ObjectSpace::WeakMap[T.untyped]"
elsif T::Generic === klass
klass_name = if T::Generic === klass
generic_name_of(klass)
else
name_of(klass)
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/___
non_generic_weak_map: ::Gem::Requirement.new(">= 0.5.10587"), # https://github.com/sorbet/sorbet/pull/6610
generic_class: ::Gem::Requirement.new(">= 0.5.10820"), # https://github.com/sorbet/sorbet/pull/6781
}.freeze,
T::Hash[Symbol, ::Gem::Requirement],
Expand Down
45 changes: 0 additions & 45 deletions spec/tapioca/cli/backwards_compatibility_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,51 +27,6 @@ def foo(foo)
@project.destroy!
end

describe "ObjectSpace WeakMap generation" do
before do
foo = mock_gem("foo", "0.0.1") do
write!("lib/foo.rb", <<~RB)
Foo = ObjectSpace::WeakMap.new
RB
end
@project.require_mock_gem(foo)
end

it "is a generic type with Sorbet < 0.5.10587" do
@project.require_real_gem("sorbet-static", "0.5.10585")
@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.let(T.unsafe(nil), ObjectSpace::WeakMap[T.untyped])
RBI
end

it "is a non-generic type with Sorbet >= 0.5.10587" do
@project.require_real_gem("sorbet-static", "0.5.10588")
@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.let(T.unsafe(nil), ObjectSpace::WeakMap)
RBI
end
end

describe "serialization of T::Class and T.anything" do
before do
foo = mock_gem("foo", "0.0.1") do
Expand Down
4 changes: 0 additions & 4 deletions spec/tapioca/gem/pipeline_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2043,11 +2043,7 @@ module Toto; end
RUBY

output = template(<<~RBI)
<% if sorbet_supports?(:non_generic_weak_map) %>
Foo = T.let(T.unsafe(nil), ObjectSpace::WeakMap)
<% else %>
Foo = T.let(T.unsafe(nil), ObjectSpace::WeakMap[T.untyped])
<% end %>
RBI

assert_equal(output, compile)
Expand Down

0 comments on commit 1e3c9ac

Please sign in to comment.