sorbet-runtime 0.5.11152 → 0.5.11155
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/abstract/declare.rb +4 -4
- data/lib/types/private/methods/_methods.rb +12 -13
- 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: b1b1587c65bda9e89dc7d2f7891c965be4270b51840f20cf1df9c10fca944851
|
4
|
+
data.tar.gz: b34b75d390903c9971f49e7d56bd4eedb211e4f26bed504837bcc6240b748428
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe9578e8bf173e4511a27f0c8501cb0f700db9702425d279e8dcb3f1707e1164fc2000081957bd163f880c19c91f3b2aaaefb9e27d1e1a84b5306ef3354f2a85
|
7
|
+
data.tar.gz: bbafe16b0ec7eab3daf431d844f4c18490c80a674a0984d6e7a9288ee236eb65e5e7fdeb3fa4a01efc584e95331b03357cc40e3ef07c98f043be104147632d8d
|
@@ -35,11 +35,11 @@ module T::Private::Abstract::Declare
|
|
35
35
|
# define_method because of the guard above
|
36
36
|
|
37
37
|
mod.send(:define_singleton_method, :new) do |*args, &blk|
|
38
|
-
super(*args, &blk)
|
39
|
-
|
40
|
-
|
41
|
-
end
|
38
|
+
result = super(*args, &blk)
|
39
|
+
if result.instance_of?(mod)
|
40
|
+
raise "#{mod} is declared as abstract; it cannot be instantiated"
|
42
41
|
end
|
42
|
+
result
|
43
43
|
end
|
44
44
|
|
45
45
|
# Ruby doesn not emit "method redefined" warnings for aliased methods
|
@@ -8,7 +8,7 @@ module T::Private::Methods
|
|
8
8
|
@sigs_that_raised = {}
|
9
9
|
# stores method names that were declared final without regard for where.
|
10
10
|
# enables early rejection of names that we know can't induce final method violations.
|
11
|
-
@was_ever_final_names = {}
|
11
|
+
@was_ever_final_names = {}.compare_by_identity
|
12
12
|
# maps from a module's object_id to the set of final methods declared in that module.
|
13
13
|
# we also overload entries slightly: if the value is nil, that means that the
|
14
14
|
# module has final methods somewhere along its ancestor chain, but does not itself
|
@@ -20,7 +20,7 @@ module T::Private::Methods
|
|
20
20
|
# twice is permitted). we could do this with two tables, but it seems slightly
|
21
21
|
# cleaner with a single table.
|
22
22
|
# Effectively T::Hash[Module, T.nilable(Set))]
|
23
|
-
@modules_with_final = Hash.new {|hash, key| hash[key] = nil}
|
23
|
+
@modules_with_final = Hash.new {|hash, key| hash[key] = nil}.compare_by_identity
|
24
24
|
# this stores the old [included, extended] hooks for Module and inherited hook for Class that we override when
|
25
25
|
# enabling final checks for when those hooks are called. the 'hooks' here don't have anything to do with the 'hooks'
|
26
26
|
# in installed_hooks.
|
@@ -132,7 +132,7 @@ module T::Private::Methods
|
|
132
132
|
source_ancestors = nil
|
133
133
|
# use reverse_each to check farther-up ancestors first, for better error messages.
|
134
134
|
target_ancestors.reverse_each do |ancestor|
|
135
|
-
final_methods = @modules_with_final.fetch(ancestor
|
135
|
+
final_methods = @modules_with_final.fetch(ancestor, nil)
|
136
136
|
# In this case, either ancestor didn't have any final methods anywhere in its
|
137
137
|
# ancestor chain, or ancestor did have final methods somewhere in its ancestor
|
138
138
|
# chain, but no final methods defined in ancestor itself. Either way, there
|
@@ -150,13 +150,13 @@ module T::Private::Methods
|
|
150
150
|
# filter out things without actual final methods just to make sure that
|
151
151
|
# the below checks (which should be uncommon) go as quickly as possible.
|
152
152
|
source_ancestors.select! do |a|
|
153
|
-
@modules_with_final.fetch(a
|
153
|
+
@modules_with_final.fetch(a, nil)
|
154
154
|
end
|
155
155
|
end
|
156
156
|
# final-ness means that there should be no more than one index for which
|
157
157
|
# the below block returns true.
|
158
158
|
defining_ancestor_idx = source_ancestors.index do |a|
|
159
|
-
@modules_with_final.fetch(a
|
159
|
+
@modules_with_final.fetch(a).include?(method_name)
|
160
160
|
end
|
161
161
|
next if defining_ancestor_idx && source_ancestors[defining_ancestor_idx] == ancestor
|
162
162
|
end
|
@@ -193,11 +193,10 @@ module T::Private::Methods
|
|
193
193
|
|
194
194
|
def self.add_module_with_final_method(mod, method_name, is_singleton_method)
|
195
195
|
m = is_singleton_method ? mod.singleton_class : mod
|
196
|
-
|
197
|
-
methods = @modules_with_final[mid]
|
196
|
+
methods = @modules_with_final[m]
|
198
197
|
if methods.nil?
|
199
198
|
methods = {}
|
200
|
-
@modules_with_final[
|
199
|
+
@modules_with_final[m] = methods
|
201
200
|
end
|
202
201
|
methods[method_name] = true
|
203
202
|
nil
|
@@ -205,8 +204,8 @@ module T::Private::Methods
|
|
205
204
|
|
206
205
|
def self.note_module_deals_with_final(mod)
|
207
206
|
# Side-effectfully initialize the value if it's not already there
|
208
|
-
@modules_with_final[mod
|
209
|
-
@modules_with_final[mod.singleton_class
|
207
|
+
@modules_with_final[mod]
|
208
|
+
@modules_with_final[mod.singleton_class]
|
210
209
|
end
|
211
210
|
|
212
211
|
# Only public because it needs to get called below inside the replace_method blocks below.
|
@@ -222,7 +221,7 @@ module T::Private::Methods
|
|
222
221
|
raise "#{mod} was declared as final but its method `#{method_name}` was not declared as final"
|
223
222
|
end
|
224
223
|
# Don't compute mod.ancestors if we don't need to bother checking final-ness.
|
225
|
-
if @was_ever_final_names.include?(method_name) && @modules_with_final.include?(mod
|
224
|
+
if @was_ever_final_names.include?(method_name) && @modules_with_final.include?(mod)
|
226
225
|
_check_final_ancestors(mod, mod.ancestors, [method_name], nil)
|
227
226
|
# We need to fetch the active declaration again, as _check_final_ancestors
|
228
227
|
# may have reset it (see the comment in that method for details).
|
@@ -474,8 +473,8 @@ module T::Private::Methods
|
|
474
473
|
def self._hook_impl(target, singleton_class, source)
|
475
474
|
# we do not need to call add_was_ever_final here, because we have already marked
|
476
475
|
# any such methods when source was originally defined.
|
477
|
-
if !@modules_with_final.include?(target
|
478
|
-
if !@modules_with_final.include?(source
|
476
|
+
if !@modules_with_final.include?(target)
|
477
|
+
if !@modules_with_final.include?(source)
|
479
478
|
return
|
480
479
|
end
|
481
480
|
note_module_deals_with_final(target)
|
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.11155
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-12-
|
11
|
+
date: 2023-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|