sorbet-runtime 0.6.13224 → 0.6.13226
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 +4 -4
- data/lib/types/private/methods/_methods.rb +27 -33
- data/lib/types/private/methods/decl_builder.rb +1 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e907a4879f20cbb646044c37f44b50280d00aec1667f104c47042d78825bc577
|
|
4
|
+
data.tar.gz: 4749bfa922d12839e963d08b99c8fef4637c238728527a9a287f6fdad2688841
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4870335d1730b9240f4b81b1d8ae948850d5833ed7d341cbbcccd8817a1ba1dd3b3afeb472c440514c7fc0a3019a29ea7b2b07675f12cd7a8f650fa983d61102
|
|
7
|
+
data.tar.gz: bcae385c2a650224bafe810e1295cda429c73d2612ffe5a4c3c3aa75345c6e38c7bcc207989ebf2e667040cf015b31cc28309689640758686cc4d8d52ec79e88
|
|
@@ -48,15 +48,9 @@ module T::Private::Methods
|
|
|
48
48
|
# (This can matter for circular load-time behavior, where a method is
|
|
49
49
|
# called while its Signature is being built)
|
|
50
50
|
# - It's `nil` if we've finished building the sig
|
|
51
|
-
DeclarationBlock = Struct.new(:mod, :loc, :blk_or_decl, :final
|
|
51
|
+
DeclarationBlock = Struct.new(:mod, :loc, :blk_or_decl, :final)
|
|
52
52
|
|
|
53
53
|
def self.declare_sig(mod, loc, arg, &blk)
|
|
54
|
-
T::Private::DeclState.current.active_declaration = _declare_sig_internal(mod, loc, arg, &blk)
|
|
55
|
-
|
|
56
|
-
nil
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
private_class_method def self._declare_sig_internal(mod, loc, arg, raw: false, &blk)
|
|
60
54
|
install_hooks(mod)
|
|
61
55
|
|
|
62
56
|
if T::Private::DeclState.current.active_declaration
|
|
@@ -68,11 +62,13 @@ module T::Private::Methods
|
|
|
68
62
|
raise "Invalid argument to `sig`: #{arg}"
|
|
69
63
|
end
|
|
70
64
|
|
|
71
|
-
DeclarationBlock.new(mod, loc, blk, arg == :final
|
|
65
|
+
T::Private::DeclState.current.active_declaration = DeclarationBlock.new(mod, loc, blk, arg == :final)
|
|
66
|
+
|
|
67
|
+
nil
|
|
72
68
|
end
|
|
73
69
|
|
|
74
70
|
def self.start_proc
|
|
75
|
-
DeclBuilder.new(PROC_TYPE
|
|
71
|
+
DeclBuilder.new(PROC_TYPE)
|
|
76
72
|
end
|
|
77
73
|
|
|
78
74
|
def self.finalize_proc(decl)
|
|
@@ -233,31 +229,29 @@ module T::Private::Methods
|
|
|
233
229
|
# This wrapper is very slow, so it will subsequently re-wrap with a much faster wrapper
|
|
234
230
|
# (or unwrap back to the original method).
|
|
235
231
|
key = method_owner_and_name_to_key(mod, method_name)
|
|
236
|
-
|
|
237
|
-
T::Private::
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
super(*args, &blk)
|
|
251
|
-
else
|
|
252
|
-
raise NotImplementedError.new("The method `#{method_sig.method_name}` on #{mod} is declared as `abstract`. It does not have an implementation.")
|
|
253
|
-
end
|
|
254
|
-
# Note, this logic is duplicated (intentionally, for micro-perf) at `CallValidation.wrap_method_if_needed`,
|
|
255
|
-
# make sure to keep changes in sync.
|
|
256
|
-
elsif method_sig.check_level == :always || (method_sig.check_level == :tests && T::Private::RuntimeLevels.check_tests?)
|
|
257
|
-
CallValidation.validate_call(self, original_method, method_sig, args, blk)
|
|
232
|
+
T::Private::ClassUtils.replace_method(original_method, mod, method_name) do |*args, &blk|
|
|
233
|
+
method_sig = T::Private::Methods.maybe_run_sig_block_for_key(key)
|
|
234
|
+
method_sig ||= T::Private::Methods._handle_missing_method_signature(
|
|
235
|
+
self,
|
|
236
|
+
original_method,
|
|
237
|
+
__callee__ || raise("Unknown __callee__ for method without a signature"),
|
|
238
|
+
)
|
|
239
|
+
|
|
240
|
+
# Should be the same logic as CallValidation.wrap_method_if_needed but we
|
|
241
|
+
# don't want that extra layer of indirection in the callstack
|
|
242
|
+
if method_sig.mode == T::Private::Methods::Modes.abstract
|
|
243
|
+
# We're in an interface method, keep going up the chain
|
|
244
|
+
if defined?(super)
|
|
245
|
+
super(*args, &blk)
|
|
258
246
|
else
|
|
259
|
-
|
|
247
|
+
raise NotImplementedError.new("The method `#{method_sig.method_name}` on #{mod} is declared as `abstract`. It does not have an implementation.")
|
|
260
248
|
end
|
|
249
|
+
# Note, this logic is duplicated (intentionally, for micro-perf) at `CallValidation.wrap_method_if_needed`,
|
|
250
|
+
# make sure to keep changes in sync.
|
|
251
|
+
elsif method_sig.check_level == :always || (method_sig.check_level == :tests && T::Private::RuntimeLevels.check_tests?)
|
|
252
|
+
CallValidation.validate_call(self, original_method, method_sig, args, blk)
|
|
253
|
+
else
|
|
254
|
+
original_method.bind_call(self, *args, &blk)
|
|
261
255
|
end
|
|
262
256
|
end
|
|
263
257
|
|
|
@@ -343,7 +337,7 @@ module T::Private::Methods
|
|
|
343
337
|
raise "DeclarationBlock for #{declaration_block.mod} at #{declaration_block.loc} should have already been unwrapped"
|
|
344
338
|
end
|
|
345
339
|
|
|
346
|
-
builder = DeclBuilder.new(declaration_block.mod
|
|
340
|
+
builder = DeclBuilder.new(declaration_block.mod)
|
|
347
341
|
decl = builder.instance_exec(&blk_or_decl).finalize!.decl
|
|
348
342
|
# Record that we've already run `blk` once and constructed a `Declaration`
|
|
349
343
|
declaration_block.blk_or_decl = decl
|
|
@@ -15,7 +15,7 @@ module T::Private::Methods
|
|
|
15
15
|
end
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
def initialize(mod
|
|
18
|
+
def initialize(mod)
|
|
19
19
|
@decl = Declaration.new(
|
|
20
20
|
mod,
|
|
21
21
|
ARG_NOT_PROVIDED, # params
|
|
@@ -27,7 +27,6 @@ module T::Private::Methods
|
|
|
27
27
|
ARG_NOT_PROVIDED, # on_failure
|
|
28
28
|
false, # override_allow_incompatible
|
|
29
29
|
ARG_NOT_PROVIDED, # type_parameters
|
|
30
|
-
raw
|
|
31
30
|
)
|
|
32
31
|
end
|
|
33
32
|
|