sorbet-runtime 0.4.4561 → 0.4.4562

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
  SHA1:
3
- metadata.gz: 876bfc1a50262444a634745ee4365bef585f99f1
4
- data.tar.gz: 883433b997f583f970769938165b1f9fe8ca7c0b
3
+ metadata.gz: fc0963ade0d5029ad47f82cb0f64291f79ded75f
4
+ data.tar.gz: b93481468f8542f1e7a4452a52a51ff5aebf95ad
5
5
  SHA512:
6
- metadata.gz: 7d18a5daebc62112791fc39b5ef2af13f090e1e825275ec92014d630b5e2383bfa6db2909bdd16971437243d3c4bafb186cee19591ea7c52299ffbf727c8d7d2
7
- data.tar.gz: 34833eccabb280746f89a619e7cc32e6f4ad6f773c73e85b446395233cc61a632db089538b15a2b38ac8df6b0d01a68d267ee8f6fb77becd271406d71c5f2d30
6
+ metadata.gz: 93a08ed35b68171fbaa9c74864b956855a7d1e3c883c0403462ae324bea31fee45b4522f3b1465b35a51c84e9a17501504c53d88509c6144a497ad530206eeeb
7
+ data.tar.gz: e46c1df5b7cd937505ee3d9595d97f1b7e1d236a4c215f78b62a3a66c28bd2f20e843ea33298ee8208e29d979e0568d86d255607d674e7c3f3d16950443dac08
@@ -188,6 +188,13 @@ module T::Private::Methods
188
188
  end
189
189
  T::Private::DeclState.current.reset!
190
190
 
191
+ if method_name == :method_added || method_name == :singleton_method_added
192
+ raise(
193
+ "Putting a `sig` on `#{method_name}` is not supported" +
194
+ " (sorbet-runtime uses this method internally to perform `sig` validation logic)"
195
+ )
196
+ end
197
+
191
198
  original_method = mod.instance_method(method_name)
192
199
  sig_block = lambda do
193
200
  T::Private::Methods.run_sig(hook_mod, method_name, original_method, current_declaration)
@@ -411,34 +418,30 @@ module T::Private::Methods
411
418
  end
412
419
  end
413
420
 
421
+ module MethodHooks
422
+ def method_added(name)
423
+ super(name)
424
+ ::T::Private::Methods._on_method_added(self, name, is_singleton_method: false)
425
+ end
426
+ end
427
+
428
+ module SingletonMethodHooks
429
+ def singleton_method_added(name)
430
+ super(name)
431
+ ::T::Private::Methods._on_method_added(self, name, is_singleton_method: true)
432
+ end
433
+ end
434
+
414
435
  def self.install_hooks(mod)
415
436
  return if @installed_hooks.include?(mod)
416
437
  @installed_hooks << mod
417
438
 
418
439
  if mod.singleton_class?
419
- install_singleton_method_added_hook(mod)
440
+ mod.include(SingletonMethodHooks)
420
441
  else
421
- original_method = T::Private::ClassUtils.replace_method(mod.singleton_class, :method_added) do |name|
422
- T::Private::Methods._on_method_added(self, name)
423
- original_method.bind(self).call(name)
424
- end
425
- end
426
- install_singleton_method_added_hook(mod.singleton_class)
427
- end
428
-
429
- private_class_method def self.install_singleton_method_added_hook(singleton_klass)
430
- attached = nil
431
- original_singleton_method = T::Private::ClassUtils.replace_method(singleton_klass, :singleton_method_added) do |name|
432
- attached = self
433
- T::Private::Methods._on_method_added(self, name, is_singleton_method: true)
434
- # This will be nil when this gets called for the addition of this method itself. We
435
- # call it below to compensate.
436
- if original_singleton_method
437
- original_singleton_method.bind(self).call(name)
438
- end
442
+ mod.extend(MethodHooks)
439
443
  end
440
- # See the comment above
441
- original_singleton_method.bind(attached).call(:singleton_method_added)
444
+ mod.extend(SingletonMethodHooks)
442
445
  end
443
446
 
444
447
  # use this directly if you don't want/need to box up the method into an object to pass to method_to_key.
@@ -37,7 +37,9 @@ module T::Private::Methods::CallValidation
37
37
  else
38
38
  T::Configuration.without_ruby_warnings do
39
39
  # get all the shims out of the way and put back the original method
40
+ T::Private::DeclState.current.skip_on_method_added = true
40
41
  mod.send(:define_method, method_sig.method_name, original_method)
42
+ T::Private::DeclState.current.skip_on_method_added = false
41
43
  mod.send(original_visibility, method_sig.method_name)
42
44
  end
43
45
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sorbet-runtime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4561
4
+ version: 0.4.4562
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe