sorbet-runtime 0.5.6318 → 0.5.6336
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 +21 -0
- 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: 0b81aa820085c3f82ab984100ffa4eca33fc67ed314655818113d3af1968f7af
|
4
|
+
data.tar.gz: c8fc6e0885c3a8851e0a68f55dccda195006b1745c9d55dbb872723fc07c39b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acd340a1290ddba91e093fe315f25bf0e17f4648faf0fe0bfee7c09f3e1793ca7ff8832eb9fa5d880215fba349c2c4bb8512d3825dc5b4741bdc79cd92dc5928
|
7
|
+
data.tar.gz: d8297b731b4d5dfab1566092c53ae78e9db20d9a0fc9a7e51bf9d59f36b4361095df0d19ccd74ba6153e9145545e2cd5535515440e88a7529978a5700e05c739
|
@@ -11,6 +11,9 @@ module T::Private::Methods
|
|
11
11
|
# - they are done possibly before any sig block has run.
|
12
12
|
# - they are done even if the method being defined doesn't have a sig.
|
13
13
|
@final_methods = Set.new
|
14
|
+
# stores method names that were declared final without regard for where.
|
15
|
+
# enables early rejection of names that we know can't induce final method violations.
|
16
|
+
@was_ever_final_names = Set.new
|
14
17
|
# a non-singleton is a module for which at least one of the following is true:
|
15
18
|
# - is declared final
|
16
19
|
# - defines a method that is declared final
|
@@ -100,9 +103,16 @@ module T::Private::Methods
|
|
100
103
|
if !module_with_final?(target)
|
101
104
|
return
|
102
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
|
103
112
|
# use reverse_each to check farther-up ancestors first, for better error messages. we could avoid this if we were on
|
104
113
|
# the version of ruby that adds the optional argument to method_defined? that allows you to exclude ancestors.
|
105
114
|
target_ancestors.reverse_each do |ancestor|
|
115
|
+
next if !module_with_final?(ancestor)
|
106
116
|
source_method_names.each do |method_name|
|
107
117
|
# the usage of method_owner_and_name_to_key(ancestor, method_name) instead of
|
108
118
|
# method_to_key(ancestor.instance_method(method_name)) is not (just) an optimization, but also required for
|
@@ -148,6 +158,14 @@ module T::Private::Methods
|
|
148
158
|
@final_methods.include?(method_key)
|
149
159
|
end
|
150
160
|
|
161
|
+
private_class_method def self.add_was_ever_final(method_name)
|
162
|
+
@was_ever_final_names.add(method_name)
|
163
|
+
end
|
164
|
+
|
165
|
+
private_class_method def self.was_ever_final?(method_name)
|
166
|
+
@was_ever_final_names.include?(method_name)
|
167
|
+
end
|
168
|
+
|
151
169
|
def self.add_module_with_final(mod)
|
152
170
|
@modules_with_final.add(mod)
|
153
171
|
@modules_with_final.add(mod.singleton_class)
|
@@ -229,6 +247,7 @@ module T::Private::Methods
|
|
229
247
|
@sig_wrappers[key] = sig_block
|
230
248
|
if current_declaration.final
|
231
249
|
add_final_method(key)
|
250
|
+
add_was_ever_final(method_name)
|
232
251
|
# use hook_mod, not mod, because for example, we want class C to be marked as having final if we def C.foo as
|
233
252
|
# final. change this to mod to see some final_method tests fail.
|
234
253
|
add_module_with_final(hook_mod)
|
@@ -411,6 +430,8 @@ module T::Private::Methods
|
|
411
430
|
if !module_with_final?(target) && !module_with_final?(source)
|
412
431
|
return
|
413
432
|
end
|
433
|
+
# we do not need to call add_was_ever_final here, because we have already marked
|
434
|
+
# any such methods when source was originally defined.
|
414
435
|
add_module_with_final(target)
|
415
436
|
install_hooks(target)
|
416
437
|
_check_final_ancestors(target, target_ancestors - source.ancestors, source.instance_methods)
|
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.6336
|
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-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|