Class: RBS::Environment::MultiEntry
- Inherits:
-
Object
- Object
- RBS::Environment::MultiEntry
- Defined in:
- lib/rbs/environment.rb
Direct Known Subclasses
Defined Under Namespace
Classes: D
Instance Attribute Summary collapse
-
#decls ⇒ Object
readonly
Returns the value of attribute decls.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name:) ⇒ MultiEntry
constructor
A new instance of MultiEntry.
- #insert(decl:, outer:) ⇒ Object
- #type_params ⇒ Object
- #validate_type_params ⇒ Object
Constructor Details
#initialize(name:) ⇒ MultiEntry
Returns a new instance of MultiEntry.
30 31 32 33 |
# File 'lib/rbs/environment.rb', line 30 def initialize(name:) @name = name @decls = [] end |
Instance Attribute Details
#decls ⇒ Object (readonly)
Returns the value of attribute decls.
28 29 30 |
# File 'lib/rbs/environment.rb', line 28 def decls @decls end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
27 28 29 |
# File 'lib/rbs/environment.rb', line 27 def name @name end |
Instance Method Details
#insert(decl:, outer:) ⇒ Object
35 36 37 38 |
# File 'lib/rbs/environment.rb', line 35 def insert(decl:, outer:) decls << D.new(decl: decl, outer: outer) @primary = nil end |
#type_params ⇒ Object
56 57 58 |
# File 'lib/rbs/environment.rb', line 56 def type_params primary.decl.type_params end |
#validate_type_params ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/rbs/environment.rb', line 40 def validate_type_params unless decls.empty? hd_decl, *tl_decls = decls hd_params = hd_decl.decl.type_params hd_names = hd_params.params.map(&:name) tl_decls.each do |tl_decl| tl_params = tl_decl.decl.type_params unless hd_params.size == tl_params.size && hd_params == tl_params.rename_to(hd_names) raise GenericParameterMismatchError.new(name: name, decl: tl_decl.decl) end end end end |