sorbet-runtime 0.5.6330 → 0.5.6332

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: 0da778c9f0f22c310083fc51efae568d37ccd4bbd351b1d6594befd781fd4d04
4
- data.tar.gz: 156d25d18fccbb910c51e95e5bf38e0b62a6675784ce5ebc9051890057c589d5
3
+ metadata.gz: 1694a688e3b73cbb921d292cac640856edf617e826a3e8e119f5fd9c43c52099
4
+ data.tar.gz: ee936f9dcc26c79ad6614c9f98461cf7a1ffd23626cb36652a143af43aa2926f
5
5
  SHA512:
6
- metadata.gz: 04c6c3df67d068040058f07d755801085ac888e781daaad45a4c92776937df998b484e09a80561846abcb065eb1ff8c2ed2181828e98f1dca93d84e4b0e74301
7
- data.tar.gz: dbfa5e1cd1a01e92d5a2917330ee9dd3493e50919fdcd74ceabc5d86bd23e82e0eb162a1ffda933688357a2439436bf0d0d7d420d8ef0d3dc579553908eea760
6
+ metadata.gz: 2b65d6a7b161994dd421dba90392a7087d60deb4608c2c4cec4220c5c06fe3c71c75747292aaec95e90d245bccafad468f230139e640d0ae9ad4bafc8326c17a
7
+ data.tar.gz: fc2e647d852f06efc68d8b9ef3b21007c6ae16a9ec7d22a9a8cdccd58598118120bea6ad2c89d054c19d105a87d91a4f6cc939aa9743ddef10fab831ca845284
@@ -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,6 +103,12 @@ module T::Private::Methods
100
103
  if !module_with_final?(target)
101
104
  return
102
105
  end
106
+ source_method_names.filter! 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|
@@ -149,6 +158,14 @@ module T::Private::Methods
149
158
  @final_methods.include?(method_key)
150
159
  end
151
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
+
152
169
  def self.add_module_with_final(mod)
153
170
  @modules_with_final.add(mod)
154
171
  @modules_with_final.add(mod.singleton_class)
@@ -230,6 +247,7 @@ module T::Private::Methods
230
247
  @sig_wrappers[key] = sig_block
231
248
  if current_declaration.final
232
249
  add_final_method(key)
250
+ add_was_ever_final(method_name)
233
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
234
252
  # final. change this to mod to see some final_method tests fail.
235
253
  add_module_with_final(hook_mod)
@@ -412,6 +430,8 @@ module T::Private::Methods
412
430
  if !module_with_final?(target) && !module_with_final?(source)
413
431
  return
414
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.
415
435
  add_module_with_final(target)
416
436
  install_hooks(target)
417
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.6330
4
+ version: 0.5.6332
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-09 00:00:00.000000000 Z
11
+ date: 2021-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest