sorbet-runtime 0.5.6317 → 0.5.6332

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '097683b0eba207cf9b04accf22d9dcf1661848f4d5e1254b34e3e3240b160351'
4
- data.tar.gz: cf2c97818079eba96e2eeba28b05844ce8ac8adb5c69ae940ad6031d6bdd9e43
3
+ metadata.gz: 1694a688e3b73cbb921d292cac640856edf617e826a3e8e119f5fd9c43c52099
4
+ data.tar.gz: ee936f9dcc26c79ad6614c9f98461cf7a1ffd23626cb36652a143af43aa2926f
5
5
  SHA512:
6
- metadata.gz: 221da0912324d1e0ab19d23ac4fb6c30fc1ba2a9db54b9eb466e807a1093205fe5393564a1a40783e7dee15bc167afa4f1f88445b12e1364e80120b0f00853ee
7
- data.tar.gz: '0893b271dd3d604514531424bde009256dc0a14d56e4379b5184b27ac01f10d140cb7d467217d854ebacb77489ef1874b324133f69ac2cf1df39c68c53de6b20'
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,9 +103,16 @@ 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|
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.6317
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-02 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