sorbet-runtime 0.6.13196 → 0.6.13201

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: 5b6b772ecaa9f6ce7788173f15073e96d619a88d575c72c36701e0f33b2f7796
4
- data.tar.gz: e986c62848ac7bef03f533753b233d151167c285dc1011023dfff4378c74ae0c
3
+ metadata.gz: 79fd6653c60d5ef471285c20e256f0c648b7c4eecabdb6fd984a001e3a65777d
4
+ data.tar.gz: ad5746e9bb9b4ac3e308b14eebb2a087ca380172fa5d7155e364b6d225348d00
5
5
  SHA512:
6
- metadata.gz: 15840ef1936591b0b06fc987a1d53952e2ff5f3c0f83e3f8ed39da9a9a510c838b6aa9f451919262e39923f7f7af071b76e1b2b1323316038f2f8f84bfdb7be4
7
- data.tar.gz: a9dcc51625a817d74cdc6be20cd7a66d6288df0b3d0628a66296c786859901c1f159cf9b33062c0a16cf653de2728e80d944b1438acbea7076c0cab9804e1079
6
+ metadata.gz: b41d0550e429ed6b54de6a67639134015e1fdfb1e313a9138a031a5783542e0884d92a2493ad19fbeafb61fb2a8961ea1561f9340c47d2d1febcdccd076867db
7
+ data.tar.gz: ff0278c3333264eec7ad1468fa0459cde87037946137d0b649a5686c0ec3fb3163c2eb51e5237c32047590a3140d89d990aabb08faa9c7ba7750cc02bfa329bc
@@ -56,11 +56,6 @@ module T::Private::Methods
56
56
  nil
57
57
  end
58
58
 
59
- # See tests for how to use this. But you shouldn't be using this.
60
- def self._declare_sig(mod, arg=nil, &blk)
61
- _declare_sig_internal(mod, caller_locations(1, 1)&.first, arg, raw: true, &blk)
62
- end
63
-
64
59
  private_class_method def self._declare_sig_internal(mod, loc, arg, raw: false, &blk)
65
60
  install_hooks(mod)
66
61
 
@@ -76,21 +71,6 @@ module T::Private::Methods
76
71
  DeclarationBlock.new(mod, loc, blk, arg == :final, raw)
77
72
  end
78
73
 
79
- def self._with_declared_signature(mod, declblock, &blk)
80
- # If declblock is provided, this code is equivalent to the check in
81
- # _declare_sig_internal, above.
82
- # If declblock is not provided and we have an active declaration, we are
83
- # obviously doing something wrong.
84
- if T::Private::DeclState.current.active_declaration
85
- T::Private::DeclState.current.reset!
86
- raise "You called sig twice without declaring a method in between"
87
- end
88
- if declblock
89
- T::Private::DeclState.current.active_declaration = declblock
90
- end
91
- mod.module_exec(&blk)
92
- end
93
-
94
74
  def self.start_proc
95
75
  DeclBuilder.new(PROC_TYPE, false)
96
76
  end
@@ -131,14 +111,14 @@ module T::Private::Methods
131
111
  #
132
112
  # we assume that source_method_names has already been filtered to only include method
133
113
  # names that were declared final at one point.
134
- def self._check_final_ancestors(target, target_ancestors, source_method_names, source)
114
+ def self._check_final_ancestors(target, source_method_names, source)
135
115
  source_ancestors = nil
136
116
  if T::Private::IS_TYPECHECKING
137
117
  # Need to avoid a pinning error, but don't want to use runtime types in _methods.rb
138
118
  source_ancestors = T.let(nil, T.nilable(T::Array[T::Module[T.anything]]))
139
119
  end
140
120
  # use reverse_each to check farther-up ancestors first, for better error messages.
141
- target_ancestors.reverse_each do |ancestor|
121
+ target.ancestors.reverse_each do |ancestor|
142
122
  final_methods = @modules_with_final.fetch(ancestor, nil)
143
123
  # In this case, either ancestor didn't have any final methods anywhere in its
144
124
  # ancestor chain, or ancestor did have final methods somewhere in its ancestor
@@ -200,6 +180,9 @@ module T::Private::Methods
200
180
  end
201
181
 
202
182
  def self.add_module_with_final_method(mod, method_name)
183
+ @was_ever_final_names[method_name] = true
184
+
185
+ # Side-effectfully initializes the value if it's not already there
203
186
  methods = @modules_with_final[mod]
204
187
  if methods.nil?
