sorbet-runtime 0.6.12598 → 0.6.12689

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: ebfe10c877dc0338945dbddb20e6f27e2e4570c951fe1a82f170c48e2d04a954
4
- data.tar.gz: 5f73781d8a144940b29b411882aa9aa715b7e8096b649a7aeec5144d9d828199
3
+ metadata.gz: 5cc2152c2f33be6d199662395074532ccdb451a799d8a656da9e8d2be3387b97
4
+ data.tar.gz: 387ceabe4a2b8442dee11067283c01d714233a08d0cf74d59d34dc829e451c26
5
5
  SHA512:
6
- metadata.gz: 0cb2d697f780a36b05d24fecebbd931d03ba0947226f9df95e1ea083c69992fc52d1eb0688ad4ee14adadf370e97d3f334ba7c16a77a9aca310de7ff2e2f711a
7
- data.tar.gz: 6876486f827f3e236a8bc7cf3cf323a1a09048ec9cb912d9b57cf30a0ee5b4d21e81915c4a935861fdd6b2982417e3aec23af602051f01181a481fd3ce1fc53b
6
+ metadata.gz: 75917b4cc55be3a4709a87b8fb32e2d27519dddf02f7ae79aa06d4aa5451216b2d42734db26b2e403b875401489960999994cc6b1bd8fea6411c7431b177bfe4
7
+ data.tar.gz: 58d863a3b062fbb27eba9fe2a6c114447fb7e01e36566035a138d851f6758c657c566ef85d312403275abfd7f23390f99915ca87e0438dd6f5f46ad8e841a042
@@ -2,9 +2,6 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module T::Configuration
5
- # Cache this comparisonn to avoid two allocations all over the place.
6
- AT_LEAST_RUBY_2_7 = Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7')
7
-
8
5
  # Announces to Sorbet that we are currently in a test environment, so it
9
6
  # should treat any sigs which are marked `.checked(:tests)` as if they were
10
7
  # just a normal sig.
@@ -448,11 +445,7 @@ module T::Configuration
448
445
  MODULE_NAME = Module.instance_method(:name)
449
446
  private_constant :MODULE_NAME
450
447
 
451
- @default_module_name_mangler = if T::Configuration::AT_LEAST_RUBY_2_7
452
- ->(type) { MODULE_NAME.bind_call(type) }
453
- else
454
- ->(type) { MODULE_NAME.bind(type).call } # rubocop:disable Performance/BindCall
455
- end
448
+ @default_module_name_mangler = ->(type) { MODULE_NAME.bind_call(type) }
456
449
 
457
450
  @module_name_mangler = nil
458
451
 
@@ -104,24 +104,6 @@ module T::Private::Methods
104
104
  T::Types::Proc.new(decl.params, decl.returns)
105
105
  end
106
106
 
107
- # Returns the signature for a method whose definition was preceded by `sig`.
108
- #
109
- # @param method [UnboundMethod]
110
- # @return [T::Private::Methods::Signature]
111
- def self.signature_for_method(method)
112
- signature_for_key(method_to_key(method))
113
- end
114
-
115
- private_class_method def self.signature_for_key(key)
116
- maybe_run_sig_block_for_key(key)
117
-
118
- # If a subclass Sub inherits a method `foo` from Base, then
119
- # Sub.instance_method(:foo) != Base.instance_method(:foo) even though they resolve to the
120
- # same method. Similarly, Foo.method(:bar) != Foo.singleton_class.instance_method(:bar).
121
- # So, we always do the look up by the method on the owner (Base in this example).
122
- @signatures_by_method[key]
123
- end
124
-
125
107
  # Fetch the directory name of the file that defines the `T::Private` constant and
126
108
  # add a trailing slash to allow us to match it as a directory prefix.
127
109
  SORBET_RUNTIME_LIB_PATH = File.dirname(T.const_source_location(:Private).first) + File::SEPARATOR
@@ -275,10 +257,8 @@ module T::Private::Methods
275
257
  # make sure to keep changes in sync.
276
258
  elsif method_sig.check_level == :always || (method_sig.check_level == :tests && T::Private::RuntimeLevels.check_tests?)
277
259
  CallValidation.validate_call(self, original_method, method_sig, args, blk)
278
- elsif T::Configuration::AT_LEAST_RUBY_2_7
279
- original_method.bind_call(self, *args, &blk)
280
260
  else
281
- original_method.bind(self).call(*args, &blk) # rubocop:disable Performance/BindCall
261
+ original_method.bind_call(self, *args, &blk)
282
262
  end
283
263
  end
284
264
  end
@@ -407,6 +387,19 @@ module T::Private::Methods
407
387
  end
408
388
  end
409
389
 
