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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df6bf8fcb2561e2428429b30dc9059636064a8a735e253fe40f42345c634dc9a
4
- data.tar.gz: 156e30c64f4ef4dad43b989ee8a462d458b8c282956de77a9f1f9e21ee2b08d8
3
+ metadata.gz: bf43d3cf4e297c8c2c814618b558777e99dad15ee9fdedaf1275adac6303b1ab
4
+ data.tar.gz: 9b454b18a90066a60aef190a683699dae158bf6e0d42be29b4314e3e5a28a072
5
5
  SHA512:
6
- metadata.gz: 85b4031fe378bad5cb9982bf02b9b4f52f888a02f3d5ef3442ef27c0343da8c9415bf443b798933807b59fb74519f8706965ac0a06a72f883ae15d6b29a5cdab
7
- data.tar.gz: de199554534b1c28bbcfd69c7718bbd1b128190e7d91102eb93d24c257b4df186be56c7c617ad1fb08491ff18efa35dfc0494197a903367a14eff2bdb34e0a30
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
- can_skip_block_type = method_sig.block_type.nil? || method_sig.block_type.valid?(nil)
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
- simple_method = all_args_are_simple && method_sig.effective_return_type.is_a?(T::Types::Simple)
82
- simple_procedure = all_args_are_simple && method_sig.effective_return_type.is_a?(T::Private::Types::Void)
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
- method_sig.effective_return_type.equal?(T::Types::Untyped::Private::INSTANCE) ||
87
- method_sig.effective_return_type.equal?(T::Types::Anything::Private::INSTANCE) ||
88
- method_sig.effective_return_type.equal?(T::Types::AttachedClassType::Private::INSTANCE) ||
89
- method_sig.effective_return_type.equal?(T::Types::SelfType::Private::INSTANCE) ||
90
- method_sig.effective_return_type.is_a?(T::Types::TypeParameter) ||
91
- method_sig.effective_return_type.is_a?(T::Types::TypeVariable) ||
92
- (method_sig.effective_return_type.is_a?(T::Types::Simple) && method_sig.effective_return_type.raw_type.equal?(BasicObject))
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 && method_sig.effective_return_type.is_a?(T::Private::Types::Void)
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 = args[-1]
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
- yield @arg_types[it][0], args[it], @arg_types[it][1]
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sorbet-runtime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.13189
4
+ version: 0.6.13192
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe