module T::Generic::TypeStoragePatch
def [](*types)
def [](*types) # `T::Generic#[]` just returns `self`, so let's call and store it. constant = super # `register_type` method builds and returns an instantiated clone of the generic type # so, we just return that from this method as well. Tapioca::Runtime::GenericTypeRegistry.register_type(constant, types) end
def has_attached_class!(variance = :invariant, &bounds_proc)
def has_attached_class!(variance = :invariant, &bounds_proc) Tapioca::Runtime::GenericTypeRegistry.register_type_variable( self, Tapioca::TypeVariableModule.new( T.cast(self, Module), Tapioca::TypeVariableModule::Type::HasAttachedClass, variance, bounds_proc, ), ) end
def type_member(variance = :invariant, &bounds_proc)
def type_member(variance = :invariant, &bounds_proc) # `T::Generic#type_member` just instantiates a `T::Type::TypeMember` instance and returns it. # We use that when registering the type member and then later return it from this method. Tapioca::TypeVariableModule.new( T.cast(self, Module), Tapioca::TypeVariableModule::Type::Member, variance, bounds_proc, ).tap do |type_variable| Tapioca::Runtime::GenericTypeRegistry.register_type_variable(self, type_variable) end end
def type_template(variance = :invariant, &bounds_proc)
def type_template(variance = :invariant, &bounds_proc) # `T::Generic#type_template` just instantiates a `T::Type::TypeTemplate` instance and returns it. # We use that when registering the type template and then later return it from this method. Tapioca::TypeVariableModule.new( T.cast(self, Module), Tapioca::TypeVariableModule::Type::Template, variance, bounds_proc, ).tap do |type_variable| Tapioca::Runtime::GenericTypeRegistry.register_type_variable(self, type_variable) end end