sorbet-runtime 0.6.13189 → 0.6.13192
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/types/private/methods/call_validation.rb +19 -11
- data/lib/types/private/methods/signature.rb +4 -3
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bf43d3cf4e297c8c2c814618b558777e99dad15ee9fdedaf1275adac6303b1ab
|
|
4
|
+
data.tar.gz: 9b454b18a90066a60aef190a683699dae158bf6e0d42be29b4314e3e5a28a072
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b5e5e921d5a506dabd5fe96e434a73723ec8105ac8f4d554379f2e82f265e965dfbeed04b04b1875f8f35520467bb35d41f8baf8dc6558d07068e1ece3f55af6
|
|
7
|
+
data.tar.gz: 145f14e022976650ccbed8a8abe9398970d687759833650185156e4e4156d91b7fd7b54ade90a86c7be2a916b608880ae739d1d8473e629c29714c1330a33b6b
|
|
@@ -74,22 +74,30 @@ module T::Private::Methods::CallValidation
|
|
|
74
74
|
def self.create_validator_method(mod, original_method, method_sig, original_visibility)
|
|
75
75
|
has_fixed_arity = method_sig.kwarg_types.empty? && method_sig.rest_type.nil? && method_sig.keyrest_type.nil? &&
|
|
76
76
|
original_method.parameters.all? { |(kind, _name)| kind == :req || kind == :block }
|
|
77
|
-
|
|
77
|
+
|
|
78
|
+
# nil implies block_type.nil?
|
|
79
|
+
# true implies !block_type.nil? and block_type.valid?(nil)
|
|
80
|
+
# false implies !block_type.nil? and !block_type.valid?(nil)
|
|
81
|
+
# This formulation avoids a type error without introducing extra method calls or local vars
|
|
82
|
+
can_skip_block_type = method_sig.block_type&.valid?(nil) != false
|
|
83
|
+
|
|
78
84
|
ok_for_fast_path = has_fixed_arity && can_skip_block_type && !method_sig.bind && method_sig.arg_types.length < 5 && is_allowed_to_have_fast_path
|
|
79
85
|
|
|
80
86
|
all_args_are_simple = ok_for_fast_path && method_sig.arg_types.all? { |_name, type| type.is_a?(T::Types::Simple) }
|
|
81
|
-
|
|
82
|
-
|
|
87
|
+
|
|
88
|
+
effective_return_type = method_sig.effective_return_type
|
|
89
|
+
simple_method = all_args_are_simple && effective_return_type.is_a?(T::Types::Simple)
|
|
90
|
+
simple_procedure = all_args_are_simple && effective_return_type.is_a?(T::Private::Types::Void)
|
|
83
91
|
|
|
84
92
|
# All the types for which valid? unconditionally returns `true`
|
|
85
93
|
return_is_ignorable =
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
(
|
|
94
|
+
effective_return_type.equal?(T::Types::Untyped::Private::INSTANCE) ||
|
|
95
|
+
effective_return_type.equal?(T::Types::Anything::Private::INSTANCE) ||
|
|
96
|
+
effective_return_type.equal?(T::Types::AttachedClassType::Private::INSTANCE) ||
|
|
97
|
+
effective_return_type.equal?(T::Types::SelfType::Private::INSTANCE) ||
|
|
98
|
+
effective_return_type.is_a?(T::Types::TypeParameter) ||
|
|
99
|
+
effective_return_type.is_a?(T::Types::TypeVariable) ||
|
|
100
|
+
(effective_return_type.is_a?(T::Types::Simple) && effective_return_type.raw_type.equal?(BasicObject))
|
|
93
101
|
|
|
94
102
|
returns_anything_method = all_args_are_simple && return_is_ignorable
|
|
95
103
|
|
|
@@ -101,7 +109,7 @@ module T::Private::Methods::CallValidation
|
|
|
101
109
|
create_validator_method_skip_return_fast(mod, original_method, method_sig, original_visibility)
|
|
102
110
|
elsif simple_procedure
|
|
103
111
|
create_validator_procedure_fast(mod, original_method, method_sig, original_visibility)
|
|
104
|
-
elsif ok_for_fast_path &&
|
|
112
|
+
elsif ok_for_fast_path && effective_return_type.is_a?(T::Private::Types::Void)
|
|
105
113
|
create_validator_procedure_medium(mod, original_method, method_sig, original_visibility)
|
|
106
114
|
elsif ok_for_fast_path && return_is_ignorable
|
|
107
115
|
create_validator_method_skip_return_medium(mod, original_method, method_sig, original_visibility)
|
|
@@ -187,8 +187,8 @@ class T::Private::Methods::Signature
|
|
|
187
187
|
# causes forwarding **kwargs to do the wrong thing: see https://bugs.ruby-lang.org/issues/10708
|
|
188
188
|
# and https://bugs.ruby-lang.org/issues/11860.
|
|
189
189
|
args_length = args.length
|
|
190
|
-
if (args_length > @req_arg_count) && (!@kwarg_types.empty? || !@keyrest_type.nil?) && args[-1].is_a?(Hash)
|
|
191
|
-
kwargs =
|
|
190
|
+
if (args_length > @req_arg_count) && (!@kwarg_types.empty? || !@keyrest_type.nil?) && (last_arg = args[-1]).is_a?(Hash)
|
|
191
|
+
kwargs = last_arg
|
|
192
192
|
args_length -= 1
|
|
193
193
|
else
|
|
194
194
|
kwargs = EMPTY_HASH
|
|
@@ -208,7 +208,8 @@ class T::Private::Methods::Signature
|
|
|
208
208
|
# Process given pre-rest args. When there are no rest args,
|
|
209
209
|
# this is just the given number of args.
|
|
210
210
|
while it < args_length && it < @arg_types.length
|
|
211
|
-
|
|
211
|
+
arg_type = @arg_types.fetch(it)
|
|
212
|
+
yield arg_type[0], args[it], arg_type[1]
|
|
212
213
|
it += 1
|
|
213
214
|
end
|
|
214
215
|
|