use RBS::TypeName, RBS::Resolver::TypeNameResolver module Steep module AST module Types class Factory @env: RBS::Environment attr_reader definition_builder: RBS::DefinitionBuilder attr_reader type_cache: Hash[RBS::Types::t, t] attr_reader type_interface_cache: untyped @type_name_resolver: TypeNameResolver? def inspect: () -> String def initialize: (builder: RBS::DefinitionBuilder) -> void def type_name_resolver: () -> TypeNameResolver def type: (RBS::Types::t `type`) -> t def type_opt: (RBS::Types::t? `type`) -> t? def type_1: (t `type`) -> RBS::Types::t def type_1_opt: (t?) -> RBS::Types::t? def function_1: (Interface::Function func) -> RBS::Types::Function def params: (RBS::Types::Function `type`) -> Interface::Function::Params def type_param: (RBS::AST::TypeParam type_param) -> Interface::TypeParam def type_param_1: (Interface::TypeParam type_param) -> RBS::AST::TypeParam @method_type_cache: Hash[RBS::MethodType, Interface::MethodType] def method_type: (RBS::MethodType method_type, method_decls: Set[TypeInference::MethodCall::MethodDecl]) -> Interface::MethodType def method_type_1: (Interface::MethodType method_type) -> RBS::MethodType def unfold: (TypeName type_name, Array[t] args) -> t # Unfold type alias one step, or returns itself # def expand_alias: (t `type`) -> t # Unfold type alias until non alias type # # * Unions and intersections are expanded # * Returns `nil` if it is recursive # def deep_expand_alias: (t `type`, ?recursive: Set[TypeName]) -> t? # Convert union types to array of types # def flatten_union: (t `type`, ?Array[t] acc) -> Array[t] # Partition the type components in union types to truthy ones and falsy ones # # * Returns a pair of *truthy* type and *falsy* type # * The pair may contain `nil` if given type always evaluates to truthy or falsy # * Expand (unfold) the type aliases automatically # # ```ruby # partition_union?(`Integer?`) # => [`Integer`, `nil`] # partition_union?(`Integer | String | nil | false`) # => [`Integer | String`, `nil | false`] # partition_union?(`bool`) # => [`bool`, `bool`] # partition_union?(`nil`) # => [nil, `nil`] # ``` # def partition_union: (Types::t) -> [Types::t?, Types::t?] # Returns a type that doesn't have `nil` in the union component # # * Returns `nil` if given type is `nil` # * **Doesn't expand type alias automatically** # # ```ruby # unwrap_optional(`String?`) # => `String` # unwrap_optional(`String | Integer | false | nil`) # => `String | Integer | false` # unwrap_optional(`nil`) # => nil # unwrap_optional(`boolish`) # => `boolish` # ``` # def unwrap_optional: (Types::t) -> Types::t? def module_name?: (TypeName type_name) -> bool def class_name?: (TypeName type_name) -> bool def env: () -> RBS::Environment def absolute_type: (t `type`, context: RBS::Resolver::context) -> t def absolute_type_name: (TypeName type_name, context: RBS::Resolver::context) -> TypeName? def instance_type: (TypeName type_name, ?args: Array[t]?, ?location: untyped?) -> t def try_singleton_type: (t) -> t? def try_instance_type: (t) -> t? def normalize_type: (t) -> t end end end end