sorbet-runtime 0.5.5858 → 0.5.5859
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 +30 -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: b26613ee717e93406be9863f6de88ba9ed7d56be71c14e5b9a0f6dea865f6bbd
|
4
|
+
data.tar.gz: 7c52bb7c5ea5624c002a69e6f38c02f64cdf4f1f1b7b0b03a90093511cac169c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce4dcea125090bb935cfe36e7d2c4c6421a4011b135a4c6f2eed4526c814b385d491f2e846629335181af9ec6f39fe7a2046d8333b971698e4a83f14397a3340
|
7
|
+
data.tar.gz: 3b3d85510672d63af66e8603e848e98e4d8c1305e8946acc4a58b21079cbab63a510884e521cc744ba72d1136e7de10bb6d685eaade360af9f03e8fb50579a77
|
@@ -208,7 +208,7 @@ module T::Private::Methods
|
|
208
208
|
T::Private::ClassUtils.replace_method(mod, method_name) do |*args, &blk|
|
209
209
|
method_sig = T::Private::Methods.maybe_run_sig_block_for_method(new_method)
|
210
210
|
method_sig ||= T::Private::Methods._handle_missing_method_signature(
|
211
|
-
|
211
|
+
self,
|
212
212
|
original_method,
|
213
213
|
__callee__,
|
214
214
|
)
|
@@ -242,28 +242,45 @@ module T::Private::Methods
|
|
242
242
|
end
|
243
243
|
end
|
244
244
|
|
245
|
-
def self._handle_missing_method_signature(
|
245
|
+
def self._handle_missing_method_signature(receiver, original_method, callee)
|
246
246
|
method_sig = T::Private::Methods.signature_for_method(original_method)
|
247
|
+
if !method_sig
|
248
|
+
raise "`sig` not present for method `#{callee}` on #{receiver.inspect} but you're trying to run it anyways. " \
|
249
|
+
"This should only be executed if you used `alias_method` to grab a handle to a method after `sig`ing it, but that clearly isn't what you are doing. " \
|
250
|
+
"Maybe look to see if an exception was thrown in your `sig` lambda or somehow else your `sig` wasn't actually applied to the method."
|
251
|
+
end
|
247
252
|
|
248
|
-
|
249
|
-
|
253
|
+
if receiver.class <= original_method.owner
|
254
|
+
receiving_class = receiver.class
|
255
|
+
elsif receiver.singleton_class <= original_method.owner
|
256
|
+
receiving_class = receiver.singleton_class
|
257
|
+
elsif receiver.is_a?(Module) && receiver <= original_method.owner
|
258
|
+
receiving_class = receiver
|
259
|
+
else
|
260
|
+
raise "#{receiver} is not related to #{original_method} - how did we get here?"
|
261
|
+
end
|
262
|
+
|
263
|
+
# Check for a case where `alias` or `alias_method` was called for a
|
264
|
+
# method which had already had a `sig` applied. In that case, we want
|
265
|
+
# to avoid hitting this slow path again, by moving to a faster validator
|
266
|
+
# just like we did or will for the original method.
|
267
|
+
#
|
268
|
+
# If this isn't an `alias` or `alias_method` case, we're probably in the
|
269
|
+
# middle of some metaprogramming using a Method object, e.g. a pattern like
|
270
|
+
# `arr.map(&method(:foo))`. There's nothing really we can do to optimize
|
271
|
+
# that here.
|
272
|
+
receiving_method = receiving_class.instance_method(callee)
|
273
|
+
if receiving_method != original_method && receiving_method.original_name == original_method.name
|
274
|
+
aliasing_mod = receiving_method.owner
|
250
275
|
|
251
|
-
if method_sig && aliasing_method != original_method && aliasing_method.original_name == original_method.name
|
252
|
-
# We're handling a case where `alias` or `alias_method` was called for a
|
253
|
-
# method which had already had a `sig` applied.
|
254
|
-
#
|
255
276
|
# Note, this logic is duplicated above, make sure to keep changes in sync.
|
256
277
|
if method_sig.check_level == :always || (method_sig.check_level == :tests && T::Private::RuntimeLevels.check_tests?)
|
257
278
|
# Checked, so copy the original signature to the aliased copy.
|
258
|
-
T::Private::Methods.unwrap_method(aliasing_mod, method_sig,
|
279
|
+
T::Private::Methods.unwrap_method(aliasing_mod, method_sig, original_method)
|
259
280
|
else
|
260
281
|
# Unchecked, so just make `alias_method` behave as if it had been called pre-sig.
|
261
282
|
aliasing_mod.send(:alias_method, callee, original_method.name)
|
262
283
|
end
|
263
|
-
else
|
264
|
-
raise "`sig` not present for method `#{aliasing_method.name}` but you're trying to run it anyways. " \
|
265
|
-
"This should only be executed if you used `alias_method` to grab a handle to a method after `sig`ing it, but that clearly isn't what you are doing. " \
|
266
|
-
"Maybe look to see if an exception was thrown in your `sig` lambda or somehow else your `sig` wasn't actually applied to the method."
|
267
284
|
end
|
268
285
|
|
269
286
|
method_sig
|
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.5859
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|