Class: RBS::Definition::InstanceAncestors
- Inherits:
-
Object
- Object
- RBS::Definition::InstanceAncestors
- Defined in:
- lib/rbs/definition.rb
Instance Attribute Summary collapse
-
#ancestors ⇒ Object
readonly
Returns the value of attribute ancestors.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#type_name ⇒ Object
readonly
Returns the value of attribute type_name.
Instance Method Summary collapse
- #apply(args, env:, location:) ⇒ Object
-
#initialize(type_name:, params:, ancestors:) ⇒ InstanceAncestors
constructor
A new instance of InstanceAncestors.
Constructor Details
#initialize(type_name:, params:, ancestors:) ⇒ InstanceAncestors
Returns a new instance of InstanceAncestors.
234 235 236 237 238 |
# File 'lib/rbs/definition.rb', line 234 def initialize(type_name:, params:, ancestors:) @type_name = type_name @params = params @ancestors = ancestors end |
Instance Attribute Details
#ancestors ⇒ Object (readonly)
Returns the value of attribute ancestors.
232 233 234 |
# File 'lib/rbs/definition.rb', line 232 def ancestors @ancestors end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
231 232 233 |
# File 'lib/rbs/definition.rb', line 231 def params @params end |
#type_name ⇒ Object (readonly)
Returns the value of attribute type_name.
230 231 232 |
# File 'lib/rbs/definition.rb', line 230 def type_name @type_name end |
Instance Method Details
#apply(args, env:, location:) ⇒ Object
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
# File 'lib/rbs/definition.rb', line 240 def apply(args, env:, location:) InvalidTypeApplicationError.check2!(env: env, type_name: type_name, args: args, location: location) subst = Substitution.build(params, args) ancestors.map do |ancestor| case ancestor when Ancestor::Instance if ancestor.args.empty? ancestor else Ancestor::Instance.new( name: ancestor.name, args: ancestor.args.map {|type| type.sub(subst) }, source: ancestor.source ) end when Ancestor::Singleton ancestor end end end |