class RBS::InvalidTypeApplicationError - rbs: Ruby Standard Library Documentation

# class RBS::InvalidTypeApplicationError

### Attributes

args[R]
location[R]
params[R]
type_name[R]
type_params[R]

### Public Class Methods

check!(type_name:, args:, params:, location:) click to toggle source

    # File rbs-3.8.0/lib/rbs/errors.rb, line 83
    def self.check!(type_name:, args:, params:, location:)
      min_arity = params.count { _1.default_type.nil? }
      max_arity = params.size

      unless min_arity <= args.size && args.size <= max_arity
        raise new(type_name: type_name, args: args, params: params, location: location)
      end
    end

check2!(env:, type_name:, args:, location:) click to toggle source

    # File rbs-3.8.0/lib/rbs/errors.rb, line 92
    def self.check2!(env:, type_name:, args:, location:)
      params =
        case
        when type_name.class?
          decl = env.normalized_module_class_entry(type_name) or raise
          decl.type_params
        when type_name.interface?
          env.interface_decls.fetch(type_name).decl.type_params
        when type_name.alias?
          env.type_alias_decls.fetch(type_name).decl.type_params
        else
          raise
        end

      check!(type_name: type_name, args: args, params: params, location: location)
    end

new(type_name:, args:, params:, location:) click to toggle source
Calls superclass method

    # File rbs-3.8.0/lib/rbs/errors.rb, line 74
    def initialize(type_name:, args:, params:, location:)
      @type_name = type_name
      @args = args
      @type_params = params
      @params = params.map(&:name)
      @location = location
      super "#{Location.to_string location}: #{type_name} expects parameters [#{params.join(", ")}], but given args [#{args.join(", ")}]"
    end