use Parser::AST::Node, Steep::Interface::MethodType use Steep::Interface::Function::Params, Steep::Interface::Block module Steep module TypeInference # A MethodParams object provides the information of parameters from MethodType and nodes # # It primarly provides a mapping from a local variable (method parameter) to its type. # class MethodParams class BaseParameter attr_reader name: Symbol attr_reader type: AST::Types::t? attr_reader node: Node def initialize: (name: Symbol, type: AST::Types::t?, node: Node) -> void def optional?: () -> bool def value: () -> Node? def var_type: () -> AST::Types::t def untyped?: () -> bool def ==: (untyped other) -> bool alias eql? == def hash: () -> Integer end class PositionalParameter < BaseParameter end class KeywordParameter < BaseParameter end class BaseRestParameter attr_reader name: Symbol attr_reader type: AST::Types::t? attr_reader node: Node def initialize: (name: Symbol, type: AST::Types::t?, node: Node) -> void def ==: (untyped other) -> bool alias eql? == def hash: () -> Integer end class PositionalRestParameter < BaseRestParameter def var_type: () -> AST::Types::Name::Instance end class KeywordRestParameter < BaseRestParameter def var_type: () -> AST::Types::Name::Instance end class BlockParameter attr_reader name: Symbol attr_reader type: Interface::Function? attr_reader node: Node attr_reader self_type: AST::Types::t? def initialize: (name: Symbol, type: Interface::Function?, node: Node, optional: boolish, self_type: AST::Types::t?) -> void @optional: boolish def optional?: () -> bool def var_type: () -> AST::Types::t def ==: (untyped other) -> bool alias eql? == def hash: () -> Integer end type param = PositionalParameter | KeywordParameter | PositionalRestParameter | KeywordRestParameter | BlockParameter # The children of `:args` node attr_reader args: Array[Node] attr_reader method_type: MethodType? # Mapping from the name of parameter to parameter object attr_reader params: Hash[Symbol, param] attr_reader errors: Array[Diagnostic::Ruby::Base] # The type of `...` # # `nil` if the node doesn't have it. # attr_reader forward_arg_type: [Params, Block?]? def initialize: (args: Array[Node], method_type: MethodType?, forward_arg_type: [Params, Block?]?) -> void def []: (Symbol name) -> param def param?: (Symbol) -> bool def size: () -> Integer def each_param: () { (param) -> void } -> void | () -> Enumerator[param, void] def each: () { (Symbol, AST::Types::t) -> void } -> void def update: (?forward_arg_type: [Params, Block?]?) -> MethodParams def self.empty: (node: Node) -> MethodParams def self.build: (node: Node, method_type: MethodType) -> MethodParams end end end