sorbet-runtime 0.6.13196 → 0.6.13198
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/_methods.rb +14 -20
- 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: 502bf6e904979bee93c3847869bba78f6e4dc9f6adab5458c3452993e5cdb4fb
|
|
4
|
+
data.tar.gz: 8e1b10adb5a41849a1429a4e54d6ac4f45fe7f359d2728802ace1dc3e5ac27d4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 01f535196a14169189e826b7e9b9ec53678e5e6f316f87b36fd9ad9c94ec8ec992ce19e679404a2935c82bd154361e4e096b1ea45ac0d5f113c91ab39c92ce2e
|
|
7
|
+
data.tar.gz: cdcae020f001facb48188aef702dd89dc9efa46b4b228b6ef081ce2c33073ec4ec1bbb09deccb6ffd5121047f6f487182342936b7bd075e7c7d5f297864604c8
|
|
@@ -131,14 +131,14 @@ module T::Private::Methods
|
|
|
131
131
|
#
|
|
132
132
|
# we assume that source_method_names has already been filtered to only include method
|
|
133
133
|
# names that were declared final at one point.
|
|
134
|
-
def self._check_final_ancestors(target,
|
|
134
|
+
def self._check_final_ancestors(target, source_method_names, source)
|
|
135
135
|
source_ancestors = nil
|
|
136
136
|
if T::Private::IS_TYPECHECKING
|
|
137
137
|
# Need to avoid a pinning error, but don't want to use runtime types in _methods.rb
|
|
138
138
|
source_ancestors = T.let(nil, T.nilable(T::Array[T::Module[T.anything]]))
|
|
139
139
|
end
|
|
140
140
|
# use reverse_each to check farther-up ancestors first, for better error messages.
|
|
141
|
-
|
|
141
|
+
target.ancestors.reverse_each do |ancestor|
|
|
142
142
|
final_methods = @modules_with_final.fetch(ancestor, nil)
|
|
143
143
|
# In this case, either ancestor didn't have any final methods anywhere in its
|
|
144
144
|
# ancestor chain, or ancestor did have final methods somewhere in its ancestor
|
|
@@ -200,6 +200,9 @@ module T::Private::Methods
|
|
|
200
200
|
end
|
|
201
201
|
|
|
202
202
|
def self.add_module_with_final_method(mod, method_name)
|
|
203
|
+
@was_ever_final_names[method_name] = true
|
|
204
|
+
|
|
205
|
+
# Side-effectfully initializes the value if it's not already there
|
|
203
206
|
methods = @modules_with_final[mod]
|
|
204
207
|
if methods.nil?
|
|
205
208
|
methods = {}
|
|
@@ -209,12 +212,6 @@ module T::Private::Methods
|
|
|
209
212
|
nil
|
|
210
213
|
end
|
|
211
214
|
|
|
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
215
|
# Only public because it needs to get called below inside the replace_method blocks below.
|
|
219
216
|
def self._on_method_added(hook_mod, mod, method_name)
|
|
220
217
|
if T::Private::DeclState.current.skip_on_method_added
|
|
@@ -228,7 +225,7 @@ module T::Private::Methods
|
|
|
228
225
|
end
|
|
229
226
|
# Don't compute mod.ancestors if we don't need to bother checking final-ness.
|
|
230
227
|
if @was_ever_final_names.include?(method_name) && @modules_with_final.include?(mod)
|
|
231
|
-
_check_final_ancestors(mod,
|
|
228
|
+
_check_final_ancestors(mod, [method_name], nil)
|
|
232
229
|
# We need to fetch the active declaration again, as _check_final_ancestors
|
|
233
230
|
# may have reset it (see the comment in that method for details).
|
|
234
231
|
current_declaration = T::Private::DeclState.current.active_declaration
|
|
@@ -286,10 +283,6 @@ module T::Private::Methods
|
|
|
286
283
|
|
|
287
284
|
@sig_wrappers[key] = sig_block
|
|
288
285
|
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
286
|
add_module_with_final_method(mod, method_name)
|
|
294
287
|
end
|
|
295
288
|
end
|
|
@@ -518,14 +511,15 @@ module T::Private::Methods
|
|
|
518
511
|
|
|
519
512
|
# the module target is adding the methods from the module source to itself. we need to check that for all instance
|
|
520
513
|
# methods M on source, M is not defined on any of target's ancestors.
|
|
521
|
-
def self._hook_impl(target,
|
|
514
|
+
def self._hook_impl(target, source)
|
|
522
515
|
# we do not need to call add_was_ever_final here, because we have already marked
|
|
523
516
|
# any such methods when source was originally defined.
|
|
524
517
|
if !@modules_with_final.include?(target)
|
|
525
518
|
if !@modules_with_final.include?(source)
|
|
526
519
|
return
|
|
527
520
|
end
|
|
528
|
-
|
|
521
|
+
# Side-effectfully initialize the value if it's not already there
|
|
522
|
+
@modules_with_final[target]
|
|
529
523
|
install_hooks(target)
|
|
530
524
|
return
|
|
531
525
|
end
|
|
@@ -538,8 +532,7 @@ module T::Private::Methods
|
|
|
538
532
|
return
|
|
539
533
|
end
|
|
540
534
|
|
|
541
|
-
|
|
542
|
-
_check_final_ancestors(target, target_ancestors, methods, source)
|
|
535
|
+
_check_final_ancestors(target, methods, source)
|
|
543
536
|
end
|
|
544
537
|
|
|
545
538
|
def self.set_final_checks_on_hooks(enable)
|
|
@@ -563,17 +556,18 @@ module T::Private::Methods
|
|
|
563
556
|
old_included = Module.instance_method(:included)
|
|
564
557
|
T::Private::ClassUtils.replace_method(old_included, Module, :included) do |arg|
|
|
565
558
|
old_included.bind_call(self, arg)
|
|
566
|
-
::T::Private::Methods._hook_impl(arg,
|
|
559
|
+
::T::Private::Methods._hook_impl(arg, self)
|
|
567
560
|
end
|
|
568
561
|
old_extended = Module.instance_method(:extended)
|
|
569
562
|
T::Private::ClassUtils.replace_method(old_extended, Module, :extended) do |arg|
|
|
570
563
|
old_extended.bind_call(self, arg)
|
|
571
|
-
::T::Private::Methods._hook_impl(arg,
|
|
564
|
+
::T::Private::Methods._hook_impl(arg.singleton_class, self)
|
|
572
565
|
end
|
|
573
566
|
old_inherited = Class.instance_method(:inherited)
|
|
574
567
|
T::Private::ClassUtils.replace_method(old_inherited, Class, :inherited) do |arg|
|
|
575
568
|
old_inherited.bind_call(self, arg)
|
|
576
|
-
::T::Private::Methods._hook_impl(arg,
|
|
569
|
+
::T::Private::Methods._hook_impl(arg, self)
|
|
570
|
+
::T::Private::Methods._hook_impl(arg.singleton_class, self.singleton_class)
|
|
577
571
|
end
|
|
578
572
|
@old_hooks = [old_included, old_extended, old_inherited]
|
|
579
573
|
end
|