class 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-3.2.1/lib/rbs/definition.rb, line 234
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-3.2.1/lib/rbs/definition.rb, line 240
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