In Files

  • rbs-2.1.0/lib/rbs/definition.rb

Parent

Methods

Class/Module Index [+]

Quicksearch

RBS::Definition::InstanceAncestors

Attributes

ancestors[R]
params[R]
type_name[R]

Public Class Methods

new(type_name:, params:, ancestors:) click to toggle source
 
               # File rbs-2.1.0/lib/rbs/definition.rb, line 222
def initialize(type_name,, params,, ancestors))
  @type_name = type_name
  @params = params
  @ancestors = ancestors
end
            

Public Instance Methods

apply(args, location:) click to toggle source
 
               # File rbs-2.1.0/lib/rbs/definition.rb, line 228
def apply(args, location))
  InvalidTypeApplicationError.check!(
    type_name: type_name,
    args: args,
    params: params,
    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