class TypedRb::Types::TyGenericExistentialType
Attributes
local_typing_context[RW]
self_variable[RW]
Public Class Methods
new(ruby_type, type_vars, node = nil)
click to toggle source
Calls superclass method
TypedRb::Types::TyExistentialType::new
# File lib/typed/types/ty_generic_existential_type.rb, line 14 def initialize(ruby_type, type_vars, node = nil) super(ruby_type, node) @type_vars = type_vars end
Public Instance Methods
check_inclusion(self_type)
click to toggle source
# File lib/typed/types/ty_generic_existential_type.rb, line 19 def check_inclusion(self_type) if self_type.generic? if ancestor_of_super_type?(self_type.super_type, ruby_type) super_type = ancestor_of_super_type?(self_type.super_type, ruby_type) materialize(self_type, super_type.type_vars) else materialize(self_type, self_type.type_vars) end else # not generic extending a generic type raise StandardError, "Extending generic module type #{ruby_type} in #{self_type} without matching super annotation" end end
clean_dynamic_bindings()
click to toggle source
# File lib/typed/types/ty_generic_existential_type.rb, line 48 def clean_dynamic_bindings type_vars.each do |type_var| type_var.clean_dynamic_bindings end local_typing_context.clean_dynamic_bindings end
materialize(self_type, actual_arguments)
click to toggle source
# File lib/typed/types/ty_generic_existential_type.rb, line 33 def materialize(self_type, actual_arguments) TypedRb.log binding, :debug, "Materialising generic existential type '#{self}' with args [#{actual_arguments.map(&:to_s).join(',')}]" compute_minimal_typing_context if @local_typing_context.nil? applied_typing_context, substitutions = @local_typing_context.clone(:module_self) fresh_vars_generic_type = clone_with_substitutions(substitutions) TypingContext.with_context(applied_typing_context) do apply_type_arguments(fresh_vars_generic_type, actual_arguments) context_self_type = Types::TypingContext.type_variable_for(ruby_type, :module_self, [ruby_type]) context_self_type.compatible?(self_type, :lt) end Polymorphism::Unification.new(applied_typing_context.all_constraints).run(false) applied_typing_context.unlink # these constraints have already been satisfied end