sorbet-runtime 0.5.10549 → 0.5.10559
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/types/private/casts.rb +4 -1
- data/lib/types/utils.rb +33 -21
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ed54606860670af4ed78cb6cbc785cd69b3f34b3e5c7482d227f329e244d31f
|
4
|
+
data.tar.gz: 334215ffa35f17453497a0c46ebd7c8a348231c12047ac3ee61bafb7a7136799
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 204b4c0e754836cbeb7bf879bbe9b6550a6ed510f52a345215c30a566854722e57844922501963af10e080ffd7660bc7978fe861bccb06a77d85b9c5c98d0a17
|
7
|
+
data.tar.gz: 741dbb77016c14e9418e2dba96406d5713d2c762200e31b64a390103a3a56361f69d438fe5959169b9279a058c470df8d2b89b13c20d581160cc981f9865c394
|
data/lib/types/private/casts.rb
CHANGED
@@ -5,7 +5,10 @@ module T::Private
|
|
5
5
|
module Casts
|
6
6
|
def self.cast(value, type, cast_method)
|
7
7
|
begin
|
8
|
-
|
8
|
+
coerced_type = T::Utils::Private.coerce_and_check_module_types(type, value, true)
|
9
|
+
return value unless coerced_type
|
10
|
+
|
11
|
+
error = coerced_type.error_message_for_obj(value)
|
9
12
|
return value unless error
|
10
13
|
|
11
14
|
caller_loc = T.must(caller_locations(2..2)).first
|
data/lib/types/utils.rb
CHANGED
@@ -2,29 +2,41 @@
|
|
2
2
|
# typed: true
|
3
3
|
|
4
4
|
module T::Utils
|
5
|
+
module Private
|
6
|
+
def self.coerce_and_check_module_types(val, check_val, check_module_type)
|
7
|
+
if val.is_a?(T::Types::Base)
|
8
|
+
if val.is_a?(T::Private::Types::TypeAlias)
|
9
|
+
val.aliased_type
|
10
|
+
else
|
11
|
+
val
|
12
|
+
end
|
13
|
+
elsif val.is_a?(Module)
|
14
|
+
if check_module_type && check_val.is_a?(val)
|
15
|
+
nil
|
16
|
+
else
|
17
|
+
T::Types::Simple::Private::Pool.type_for_module(val)
|
18
|
+
end
|
19
|
+
elsif val.is_a?(::Array)
|
20
|
+
T::Types::FixedArray.new(val)
|
21
|
+
elsif val.is_a?(::Hash)
|
22
|
+
T::Types::FixedHash.new(val)
|
23
|
+
elsif val.is_a?(T::Private::Methods::DeclBuilder)
|
24
|
+
T::Private::Methods.finalize_proc(val.decl)
|
25
|
+
elsif val.is_a?(::T::Enum)
|
26
|
+
T::Types::TEnum.new(val)
|
27
|
+
elsif val.is_a?(::String)
|
28
|
+
raise "Invalid String literal for type constraint. Must be an #{T::Types::Base}, a " \
|
29
|
+
"class/module, or an array. Got a String with value `#{val}`."
|
30
|
+
else
|
31
|
+
raise "Invalid value for type constraint. Must be an #{T::Types::Base}, a " \
|
32
|
+
"class/module, or an array. Got a `#{val.class}`."
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
5
37
|
# Used to convert from a type specification to a `T::Types::Base`.
|
6
38
|
def self.coerce(val)
|
7
|
-
|
8
|
-
val.aliased_type
|
9
|
-
elsif val.is_a?(T::Types::Base)
|
10
|
-
val
|
11
|
-
elsif val.is_a?(Module)
|
12
|
-
T::Types::Simple::Private::Pool.type_for_module(val)
|
13
|
-
elsif val.is_a?(::Array)
|
14
|
-
T::Types::FixedArray.new(val)
|
15
|
-
elsif val.is_a?(::Hash)
|
16
|
-
T::Types::FixedHash.new(val)
|
17
|
-
elsif val.is_a?(T::Private::Methods::DeclBuilder)
|
18
|
-
T::Private::Methods.finalize_proc(val.decl)
|
19
|
-
elsif val.is_a?(::T::Enum)
|
20
|
-
T::Types::TEnum.new(val)
|
21
|
-
elsif val.is_a?(::String)
|
22
|
-
raise "Invalid String literal for type constraint. Must be an #{T::Types::Base}, a " \
|
23
|
-
"class/module, or an array. Got a String with value `#{val}`."
|
24
|
-
else
|
25
|
-
raise "Invalid value for type constraint. Must be an #{T::Types::Base}, a " \
|
26
|
-
"class/module, or an array. Got a `#{val.class}`."
|
27
|
-
end
|
39
|
+
Private.coerce_and_check_module_types(val, nil, false)
|
28
40
|
end
|
29
41
|
|
30
42
|
# Dynamically confirm that `value` is recursively a valid value of
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sorbet-runtime
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.10559
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-11-
|
11
|
+
date: 2022-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|