Class: TypedRb::Types::TyExistentialType
- Defined in:
- lib/typed/types/ty_existential_type.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#local_typing_context ⇒ Object
Returns the value of attribute local_typing_context.
-
#self_variable ⇒ Object
Returns the value of attribute self_variable.
Attributes inherited from TyObject
#classes, #hierarchy, #modules, #ruby_type, #with_ruby_type
Attributes inherited from Type
Instance Method Summary collapse
- #check_inclusion(self_type) ⇒ Object
-
#initialize(ruby_type, node = nil) ⇒ TyExistentialType
constructor
A new instance of TyExistentialType.
Methods inherited from TyObject
#<=>, #as_object_type, #check_type, #compatible?, #dynamic?, #either?, #find_function_type, #find_function_type_in_hierarchy, #find_var_type, #generic?, #join, #max, #resolve_ruby_method, #singleton?, #to_s, #union
Methods included from Comparable
Methods inherited from Type
#compatible?, #either?, #stack_jump?
Constructor Details
#initialize(ruby_type, node = nil) ⇒ TyExistentialType
Returns a new instance of TyExistentialType.
8 9 10 11 12 13 |
# File 'lib/typed/types/ty_existential_type.rb', line 8 def initialize(ruby_type, node = nil) super(ruby_type, node) @hierarchy = [ruby_type] + Module.ancestors @classes = @hierarchy.select { |klass| klass.instance_of?(Class) } @modules = @hierarchy.select { |klass| klass.instance_of?(Module) } end |
Instance Attribute Details
#local_typing_context ⇒ Object
Returns the value of attribute local_typing_context.
6 7 8 |
# File 'lib/typed/types/ty_existential_type.rb', line 6 def local_typing_context @local_typing_context end |
#self_variable ⇒ Object
Returns the value of attribute self_variable.
6 7 8 |
# File 'lib/typed/types/ty_existential_type.rb', line 6 def self_variable @self_variable end |
Instance Method Details
#check_inclusion(self_type) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/typed/types/ty_existential_type.rb', line 15 def check_inclusion(self_type) cloned_context, _ = local_typing_context.clone(:module_self) Types::TypingContext.with_context(cloned_context) do context_self_type = Types::TypingContext.type_variable_for(ruby_type, :module_self, [ruby_type]) context_self_type.compatible?(self_type, :lt) Types::Polymorphism::Unification.new(Types::TypingContext.all_constraints).run(false) end end |