Class: Steep::TypeInference::Context::TypeVariableContext
- Defined in:
- lib/steep/type_inference/context.rb
Instance Attribute Summary collapse
-
#table ⇒ Object
readonly
Returns the value of attribute table.
-
#type_params ⇒ Object
readonly
Returns the value of attribute type_params.
Class Method Summary collapse
Instance Method Summary collapse
- #[](name) ⇒ Object
-
#initialize(type_params, parent_context: nil) ⇒ TypeVariableContext
constructor
A new instance of TypeVariableContext.
- #upper_bounds ⇒ Object
Constructor Details
#initialize(type_params, parent_context: nil) ⇒ TypeVariableContext
Returns a new instance of TypeVariableContext.
114 115 116 117 118 119 120 121 122 123 |
# File 'lib/steep/type_inference/context.rb', line 114 def initialize(type_params, parent_context: nil) @type_params = type_params @table = {} table.merge!(parent_context.table) if parent_context type_params.each do |param| table[param.name] = param end end |
Instance Attribute Details
#table ⇒ Object (readonly)
Returns the value of attribute table.
111 112 113 |
# File 'lib/steep/type_inference/context.rb', line 111 def table @table end |
#type_params ⇒ Object (readonly)
Returns the value of attribute type_params.
112 113 114 |
# File 'lib/steep/type_inference/context.rb', line 112 def type_params @type_params end |
Class Method Details
.empty ⇒ Object
137 138 139 |
# File 'lib/steep/type_inference/context.rb', line 137 def self.empty new([]) end |
Instance Method Details
#[](name) ⇒ Object
125 126 127 |
# File 'lib/steep/type_inference/context.rb', line 125 def [](name) table.fetch(name).upper_bound end |
#upper_bounds ⇒ Object
129 130 131 132 133 134 135 |
# File 'lib/steep/type_inference/context.rb', line 129 def upper_bounds @upper_bounds ||= table.each_value.with_object({}) do |type_param, bounds| #$ Hash[Symbol, AST::Types::t] if type_param.upper_bound bounds[type_param.name] = type_param.upper_bound end end end |