390
+ # Returns the signature for a method whose definition was preceded by `sig`.
391
+ #
392
+ # @param method [UnboundMethod]
393
+ # @return [T::Private::Methods::Signature]
394
+ def self.signature_for_method(method)
395
+ signature_for_key(method_to_key(method))
396
+ end
397
+
398
+ private_class_method def self.signature_for_key(key)
399
+ maybe_run_sig_block_for_key(key)
400
+ @signatures_by_method[key]
401
+ end
402
+
410
403
  def self.unwrap_method(mod, signature, original_method)
411
404
  maybe_wrapped_method = CallValidation.wrap_method_if_needed(mod, signature, original_method)
412
405
  @signatures_by_method[method_to_key(maybe_wrapped_method)] = signature
@@ -433,6 +426,25 @@ module T::Private::Methods
433
426
  run_sig_block_for_key(method_to_key(method))
434
427
  end
435
428
 
429
+ # use this directly if you don't want/need to box up the method into an object to pass to method_to_key.
430
+ private_class_method def self.method_owner_and_name_to_key(owner, name)
431
+ "#{owner.object_id}##{name}"
432
+ end
433
+
434
+ private_class_method def self.method_to_key(method)
435
+ # If a subclass Sub inherits a method `foo` from Base, then
436
+ # Sub.instance_method(:foo) != Base.instance_method(:foo) even though they resolve to the
437
+ # same method. Similarly, Foo.method(:bar) != Foo.singleton_class.instance_method(:bar).
438
+ # So, we always do the look up by the method on the owner (Base in this example).
439
+ method_owner_and_name_to_key(method.owner, method.name)
440
+ end
441
+
442
+ private_class_method def self.key_to_method(key)
443
+ id, name = key.split("#")
444
+ obj = ObjectSpace._id2ref(id.to_i)
445
+ obj.instance_method(name)
446
+ end
447
+
436
448
  private_class_method def self.run_sig_block_for_key(key, force_type_init: false)
437
449
  blk = @sig_wrappers[key]
438
450
  if !blk
@@ -516,27 +528,15 @@ module T::Private::Methods
516
528
  @old_hooks = nil
517
529
  else
518
530
  old_included = T::Private::ClassUtils.replace_method(Module, :included, true) do |arg|
519
- if T::Configuration::AT_LEAST_RUBY_2_7
520
- old_included.bind_call(self, arg)
521
- else
522
- old_included.bind(self).call(arg) # rubocop:disable Performance/BindCall
523
- end
531
+ old_included.bind_call(self, arg)
524
532
  ::T::Private::Methods._hook_impl(arg, false, self)
525
533
  end
526
534
  old_extended = T::Private::ClassUtils.replace_method(Module, :extended, true) do |arg|
527
- if T::Configuration::AT_LEAST_RUBY_2_7
528
- old_extended.bind_call(self, arg)
529
- else
530
- old_extended.bind(self).call(arg) # rubocop:disable Performance/BindCall
531
- end
535
+ old_extended.bind_call(self, arg)
532
536
  ::T::Private::Methods._hook_impl(arg, true, self)
533
537
  end
534
538
  old_inherited = T::Private::ClassUtils.replace_method(Class, :inherited, true) do |arg|
535
- if T::Configuration::AT_LEAST_RUBY_2_7
536
- old_inherited.bind_call(self, arg)
537
- else
538
- old_inherited.bind(self).call(arg) # rubocop:disable Performance/BindCall
539
- end
539
+ old_inherited.bind_call(self, arg)
540
540
  ::T::Private::Methods._hook_impl(arg, false, self)
541
541
  end
542
542
  @old_hooks = [old_included, old_extended, old_inherited]
@@ -604,21 +604,6 @@ module T::Private::Methods
604
604
  mod.method(name)
605
605
  end
606
606
  end
607
-
608
- # use this directly if you don't want/need to box up the method into an object to pass to method_to_key.
609
- private_class_method def self.method_owner_and_name_to_key(owner, name)
610
- "#{owner.object_id}##{name}"
611
- end
612
-
613
- private_class_method def self.method_to_key(method)
614
- method_owner_and_name_to_key(method.owner, method.name)
615
- end
616
-
617
- private_class_method def self.key_to_method(key)
618
- id, name = key.split("#")
619
- obj = ObjectSpace._id2ref(id.to_i)
620
- obj.instance_method(name)
621
- end
622
607
  end
623
608
 
624
609
  # This has to be here, and can't be nested inside `T::Private::Methods`,
@@ -79,13 +79,13 @@ module T::Private::Methods::CallValidation
79
79
 
80
80
  # All the types for which valid? unconditionally returns `true`
81
81
  return_is_ignorable =
