module T::Utils
def self.coerce(val)
def self.coerce(val) if val.is_a?(T::Types::Base) val elsif val == ::Array T::Array[T.untyped] elsif val == ::Set T::Set[T.untyped] elsif val == ::Hash T::Hash[T.untyped, T.untyped] elsif val == ::Enumerable T::Enumerable[T.untyped] elsif val == ::Enumerator T::Enumerator[T.untyped] elsif val == ::Range T::Range[T.untyped] elsif val.is_a?(Module) T::Types::Simple.new(val) # rubocop:disable PrisonGuard/UseOpusTypesShortcut elsif val.is_a?(::Array) T::Types::FixedArray.new(val) # rubocop:disable PrisonGuard/UseOpusTypesShortcut elsif val.is_a?(::Hash) T::Types::FixedHash.new(val) # rubocop:disable PrisonGuard/UseOpusTypesShortcut elsif val.is_a?(T::Private::Methods::DeclBuilder) T::Private::Methods.finalize_proc(val.decl) else raise "Invalid value for type constraint. Must be an #{T::Types::Base}, a " \ "class/module, or an array. Got a `#{val.class}`." end end