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.6.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, env:, location:) click to toggle source
# File rbs-3.6.1/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