82
- (method_sig.return_type.equal?(T::Types::Untyped::Private::INSTANCE) ||
83
- method_sig.return_type.equal?(T::Types::Anything::Private::INSTANCE) ||
84
- method_sig.return_type.equal?(T::Types::AttachedClassType::Private::INSTANCE) ||
85
- method_sig.return_type.equal?(T::Types::SelfType::Private::INSTANCE) ||
86
- method_sig.return_type.is_a?(T::Types::TypeParameter) ||
87
- method_sig.return_type.is_a?(T::Types::TypeVariable) ||
88
- (method_sig.return_type.is_a?(T::Types::Simple) && method_sig.return_type.raw_type.equal?(BasicObject)))
82
+ method_sig.return_type.equal?(T::Types::Untyped::Private::INSTANCE) ||
83
+ method_sig.return_type.equal?(T::Types::Anything::Private::INSTANCE) ||
84
+ method_sig.return_type.equal?(T::Types::AttachedClassType::Private::INSTANCE) ||
85
+ method_sig.return_type.equal?(T::Types::SelfType::Private::INSTANCE) ||
86
+ method_sig.return_type.is_a?(T::Types::TypeParameter) ||
87
+ method_sig.return_type.is_a?(T::Types::TypeVariable) ||
88
+ (method_sig.return_type.is_a?(T::Types::Simple) && method_sig.return_type.raw_type.equal?(BasicObject))
89
89
 
90
90
  returns_anything_method = all_args_are_simple && return_is_ignorable
91
91
 
@@ -176,7 +176,7 @@ module T::Private::Methods::CallValidation
176
176
  # this code is sig validation code.
177
177
  # Please issue `finish` to step out of it
178
178
 
179
- return_value = T::Configuration::AT_LEAST_RUBY_2_7 ? original_method.bind_call(instance, *args, &blk) : original_method.bind(instance).call(*args, &blk)
179
+ return_value = original_method.bind_call(instance, *args, &blk)
180
180
 
181
181
  # The only type that is allowed to change the return value is `.void`.
182
182
  # It ignores what you returned and changes it to be a private singleton.
@@ -279,7 +279,7 @@ module T::Private::Methods::CallValidation
279
279
  # this code is sig validation code.
280
280
  # Please issue `finish` to step out of it
281
281
 
282
- return_value = T::Configuration::AT_LEAST_RUBY_2_7 ? original_method.bind_call(instance, *args, &blk) : original_method.bind(instance).call(*args, &blk)
282
+ return_value = original_method.bind_call(instance, *args, &blk)
283
283
 
284
284
  # The only type that is allowed to change the return value is `.void`.
285
285
  # It ignores what you returned and changes it to be a private singleton.
@@ -332,8 +332,4 @@ module T::Private::Methods::CallValidation
332
332
  end
333
333
  end
334
334
 
335
- if T::Configuration::AT_LEAST_RUBY_2_7
336
- require_relative './call_validation_2_7'
337
- else
338
- require_relative './call_validation_2_6'
339
- end
335
+ require_relative './call_validation_2_7'
@@ -264,9 +264,9 @@ class T::Props::Decorator
264
264
  nil
265
265
  end
266
266
 
267
- SAFE_NAME = T.let(/\A[A-Za-z_][A-Za-z0-9_-]*\z/.freeze, Regexp, checked: false)
267
+ SAFE_NAME = T.let(/\A[A-Za-z_][A-Za-z0-9_-]*\z/, Regexp, checked: false)
268
268
  # Should be exactly the same as `SAFE_NAME`, but with a leading `@`.
269
- SAFE_ACCESSOR_KEY_NAME = T.let(/\A@[A-Za-z_][A-Za-z0-9_-]*\z/.freeze, Regexp, checked: false)
269
+ SAFE_ACCESSOR_KEY_NAME = T.let(/\A@[A-Za-z_][A-Za-z0-9_-]*\z/, Regexp, checked: false)
270
270
 
271
271
  # Used to validate both prop names and serialized forms
272
272
  sig { params(name: T.any(Symbol, String)).void.checked(:never) }
@@ -327,9 +327,9 @@ class T::Props::Decorator
327
327
  sig(:final) { params(name: Symbol).returns(T::Boolean).checked(:never) }
328
328
  private def method_defined_on_ancestor?(name)
329
329
  (@class.method_defined?(name) || @class.private_method_defined?(name)) &&
330
- # Unfortunately, older versions of ruby don't allow the second parameter on
331
- # `private_method_defined?`.
332
- (!@class.method_defined?(name, false) && !@class.private_method_defined?(name, false))
330
+ # Unfortunately, older versions of ruby don't allow the second parameter on
331
+ # `private_method_defined?`.
332
+ !@class.method_defined?(name, false) && !@class.private_method_defined?(name, false)
333
333
  end
