Skip to content

Commit

Permalink
Override to_s on generic clones as well
Browse files Browse the repository at this point in the history
  • Loading branch information
paracycle committed Mar 1, 2022
1 parent 44c8664 commit 4e64825
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/tapioca/runtime/generic_type_registry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,10 @@ def create_generic_type(constant, name)
constant.clone
end

# Let's set the `name` method to return the proper generic name
generic_type.define_singleton_method(:name) { name }
# Let's set the `name` and `to_s` methods to return the proper generic name
name_proc = -> { name }
generic_type.define_singleton_method(:name, name_proc)
generic_type.define_singleton_method(:to_s, name_proc)

# We need to define a `<=` method on the cloned constant, so that Sorbet
# can do covariance/contravariance checks on the type variables.
Expand Down

0 comments on commit 4e64825

Please sign in to comment.