205
188
  methods = {}
@@ -209,12 +192,6 @@ module T::Private::Methods
209
192
  nil
210
193
  end
211
194
 
212
- def self.note_module_deals_with_final(mod)
213
- # Side-effectfully initialize the value if it's not already there
214
- @modules_with_final[mod]
215
- @modules_with_final[mod.singleton_class]
216
- end
217
-
218
195
  # Only public because it needs to get called below inside the replace_method blocks below.
219
196
  def self._on_method_added(hook_mod, mod, method_name)
220
197
  if T::Private::DeclState.current.skip_on_method_added
@@ -228,7 +205,7 @@ module T::Private::Methods
228
205
  end
229
206
  # Don't compute mod.ancestors if we don't need to bother checking final-ness.
230
207
  if @was_ever_final_names.include?(method_name) && @modules_with_final.include?(mod)
231
- _check_final_ancestors(mod, mod.ancestors, [method_name], nil)
208
+ _check_final_ancestors(mod, [method_name], nil)
232
209
  # We need to fetch the active declaration again, as _check_final_ancestors
233
210
  # may have reset it (see the comment in that method for details).
234
211
  current_declaration = T::Private::DeclState.current.active_declaration
@@ -286,10 +263,6 @@ module T::Private::Methods
286
263
 
287
264
  @sig_wrappers[key] = sig_block
288
265
  if current_declaration.final
289
- @was_ever_final_names[method_name] = true
290
- # use hook_mod, not mod, because for example, we want class C to be marked as having final if we def C.foo as
291
- # final. change this to mod to see some final_method tests fail.
292
- note_module_deals_with_final(hook_mod)
293
266
  add_module_with_final_method(mod, method_name)
294
267
  end
295
268
  end
@@ -518,14 +491,15 @@ module T::Private::Methods
518
491
 
519
492
  # the module target is adding the methods from the module source to itself. we need to check that for all instance
520
493
  # methods M on source, M is not defined on any of target's ancestors.
521
- def self._hook_impl(target, singleton_class, source)
494
+ def self._hook_impl(target, source)
522
495
  # we do not need to call add_was_ever_final here, because we have already marked
523
496
  # any such methods when source was originally defined.
524
497
  if !@modules_with_final.include?(target)
525
498
  if !@modules_with_final.include?(source)
526
499
  return
527
500
  end
528
- note_module_deals_with_final(target)
501
+ # Side-effectfully initialize the value if it's not already there
502
+ @modules_with_final[target]
529
503
  install_hooks(target)
530
504
  return
531
505
  end
@@ -538,8 +512,7 @@ module T::Private::Methods
538
512
  return
539
513
  end
540
514
 
541
- target_ancestors = singleton_class ? target.singleton_class.ancestors : target.ancestors
542
- _check_final_ancestors(target, target_ancestors, methods, source)
515
+ _check_final_ancestors(target, methods, source)
543
516
  end
544
517
 
545
518
  def self.set_final_checks_on_hooks(enable)
@@ -563,17 +536,18 @@ module T::Private::Methods
563
536
  old_included = Module.instance_method(:included)
564
537
  T::Private::ClassUtils.replace_method(old_included, Module, :included) do |arg|
565
538
  old_included.bind_call(self, arg)
566
- ::T::Private::Methods._hook_impl(arg, false, self)
539
+ ::T::Private::Methods._hook_impl(arg, self)
567
540
  end
568
541
  old_extended = Module.instance_method(:extended)
569
542
  T::Private::ClassUtils.replace_method(old_extended, Module, :extended) do |arg|
570
543
  old_extended.bind_call(self, arg)
571
- ::T::Private::Methods._hook_impl(arg, true, self)
544
+ ::T::Private::Methods._hook_impl(arg.singleton_class, self)
572
545
  end
573
546
  old_inherited = Class.instance_method(:inherited)
574
547
  T::Private::ClassUtils.replace_method(old_inherited, Class, :inherited) do |arg|
575
548
  old_inherited.bind_call(self, arg)
576
- ::T::Private::Methods._hook_impl(arg, false, self)
549
+ ::T::Private::Methods._hook_impl(arg, self)
550
+ ::T::Private::Methods._hook_impl(arg.singleton_class, self.singleton_class)
577
551
  end
578
552
  @old_hooks = [old_included, old_extended, old_inherited]
579
553
  end
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.13196
4
+ version: 0.6.13201
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-05-07 00:00:00.000000000 Z
11
+ date: 2026-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: benchmark