sorbet-runtime 0.5.10810 → 0.5.10818
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ddfd9761a4a88233877d8cbfe25d3e5bd257c1e4ea7497c255bec6c7d5897e3a
|
4
|
+
data.tar.gz: 38ed467519b492e37c20b4c8a8c051731deec8b2fc561508fbe1506a8c4aae15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9eeaf99c28f740abab40b839a0c70185891e2c0565d095b762664000ad0ed34effab6ce909c5b7e9c87ac37e7b8f7acb72c3ec62f4e79ef619981b0cfd581cfd
|
7
|
+
data.tar.gz: f2f55b4b4c85c23e31914c5b73692adebf64330ae8c0ca4ce3cab2190cea328f0cece749884e2a5a6aba8d7dd92636a8bf2e9fec6f7ab8cd7005330cd8ab7839
|
@@ -231,15 +231,17 @@ module T::Private::Methods
|
|
231
231
|
decl.on_failure = nil
|
232
232
|
end
|
233
233
|
if decl.params.equal?(ARG_NOT_PROVIDED)
|
234
|
-
decl.params =
|
234
|
+
decl.params = FROZEN_HASH
|
235
235
|
end
|
236
236
|
if decl.type_parameters.equal?(ARG_NOT_PROVIDED)
|
237
|
-
decl.type_parameters =
|
237
|
+
decl.type_parameters = FROZEN_HASH
|
238
238
|
end
|
239
239
|
|
240
240
|
decl.finalized = true
|
241
241
|
|
242
242
|
self
|
243
243
|
end
|
244
|
+
|
245
|
+
FROZEN_HASH = {}.freeze
|
244
246
|
end
|
245
247
|
end
|
@@ -8,17 +8,20 @@ class T::Private::Methods::Signature
|
|
8
8
|
:check_level, :parameters, :on_failure, :override_allow_incompatible,
|
9
9
|
:defined_raw
|
10
10
|
|
11
|
+
UNNAMED_REQUIRED_PARAMETERS = [[:req]].freeze
|
12
|
+
|
11
13
|
def self.new_untyped(method:, mode: T::Private::Methods::Modes.untyped, parameters: method.parameters)
|
12
|
-
# Using `
|
13
|
-
not_typed = T::Private::Types::NotTyped
|
14
|
+
# Using `NotTyped` ensures we'll get an error if we ever try validation on these.
|
15
|
+
not_typed = T::Private::Types::NotTyped::INSTANCE
|
14
16
|
raw_return_type = not_typed
|
15
17
|
# Map missing parameter names to "argN" positionally
|
16
18
|
parameters = parameters.each_with_index.map do |(param_kind, param_name), index|
|
17
19
|
[param_kind, param_name || "arg#{index}"]
|
18
20
|
end
|
19
|
-
raw_arg_types =
|
20
|
-
|
21
|
-
|
21
|
+
raw_arg_types = {}
|
22
|
+
parameters.each do |_, param_name|
|
23
|
+
raw_arg_types[param_name] = not_typed
|
24
|
+
end
|
22
25
|
|
23
26
|
self.new(
|
24
27
|
method: method,
|
@@ -57,28 +60,34 @@ class T::Private::Methods::Signature
|
|
57
60
|
@override_allow_incompatible = override_allow_incompatible
|
58
61
|
@defined_raw = defined_raw
|
59
62
|
|
60
|
-
declared_param_names = raw_arg_types.keys
|
61
63
|
# If sig params are declared but there is a single parameter with a missing name
|
62
64
|
# **and** the method ends with a "=", assume it is a writer method generated
|
63
65
|
# by attr_writer or attr_accessor
|
64
|
-
writer_method =
|
66
|
+
writer_method = !(raw_arg_types.size == 1 && raw_arg_types.key?(nil)) && parameters == UNNAMED_REQUIRED_PARAMETERS && method_name[-1] == "="
|
65
67
|
# For writer methods, map the single parameter to the method name without the "=" at the end
|
66
68
|
parameters = [[:req, method_name[0...-1].to_sym]] if writer_method
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
69
|
+
is_name_missing = parameters.any? {|_, name| !raw_arg_types.key?(name)}
|
70
|
+
if is_name_missing
|
71
|
+
param_names = parameters.map {|_, name| name}
|
72
|
+
missing_names = param_names - raw_arg_types.keys
|
71
73
|
raise "The declaration for `#{method.name}` is missing parameter(s): #{missing_names.join(', ')}"
|
72
|
-
|
73
|
-
|
74
|
-
|
74
|
+
elsif parameters.length == raw_arg_types.size
|
75
|
+
else
|
76
|
+
param_names = parameters.map {|_, name| name}
|
77
|
+
has_extra_names = parameters.count {|_, name| raw_arg_types.key?(name)} < raw_arg_types.size
|
78
|
+
if has_extra_names
|
79
|
+
extra_names = raw_arg_types.keys - param_names
|
80
|
+
raise "The declaration for `#{method.name}` has extra parameter(s): #{extra_names.join(', ')}"
|
81
|
+
end
|
75
82
|
end
|
76
83
|
|
77
84
|
if parameters.size != raw_arg_types.size
|
78
85
|
raise "The declaration for `#{method.name}` has arguments with duplicate names"
|
79
86
|
end
|
87
|
+
i = 0
|
88
|
+
raw_arg_types.each do |type_name, raw_type|
|
89
|
+
param_kind, param_name = parameters[i]
|
80
90
|
|
81
|
-
parameters.zip(raw_arg_types) do |(param_kind, param_name), (type_name, raw_type)|
|
82
91
|
if type_name != param_name
|
83
92
|
hint = ""
|
84
93
|
# Ruby reorders params so that required keyword arguments
|
@@ -92,8 +101,8 @@ class T::Private::Methods::Signature
|
|
92
101
|
end
|
93
102
|
|
94
103
|
raise "Parameter `#{type_name}` is declared out of order (declared as arg number " \
|
95
|
-
"#{
|
96
|
-
"#{
|
104
|
+
"#{i + 1}, defined in the method as arg number " \
|
105
|
+
"#{parameters.index {|_, name| name == type_name} + 1}).#{hint}\nMethod: #{method_desc}"
|
97
106
|
end
|
98
107
|
|
99
108
|
type = T::Utils.coerce(raw_type)
|
@@ -134,6 +143,8 @@ class T::Private::Methods::Signature
|
|
134
143
|
else
|
135
144
|
raise "Unexpected param_kind: `#{param_kind}`. Method: #{method_desc}"
|
136
145
|
end
|
146
|
+
|
147
|
+
i += 1
|
137
148
|
end
|
138
149
|
end
|
139
150
|
|
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.10818
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|