class Tapioca::TypeVariableModule
do that automatically for us and we get the ‘name` method for free from `Module`.
need to do any matching of constants to type variables to bind their names, Ruby will
get bound to the constant names they are assigned to by Ruby. As a result, we don’t
The reason why we want that is because that means those instances will automatically
This is subclassing from ‘Module` so that instances of this type will be modules.
def bounds
def bounds @bounds ||= @bounds_proc.call end
def coerce_to_type_variable
def coerce_to_type_variable TypeVariable.new(name, @variance) end
def fixed?
def fixed? bounds.key?(:fixed) end
def initialize(context, type, variance, bounds_proc)
def initialize(context, type, variance, bounds_proc) @context = context @type = type @variance = variance @bounds_proc = bounds_proc || DEFAULT_BOUNDS_PROC super() end
def name
def name constant_name = super constant_name&.split("::")&.last end
def serialize
def serialize fixed = bounds[:fixed].to_s if fixed? lower = bounds[:lower].to_s if bounds.key?(:lower) upper = bounds[:upper].to_s if bounds.key?(:upper) RBIHelper.serialize_type_variable( @type.serialize, @variance, fixed, upper, lower, ) end