Module: T::Types::Simple::GenericNamePatch

Included in:
T::Types::Simple
Defined in:
lib/tapioca/sorbet_ext/generic_name_patch.rb

Overview

This module intercepts calls to the name method for simple types, so that it can ask the name to the type if the type is generic, since, by this point, we’ve created a clone of that type with the name method returning the appropriate name for that specific concrete type.

Instance Method Summary collapse

Instance Method Details

#nameObject



51
52
53
54
55
56
57
58
59
60
# File 'lib/tapioca/sorbet_ext/generic_name_patch.rb', line 51

def name
  if T::Generic === @raw_type
    # for types that are generic, use the name
    # returned by the "name" method of this instance
    @name ||= T.unsafe(@raw_type).name.freeze
  else
    # otherwise, fallback to the normal name lookup
    super
  end
end