sorbet-runtime 0.5.6400 → 0.5.6408
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/types/configuration.rb +10 -0
- data/lib/types/private/methods/signature_validation.rb +3 -3
- data/lib/types/types/simple.rb +18 -3
- data/lib/types/types/union.rb +2 -2
- data/lib/types/utils.rb +0 -12
- 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: 83a18a0a29a0fa141646a4abb78bcdf1b07d514eb095f3a59073de297069f73a
|
4
|
+
data.tar.gz: 4e6c98a7720c732e065283217abdd9986b4f4713cfd4b0abe2ad34b8da439128
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee5ea85b50b5cd8540956ef36fa361679dd4a5d957b6f9761e04335eb9ad4a9dbe884452bfe246c3cc2d60c2d08b8541731c6b1b10e5067c5fbad9e5c6f65318
|
7
|
+
data.tar.gz: a251763b257891930ce08ee01e1896a1af33e193bf8e87b91ddc1cef4691fe72de9615030a9723e8343d67c1b8798a0fffc66a9b25cdb3fab47abc30bb3618a9
|
data/lib/types/configuration.rb
CHANGED
@@ -73,6 +73,13 @@ module T::Configuration
|
|
73
73
|
@include_value_in_type_errors = true
|
74
74
|
end
|
75
75
|
|
76
|
+
# Whether VM-defined prop serialization/deserialization routines can be enabled.
|
77
|
+
#
|
78
|
+
# @return [T::Boolean]
|
79
|
+
def self.can_enable_vm_prop_serde?
|
80
|
+
T::Props::Private::DeserializerGenerator.respond_to?(:generate2)
|
81
|
+
end
|
82
|
+
|
76
83
|
# Whether to use VM-defined prop serialization/deserialization routines.
|
77
84
|
#
|
78
85
|
# The default is to use runtime codegen inside sorbet-runtime itself.
|
@@ -86,6 +93,9 @@ module T::Configuration
|
|
86
93
|
#
|
87
94
|
# This method is likely to break things outside of Stripe's systems.
|
88
95
|
def self.enable_vm_prop_serde
|
96
|
+
if !can_enable_vm_prop_serde?
|
97
|
+
hard_assert_handler('Ruby VM is not setup to use VM-defined prop serde')
|
98
|
+
end
|
89
99
|
@use_vm_prop_serde = true
|
90
100
|
end
|
91
101
|
|
@@ -181,7 +181,7 @@ module T::Private::Methods::SignatureValidation
|
|
181
181
|
# arg types must be contravariant
|
182
182
|
super_signature.arg_types.zip(signature.arg_types).each_with_index do |((_super_name, super_type), (name, type)), index|
|
183
183
|
if !super_type.subtype_of?(type)
|
184
|
-
raise "Incompatible type for arg ##{index + 1} (`#{name}`) in #{mode_noun} of method " \
|
184
|
+
raise "Incompatible type for arg ##{index + 1} (`#{name}`) in signature for #{mode_noun} of method " \
|
185
185
|
"`#{signature.method_name}`:\n" \
|
186
186
|
"* Base: `#{super_type}` (in #{method_loc_str(super_signature.method)})\n" \
|
187
187
|
"* #{mode_noun.capitalize}: `#{type}` (in #{method_loc_str(signature.method)})\n" \
|
@@ -193,7 +193,7 @@ module T::Private::Methods::SignatureValidation
|
|
193
193
|
super_signature.kwarg_types.each do |name, super_type|
|
194
194
|
type = signature.kwarg_types[name]
|
195
195
|
if !super_type.subtype_of?(type)
|
196
|
-
raise "Incompatible type for arg `#{name}` in #{mode_noun} of method `#{signature.method_name}`:\n" \
|
196
|
+
raise "Incompatible type for arg `#{name}` in signature for #{mode_noun} of method `#{signature.method_name}`:\n" \
|
197
197
|
"* Base: `#{super_type}` (in #{method_loc_str(super_signature.method)})\n" \
|
198
198
|
"* #{mode_noun.capitalize}: `#{type}` (in #{method_loc_str(signature.method)})\n" \
|
199
199
|
"(The types must be contravariant.)"
|
@@ -202,7 +202,7 @@ module T::Private::Methods::SignatureValidation
|
|
202
202
|
|
203
203
|
# return types must be covariant
|
204
204
|
if !signature.return_type.subtype_of?(super_signature.return_type)
|
205
|
-
raise "Incompatible return type in #{mode_noun} of method `#{signature.method_name}`:\n" \
|
205
|
+
raise "Incompatible return type in signature for #{mode_noun} of method `#{signature.method_name}`:\n" \
|
206
206
|
"* Base: `#{super_signature.return_type}` (in #{method_loc_str(super_signature.method)})\n" \
|
207
207
|
"* #{mode_noun.capitalize}: `#{signature.return_type}` (in #{method_loc_str(signature.method)})\n" \
|
208
208
|
"(The types must be covariant.)"
|
data/lib/types/types/simple.rb
CHANGED
@@ -41,11 +41,26 @@ module T::Types
|
|
41
41
|
module Private
|
42
42
|
module Pool
|
43
43
|
def self.type_for_module(mod)
|
44
|
-
cached = mod.instance_variable_get(:@
|
44
|
+
cached = mod.instance_variable_get(:@__as_sorbet_type)
|
45
45
|
return cached if cached
|
46
46
|
|
47
|
-
type =
|
48
|
-
|
47
|
+
type = if mod == ::Array
|
48
|
+
T::Array[T.untyped]
|
49
|
+
elsif mod == ::Set
|
50
|
+
T::Set[T.untyped]
|
51
|
+
elsif mod == ::Hash
|
52
|
+
T::Hash[T.untyped, T.untyped]
|
53
|
+
elsif mod == ::Enumerable
|
54
|
+
T::Enumerable[T.untyped]
|
55
|
+
elsif mod == ::Enumerator
|
56
|
+
T::Enumerator[T.untyped]
|
57
|
+
elsif mod == ::Range
|
58
|
+
T::Range[T.untyped]
|
59
|
+
else
|
60
|
+
Simple.new(mod)
|
61
|
+
end
|
62
|
+
|
63
|
+
mod.instance_variable_set(:@__as_sorbet_type, type) unless mod.frozen?
|
49
64
|
type
|
50
65
|
end
|
51
66
|
end
|
data/lib/types/types/union.rb
CHANGED
@@ -8,12 +8,12 @@ module T::Types
|
|
8
8
|
|
9
9
|
def initialize(types)
|
10
10
|
@types = types.flat_map do |type|
|
11
|
-
type = T::Utils.
|
11
|
+
type = T::Utils.coerce(type)
|
12
12
|
if type.is_a?(Union)
|
13
13
|
# Simplify nested unions (mostly so `name` returns a nicer value)
|
14
14
|
type.types
|
15
15
|
else
|
16
|
-
|
16
|
+
type
|
17
17
|
end
|
18
18
|
end.uniq
|
19
19
|
end
|
data/lib/types/utils.rb
CHANGED
@@ -8,18 +8,6 @@ module T::Utils
|
|
8
8
|
val.aliased_type
|
9
9
|
elsif val.is_a?(T::Types::Base)
|
10
10
|
val
|
11
|
-
elsif val == ::Array
|
12
|
-
T::Array[T.untyped]
|
13
|
-
elsif val == ::Set
|
14
|
-
T::Set[T.untyped]
|
15
|
-
elsif val == ::Hash
|
16
|
-
T::Hash[T.untyped, T.untyped]
|
17
|
-
elsif val == ::Enumerable
|
18
|
-
T::Enumerable[T.untyped]
|
19
|
-
elsif val == ::Enumerator
|
20
|
-
T::Enumerator[T.untyped]
|
21
|
-
elsif val == ::Range
|
22
|
-
T::Range[T.untyped]
|
23
11
|
elsif val.is_a?(Module)
|
24
12
|
T::Types::Simple::Private::Pool.type_for_module(val)
|
25
13
|
elsif val.is_a?(::Array)
|
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.6408
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-05-
|
11
|
+
date: 2021-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|