sorbet-runtime 0.5.6336 → 0.5.6338
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/types/private/methods/_methods.rb +28 -16
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3671ed176f9cf1875148797095dcda29672ad803d5ede745ec3aac0e8ddacd31
|
4
|
+
data.tar.gz: '019c5545c3bdff3a7f1aad4c0eaefdc57f0172a13413aa59236b27da8609e89f'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18c9836a43d62d5c73f8c7d4dd402496ed523e6beaa389eda774b207c4aaacb7499f83936f32a8d4efcf72559f0b2a06b341a89bd31aa41ca7168359ecf03462
|
7
|
+
data.tar.gz: da19c72bf63324a8f09ef63b811edba84f84c26bc545025c1ca354e03626c774bbf1fc3ada5051c7393678d056ad10106f73ffdb24a790d14564b9b7ebf10797
|
@@ -99,16 +99,10 @@ module T::Private::Methods
|
|
99
99
|
# when target includes a module with instance methods source_method_names, ensure there is zero intersection between
|
100
100
|
# the final instance methods of target and source_method_names. so, for every m in source_method_names, check if there
|
101
101
|
# is already a method defined on one of target_ancestors with the same name that is final.
|
102
|
+
#
|
103
|
+
# we assume that source_method_names has already been filtered to only include method
|
104
|
+
# names that were declared final at one point.
|
102
105
|
def self._check_final_ancestors(target, target_ancestors, source_method_names)
|
103
|
-
if !module_with_final?(target)
|
104
|
-
return
|
105
|
-
end
|
106
|
-
source_method_names.select! do |method_name|
|
107
|
-
was_ever_final?(method_name)
|
108
|
-
end
|
109
|
-
if source_method_names.empty?
|
110
|
-
return
|
111
|
-
end
|
112
106
|
# use reverse_each to check farther-up ancestors first, for better error messages. we could avoid this if we were on
|
113
107
|
# the version of ruby that adds the optional argument to method_defined? that allows you to exclude ancestors.
|
114
108
|
target_ancestors.reverse_each do |ancestor|
|
@@ -187,7 +181,10 @@ module T::Private::Methods
|
|
187
181
|
if T::Private::Final.final_module?(mod) && (current_declaration.nil? || !current_declaration.final)
|
188
182
|
raise "#{mod} was declared as final but its method `#{method_name}` was not declared as final"
|
189
183
|
end
|
190
|
-
|
184
|
+
# Don't compute mod.ancestors if we don't need to bother checking final-ness.
|
185
|
+
if was_ever_final?(method_name) && module_with_final?(mod)
|
186
|
+
_check_final_ancestors(mod, mod.ancestors, [method_name])
|
187
|
+
end
|
191
188
|
|
192
189
|
# We need to fetch the active declaration again, as _check_final_ancestors
|
193
190
|
# may have reset it (see the comment in that method for details).
|
@@ -426,15 +423,30 @@ module T::Private::Methods
|
|
426
423
|
|
427
424
|
# the module target is adding the methods from the module source to itself. we need to check that for all instance
|
428
425
|
# methods M on source, M is not defined on any of target's ancestors.
|
429
|
-
def self._hook_impl(target,
|
430
|
-
|
426
|
+
def self._hook_impl(target, singleton_class, source)
|
427
|
+
target_was_final = module_with_final?(target)
|
428
|
+
if !target_was_final && !module_with_final?(source)
|
431
429
|
return
|
432
430
|
end
|
433
431
|
# we do not need to call add_was_ever_final here, because we have already marked
|
434
432
|
# any such methods when source was originally defined.
|
435
433
|
add_module_with_final(target)
|
436
434
|
install_hooks(target)
|
437
|
-
|
435
|
+
|
436
|
+
if !target_was_final
|
437
|
+
return
|
438
|
+
end
|
439
|
+
|
440
|
+
methods = source.instance_methods
|
441
|
+
methods.select! do |method_name|
|
442
|
+
was_ever_final?(method_name)
|
443
|
+
end
|
444
|
+
if methods.empty?
|
445
|
+
return
|
446
|
+
end
|
447
|
+
|
448
|
+
target_ancestors = singleton_class ? target.singleton_class.ancestors : target.ancestors
|
449
|
+
_check_final_ancestors(target, target_ancestors - source.ancestors, methods)
|
438
450
|
end
|
439
451
|
|
440
452
|
def self.set_final_checks_on_hooks(enable)
|
@@ -448,15 +460,15 @@ module T::Private::Methods
|
|
448
460
|
else
|
449
461
|
old_included = T::Private::ClassUtils.replace_method(Module, :included) do |arg|
|
450
462
|
old_included.bind(self).call(arg)
|
451
|
-
::T::Private::Methods._hook_impl(arg,
|
463
|
+
::T::Private::Methods._hook_impl(arg, false, self)
|
452
464
|
end
|
453
465
|
old_extended = T::Private::ClassUtils.replace_method(Module, :extended) do |arg|
|
454
466
|
old_extended.bind(self).call(arg)
|
455
|
-
::T::Private::Methods._hook_impl(arg,
|
467
|
+
::T::Private::Methods._hook_impl(arg, true, self)
|
456
468
|
end
|
457
469
|
old_inherited = T::Private::ClassUtils.replace_method(Class, :inherited) do |arg|
|
458
470
|
old_inherited.bind(self).call(arg)
|
459
|
-
::T::Private::Methods._hook_impl(arg,
|
471
|
+
::T::Private::Methods._hook_impl(arg, false, self)
|
460
472
|
end
|
461
473
|
@old_hooks = [old_included, old_extended, old_inherited]
|
462
474
|
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.5.
|
4
|
+
version: 0.5.6338
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|