334
334
 
335
335
  sig(:final) { params(name: Symbol, rules: Rules).void.checked(:never) }
@@ -22,8 +22,8 @@ module T::Types
22
22
  obj.is_a?(Array)
23
23
  end
24
24
 
25
- def new(*args)
26
- Array.new(*T.unsafe(args))
25
+ def new(...)
26
+ Array.new(...)
27
27
  end
28
28
 
29
29
  module Private
@@ -38,14 +38,12 @@ module T::Types
38
38
  return false unless obj.is_a?(Enumerable)
39
39
  case obj
40
40
  when Array
41
- begin
42
- it = 0
43
- while it < obj.count
44
- return false unless type.recursively_valid?(obj[it])
45
- it += 1
46
- end
47
- true
41
+ it = 0
42
+ while it < obj.count
43
+ return false unless type.recursively_valid?(obj[it])
44
+ it += 1
48
45
  end
46
+ true
49
47
  when Hash
50
48
  type_ = self.type
51
49
  return false unless type_.is_a?(FixedArray)
@@ -168,11 +166,7 @@ module T::Types
168
166
  obj.class
169
167
  else
170
168
  # This is a specialized enumerable type, just return the class.
171
- if T::Configuration::AT_LEAST_RUBY_2_7
172
- Object.instance_method(:class).bind_call(obj)
173
- else
174
- Object.instance_method(:class).bind(obj).call # rubocop:disable Performance/BindCall
175
- end
169
+ Object.instance_method(:class).bind_call(obj)
176
170
  end
177
171
  end
178
172
 
@@ -22,8 +22,8 @@ module T::Types
22
22
  obj.is_a?(Enumerator)
23
23
  end
24
24
 
25
- def new(*args, &blk)
26
- T.unsafe(Enumerator).new(*args, &blk)
25
+ def new(...)
26
+ Enumerator.new(...)
27
27
  end
28
28
 
29
29
  class Untyped < TypedEnumerator
@@ -22,8 +22,8 @@ module T::Types
22
22
  obj.is_a?(Enumerator::Chain)
23
23
  end
24
24
 
25
- def new(*args, &blk)
26
- T.unsafe(Enumerator::Chain).new(*args, &blk)
25
+ def new(...)
26
+ Enumerator::Chain.new(...)
27
27
  end
28
28
 
29
29
  class Untyped < TypedEnumeratorChain
@@ -22,8 +22,8 @@ module T::Types
22
22
  obj.is_a?(Enumerator::Lazy)
23
23
  end
24
24
 
25
- def new(*args, &blk)
26
- T.unsafe(Enumerator::Lazy).new(*args, &blk)
25
+ def new(...)
26
+ Enumerator::Lazy.new(...)
27
27
  end
28
28
 
29
29
  class Untyped < TypedEnumeratorLazy
@@ -41,8 +41,8 @@ module T::Types
41
41
  obj.is_a?(Hash)
42
42
  end
43
43
 
44
- def new(*args, &blk)
45
- Hash.new(*T.unsafe(args), &blk)
44
+ def new(...)
45
+ Hash.new(...)
46
46
  end
47
47
 
48
48
  class Untyped < TypedHash
@@ -22,8 +22,8 @@ module T::Types
22
22
  obj.is_a?(Range)
23
23
  end
24
24
 
25
- def new(*args)
26
- T.unsafe(Range).new(*args)
25
+ def new(...)
26
+ Range.new(...)
27
27
  end
28
28
  end
29
29
  end
@@ -28,11 +28,11 @@ module T::Types
28
28
  obj.is_a?(Set)
29
29
  end
30
30
 
31
- def new(*args)
31
+ def new(...)
32
32
  # Fine for this to blow up, because hopefully if they're trying to make a
33
33
  # Set, they don't mind putting (or already have put) a `require 'set'` in
34
34
  # their program directly.
35
- Set.new(*T.unsafe(args))
35
+ Set.new(...)
36
36
  end
37
37
 
38
38
  class Untyped < TypedSet
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.6.12598
4
+ version: 0.6.12689
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-09-30 00:00:00.000000000 Z
11
+ date: 2025-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 1.57.1
61
+ version: 1.81.6
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: 1.57.1
68
+ version: 1.81.6
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rubocop-performance
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -177,7 +177,6 @@ files:
177
177
  - lib/types/private/final.rb
178
178
  - lib/types/private/methods/_methods.rb
179
179
  - lib/types/private/methods/call_validation.rb
180
- - lib/types/private/methods/call_validation_2_6.rb
181
180
  - lib/types/private/methods/call_validation_2_7.rb
182
181
  - lib/types/private/methods/decl_builder.rb
183
182
  - lib/types/private/methods/modes.rb