sorbet-runtime 0.5.10782 → 0.5.10993
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sorbet-runtime.rb +1 -0
- data/lib/types/_types.rb +13 -1
- data/lib/types/enum.rb +1 -1
- data/lib/types/private/abstract/declare.rb +10 -9
- data/lib/types/private/class_utils.rb +13 -6
- data/lib/types/private/methods/_methods.rb +27 -9
- data/lib/types/private/methods/call_validation.rb +1 -1
- data/lib/types/private/methods/call_validation_2_6.rb +68 -60
- data/lib/types/private/methods/call_validation_2_7.rb +68 -60
- data/lib/types/private/methods/decl_builder.rb +4 -2
- data/lib/types/private/methods/signature.rb +63 -38
- data/lib/types/private/methods/signature_validation.rb +55 -6
- data/lib/types/private/types/not_typed.rb +2 -0
- data/lib/types/props/decorator.rb +38 -35
- data/lib/types/props/has_lazily_specialized_methods.rb +1 -1
- data/lib/types/props/private/setter_factory.rb +1 -1
- data/lib/types/props/type_validation.rb +5 -2
- data/lib/types/struct.rb +2 -2
- data/lib/types/types/class_of.rb +11 -0
- data/lib/types/types/simple.rb +12 -1
- data/lib/types/types/type_parameter.rb +19 -0
- data/lib/types/types/typed_class.rb +85 -0
- data/lib/types/types/typed_enumerable.rb +2 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0f91e65ae1b0e498c5df805b8f45638368257bba5b57c83153d73468c93c902
|
4
|
+
data.tar.gz: c183a3eb926674965fb519fe6fd03450151134fd14e494d3cf9cbdb2214fefb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4e0e8d924176d843836921e5b8de7b768ec85636aaba35d05e8329225bf92854e979a8c6e8ee373de5568c2fc1f57f3a1b069197c0b6849942561f7cd16e395
|
7
|
+
data.tar.gz: c75f0f7590bc1b1e481f674e537497b69969bebeaa8866cea12994e63b62d3366dad7fbc583cdfff7c67392e76294374ef16e1946234ecc9be1ae4429211152b
|
data/lib/sorbet-runtime.rb
CHANGED
data/lib/types/_types.rb
CHANGED
@@ -123,7 +123,7 @@ module T
|
|
123
123
|
# .returns(T::Array[T.type_parameter(:U)])
|
124
124
|
# def map(&blk); end
|
125
125
|
def self.type_parameter(name)
|
126
|
-
T::Types::TypeParameter.
|
126
|
+
T::Types::TypeParameter.make(name)
|
127
127
|
end
|
128
128
|
|
129
129
|
# Tells the typechecker that `value` is of type `type`. Use this to get additional checking after
|
@@ -355,4 +355,16 @@ module T
|
|
355
355
|
end
|
356
356
|
end
|
357
357
|
end
|
358
|
+
|
359
|
+
module Class
|
360
|
+
def self.[](type)
|
361
|
+
if type.is_a?(T::Types::Untyped)
|
362
|
+
T::Types::TypedClass::Untyped::Private::INSTANCE
|
363
|
+
elsif type.is_a?(T::Types::Anything)
|
364
|
+
T::Types::TypedClass::Anything::Private::INSTANCE
|
365
|
+
else
|
366
|
+
T::Types::TypedClass::Private::Pool.type_for_module(type)
|
367
|
+
end
|
368
|
+
end
|
369
|
+
end
|
358
370
|
end
|
data/lib/types/enum.rb
CHANGED
@@ -27,26 +27,27 @@ module T::Private::Abstract::Declare
|
|
27
27
|
raise "Classes can't be interfaces. Use `abstract!` instead of `interface!`."
|
28
28
|
end
|
29
29
|
|
30
|
-
if
|
31
|
-
raise "You must call `abstract!` *before* defining
|
30
|
+
if Object.instance_method(:method).bind_call(mod, :new).owner == mod
|
31
|
+
raise "You must call `abstract!` *before* defining a `new` method"
|
32
32
|
end
|
33
33
|
|
34
34
|
# Don't need to silence warnings via without_ruby_warnings when calling
|
35
35
|
# define_method because of the guard above
|
36
36
|
|
37
|
-
mod.send(:
|
38
|
-
|
39
|
-
|
37
|
+
mod.send(:define_singleton_method, :new) do |*args, &blk|
|
38
|
+
super(*args, &blk).tap do |result|
|
39
|
+
if result.instance_of?(mod)
|
40
|
+
raise "#{mod} is declared as abstract; it cannot be instantiated"
|
41
|
+
end
|
40
42
|
end
|
41
|
-
super(*args, &blk)
|
42
43
|
end
|
43
44
|
|
44
45
|
# Ruby doesn not emit "method redefined" warnings for aliased methods
|
45
46
|
# (more robust than undef_method that would create a small window in which the method doesn't exist)
|
46
|
-
mod.send(:alias_method, :
|
47
|
+
mod.singleton_class.send(:alias_method, :new, :new)
|
47
48
|
|
48
|
-
if mod.respond_to?(:ruby2_keywords, true)
|
49
|
-
mod.send(:ruby2_keywords, :
|
49
|
+
if mod.singleton_class.respond_to?(:ruby2_keywords, true)
|
50
|
+
mod.singleton_class.send(:ruby2_keywords, :new)
|
50
51
|
end
|
51
52
|
end
|
52
53
|
end
|
@@ -91,10 +91,13 @@ module T::Private::ClassUtils
|
|
91
91
|
end
|
92
92
|
|
93
93
|
# Replaces a method, either by overwriting it (if it is defined directly on `mod`) or by
|
94
|
-
# overriding it (if it is defined by one of mod's ancestors).
|
95
|
-
# on which you can call `bind(...).call(...)`
|
96
|
-
#
|
97
|
-
|
94
|
+
# overriding it (if it is defined by one of mod's ancestors). If `original_only` is
|
95
|
+
# false, returns a ReplacedMethod instance on which you can call `bind(...).call(...)`
|
96
|
+
# to call the original method, or `restore` to restore the original method (by
|
97
|
+
# overwriting or removing the override).
|
98
|
+
#
|
99
|
+
# If `original_only` is true, return the `UnboundMethod` representing the original method.
|
100
|
+
def self.replace_method(mod, name, original_only=false, &blk)
|
98
101
|
original_method = mod.instance_method(name)
|
99
102
|
original_visibility = visibility_method_name(mod, name)
|
100
103
|
original_owner = original_method.owner
|
@@ -120,8 +123,12 @@ module T::Private::ClassUtils
|
|
120
123
|
def_with_visibility(mod, name, original_visibility, &blk)
|
121
124
|
end
|
122
125
|
end
|
123
|
-
new_method = mod.instance_method(name)
|
124
126
|
|
125
|
-
|
127
|
+
if original_only
|
128
|
+
original_method
|
129
|
+
else
|
130
|
+
new_method = mod.instance_method(name)
|
131
|
+
ReplacedMethod.new(mod, original_method, new_method, overwritten, original_visibility)
|
132
|
+
end
|
126
133
|
end
|
127
134
|
end
|
@@ -163,7 +163,7 @@ module T::Private::Methods
|
|
163
163
|
|
164
164
|
definition_file, definition_line = T::Private::Methods.signature_for_method(ancestor.instance_method(method_name)).method.source_location
|
165
165
|
is_redefined = target == ancestor
|
166
|
-
caller_loc = caller_locations
|
166
|
+
caller_loc = caller_locations.find {|l| !l.to_s.start_with?(SORBET_RUNTIME_LIB_PATH)}
|
167
167
|
extra_info = "\n"
|
168
168
|
if caller_loc
|
169
169
|
extra_info = (is_redefined ? "Redefined" : "Overridden") + " here: #{caller_loc.path}:#{caller_loc.lineno}\n"
|
@@ -252,7 +252,7 @@ module T::Private::Methods
|
|
252
252
|
# (or unwrap back to the original method).
|
253
253
|
key = method_owner_and_name_to_key(mod, method_name)
|
254
254
|
unless current_declaration.raw
|
255
|
-
T::Private::ClassUtils.replace_method(mod, method_name) do |*args, &blk|
|
255
|
+
T::Private::ClassUtils.replace_method(mod, method_name, true) do |*args, &blk|
|
256
256
|
method_sig = T::Private::Methods.maybe_run_sig_block_for_key(key)
|
257
257
|
method_sig ||= T::Private::Methods._handle_missing_method_signature(
|
258
258
|
self,
|
@@ -501,19 +501,37 @@ module T::Private::Methods
|
|
501
501
|
return
|
502
502
|
end
|
503
503
|
if is_enabled
|
504
|
-
|
504
|
+
# A cut-down version of T::Private::ClassUtils::ReplacedMethod#restore, because we
|
505
|
+
# should only be resetting final hooks during tests.
|
506
|
+
T::Configuration.without_ruby_warnings do
|
507
|
+
Module.define_method(:included, @old_hooks[0])
|
508
|
+
Module.define_method(:extended, @old_hooks[1])
|
509
|
+
Class.define_method(:inherited, @old_hooks[2])
|
510
|
+
end
|
505
511
|
@old_hooks = nil
|
506
512
|
else
|
507
|
-
old_included = T::Private::ClassUtils.replace_method(Module, :included) do |arg|
|
508
|
-
|
513
|
+
old_included = T::Private::ClassUtils.replace_method(Module, :included, true) do |arg|
|
514
|
+
if T::Configuration::AT_LEAST_RUBY_2_7
|
515
|
+
old_included.bind_call(self, arg)
|
516
|
+
else
|
517
|
+
old_included.bind(self).call(arg)
|
518
|
+
end
|
509
519
|
::T::Private::Methods._hook_impl(arg, false, self)
|
510
520
|
end
|
511
|
-
old_extended = T::Private::ClassUtils.replace_method(Module, :extended) do |arg|
|
512
|
-
|
521
|
+
old_extended = T::Private::ClassUtils.replace_method(Module, :extended, true) do |arg|
|
522
|
+
if T::Configuration::AT_LEAST_RUBY_2_7
|
523
|
+
old_extended.bind_call(self, arg)
|
524
|
+
else
|
525
|
+
old_extended.bind(self).call(arg)
|
526
|
+
end
|
513
527
|
::T::Private::Methods._hook_impl(arg, true, self)
|
514
528
|
end
|
515
|
-
old_inherited = T::Private::ClassUtils.replace_method(Class, :inherited) do |arg|
|
516
|
-
|
529
|
+
old_inherited = T::Private::ClassUtils.replace_method(Class, :inherited, true) do |arg|
|
530
|
+
if T::Configuration::AT_LEAST_RUBY_2_7
|
531
|
+
old_inherited.bind_call(self, arg)
|
532
|
+
else
|
533
|
+
old_inherited.bind(self).call(arg)
|
534
|
+
end
|
517
535
|
::T::Private::Methods._hook_impl(arg, false, self)
|
518
536
|
end
|
519
537
|
@old_hooks = [old_included, old_extended, old_inherited]
|
@@ -14,7 +14,7 @@ module T::Private::Methods::CallValidation
|
|
14
14
|
def self.wrap_method_if_needed(mod, method_sig, original_method)
|
15
15
|
original_visibility = visibility_method_name(mod, method_sig.method_name)
|
16
16
|
if method_sig.mode == T::Private::Methods::Modes.abstract
|
17
|
-
T::Private::ClassUtils.replace_method(mod, method_sig.method_name) do |*args, &blk|
|
17
|
+
T::Private::ClassUtils.replace_method(mod, method_sig.method_name, true) do |*args, &blk|
|
18
18
|
# TODO: write a cop to ensure that abstract methods have an empty body
|
19
19
|
#
|
20
20
|
# We allow abstract methods to be implemented by things further down the ancestor chain.
|
@@ -11,26 +11,28 @@ module T::Private::Methods::CallValidation
|
|
11
11
|
raise 'Should have used create_validator_procedure_fast'
|
12
12
|
end
|
13
13
|
# trampoline to reduce stack frame size
|
14
|
-
|
14
|
+
arg_types = method_sig.arg_types
|
15
|
+
case arg_types.length
|
16
|
+
when 0
|
15
17
|
create_validator_method_fast0(mod, original_method, method_sig, original_visibility, method_sig.return_type.raw_type)
|
16
|
-
|
18
|
+
when 1
|
17
19
|
create_validator_method_fast1(mod, original_method, method_sig, original_visibility, method_sig.return_type.raw_type,
|
18
|
-
|
19
|
-
|
20
|
+
arg_types[0][1].raw_type)
|
21
|
+
when 2
|
20
22
|
create_validator_method_fast2(mod, original_method, method_sig, original_visibility, method_sig.return_type.raw_type,
|
21
|
-
|
22
|
-
|
23
|
-
|
23
|
+
arg_types[0][1].raw_type,
|
24
|
+
arg_types[1][1].raw_type)
|
25
|
+
when 3
|
24
26
|
create_validator_method_fast3(mod, original_method, method_sig, original_visibility, method_sig.return_type.raw_type,
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
arg_types[0][1].raw_type,
|
28
|
+
arg_types[1][1].raw_type,
|
29
|
+
arg_types[2][1].raw_type)
|
30
|
+
when 4
|
29
31
|
create_validator_method_fast4(mod, original_method, method_sig, original_visibility, method_sig.return_type.raw_type,
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
arg_types[0][1].raw_type,
|
33
|
+
arg_types[1][1].raw_type,
|
34
|
+
arg_types[2][1].raw_type,
|
35
|
+
arg_types[3][1].raw_type)
|
34
36
|
else
|
35
37
|
raise 'should not happen'
|
36
38
|
end
|
@@ -343,26 +345,28 @@ module T::Private::Methods::CallValidation
|
|
343
345
|
|
344
346
|
def self.create_validator_procedure_fast(mod, original_method, method_sig, original_visibility)
|
345
347
|
# trampoline to reduce stack frame size
|
346
|
-
|
348
|
+
arg_types = method_sig.arg_types
|
349
|
+
case arg_types.length
|
350
|
+
when 0
|
347
351
|
create_validator_procedure_fast0(mod, original_method, method_sig, original_visibility)
|
348
|
-
|
352
|
+
when 1
|
349
353
|
create_validator_procedure_fast1(mod, original_method, method_sig, original_visibility,
|
350
|
-
|
351
|
-
|
354
|
+
arg_types[0][1].raw_type)
|
355
|
+
when 2
|
352
356
|
create_validator_procedure_fast2(mod, original_method, method_sig, original_visibility,
|
353
|
-
|
354
|
-
|
355
|
-
|
357
|
+
arg_types[0][1].raw_type,
|
358
|
+
arg_types[1][1].raw_type)
|
359
|
+
when 3
|
356
360
|
create_validator_procedure_fast3(mod, original_method, method_sig, original_visibility,
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
+
arg_types[0][1].raw_type,
|
362
|
+
arg_types[1][1].raw_type,
|
363
|
+
arg_types[2][1].raw_type)
|
364
|
+
when 4
|
361
365
|
create_validator_procedure_fast4(mod, original_method, method_sig, original_visibility,
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
+
arg_types[0][1].raw_type,
|
367
|
+
arg_types[1][1].raw_type,
|
368
|
+
arg_types[2][1].raw_type,
|
369
|
+
arg_types[3][1].raw_type)
|
366
370
|
else
|
367
371
|
raise 'should not happen'
|
368
372
|
end
|
@@ -608,26 +612,28 @@ module T::Private::Methods::CallValidation
|
|
608
612
|
raise 'Should have used create_validator_procedure_medium'
|
609
613
|
end
|
610
614
|
# trampoline to reduce stack frame size
|
611
|
-
|
615
|
+
arg_types = method_sig.arg_types
|
616
|
+
case arg_types.length
|
617
|
+
when 0
|
612
618
|
create_validator_method_medium0(mod, original_method, method_sig, original_visibility, method_sig.return_type)
|
613
|
-
|
619
|
+
when 1
|
614
620
|
create_validator_method_medium1(mod, original_method, method_sig, original_visibility, method_sig.return_type,
|
615
|
-
|
616
|
-
|
621
|
+
arg_types[0][1])
|
622
|
+
when 2
|
617
623
|
create_validator_method_medium2(mod, original_method, method_sig, original_visibility, method_sig.return_type,
|
618
|
-
|
619
|
-
|
620
|
-
|
624
|
+
arg_types[0][1],
|
625
|
+
arg_types[1][1])
|
626
|
+
when 3
|
621
627
|
create_validator_method_medium3(mod, original_method, method_sig, original_visibility, method_sig.return_type,
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
628
|
+
arg_types[0][1],
|
629
|
+
arg_types[1][1],
|
630
|
+
arg_types[2][1])
|
631
|
+
when 4
|
626
632
|
create_validator_method_medium4(mod, original_method, method_sig, original_visibility, method_sig.return_type,
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
633
|
+
arg_types[0][1],
|
634
|
+
arg_types[1][1],
|
635
|
+
arg_types[2][1],
|
636
|
+
arg_types[3][1])
|
631
637
|
else
|
632
638
|
raise 'should not happen'
|
633
639
|
end
|
@@ -940,26 +946,28 @@ module T::Private::Methods::CallValidation
|
|
940
946
|
|
941
947
|
def self.create_validator_procedure_medium(mod, original_method, method_sig, original_visibility)
|
942
948
|
# trampoline to reduce stack frame size
|
943
|
-
|
949
|
+
arg_types = method_sig.arg_types
|
950
|
+
case arg_types.length
|
951
|
+
when 0
|
944
952
|
create_validator_procedure_medium0(mod, original_method, method_sig, original_visibility)
|
945
|
-
|
953
|
+
when 1
|
946
954
|
create_validator_procedure_medium1(mod, original_method, method_sig, original_visibility,
|
947
|
-
|
948
|
-
|
955
|
+
arg_types[0][1])
|
956
|
+
when 2
|
949
957
|
create_validator_procedure_medium2(mod, original_method, method_sig, original_visibility,
|
950
|
-
|
951
|
-
|
952
|
-
|
958
|
+
arg_types[0][1],
|
959
|
+
arg_types[1][1])
|
960
|
+
when 3
|
953
961
|
create_validator_procedure_medium3(mod, original_method, method_sig, original_visibility,
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
962
|
+
arg_types[0][1],
|
963
|
+
arg_types[1][1],
|
964
|
+
arg_types[2][1])
|
965
|
+
when 4
|
958
966
|
create_validator_procedure_medium4(mod, original_method, method_sig, original_visibility,
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
967
|
+
arg_types[0][1],
|
968
|
+
arg_types[1][1],
|
969
|
+
arg_types[2][1],
|
970
|
+
arg_types[3][1])
|
963
971
|
else
|
964
972
|
raise 'should not happen'
|
965
973
|
end
|
@@ -11,26 +11,28 @@ module T::Private::Methods::CallValidation
|
|
11
11
|
raise 'Should have used create_validator_procedure_fast'
|
12
12
|
end
|
13
13
|
# trampoline to reduce stack frame size
|
14
|
-
|
14
|
+
arg_types = method_sig.arg_types
|
15
|
+
case arg_types.length
|
16
|
+
when 0
|
15
17
|
create_validator_method_fast0(mod, original_method, method_sig, original_visibility, method_sig.return_type.raw_type)
|
16
|
-
|
18
|
+
when 1
|
17
19
|
create_validator_method_fast1(mod, original_method, method_sig, original_visibility, method_sig.return_type.raw_type,
|
18
|
-
|
19
|
-
|
20
|
+
arg_types[0][1].raw_type)
|
21
|
+
when 2
|
20
22
|
create_validator_method_fast2(mod, original_method, method_sig, original_visibility, method_sig.return_type.raw_type,
|
21
|
-
|
22
|
-
|
23
|
-
|
23
|
+
arg_types[0][1].raw_type,
|
24
|
+
arg_types[1][1].raw_type)
|
25
|
+
when 3
|
24
26
|
create_validator_method_fast3(mod, original_method, method_sig, original_visibility, method_sig.return_type.raw_type,
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
arg_types[0][1].raw_type,
|
28
|
+
arg_types[1][1].raw_type,
|
29
|
+
arg_types[2][1].raw_type)
|
30
|
+
when 4
|
29
31
|
create_validator_method_fast4(mod, original_method, method_sig, original_visibility, method_sig.return_type.raw_type,
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
arg_types[0][1].raw_type,
|
33
|
+
arg_types[1][1].raw_type,
|
34
|
+
arg_types[2][1].raw_type,
|
35
|
+
arg_types[3][1].raw_type)
|
34
36
|
else
|
35
37
|
raise 'should not happen'
|
36
38
|
end
|
@@ -343,26 +345,28 @@ module T::Private::Methods::CallValidation
|
|
343
345
|
|
344
346
|
def self.create_validator_procedure_fast(mod, original_method, method_sig, original_visibility)
|
345
347
|
# trampoline to reduce stack frame size
|
346
|
-
|
348
|
+
arg_types = method_sig.arg_types
|
349
|
+
case arg_types.length
|
350
|
+
when 0
|
347
351
|
create_validator_procedure_fast0(mod, original_method, method_sig, original_visibility)
|
348
|
-
|
352
|
+
when 1
|
349
353
|
create_validator_procedure_fast1(mod, original_method, method_sig, original_visibility,
|
350
|
-
|
351
|
-
|
354
|
+
arg_types[0][1].raw_type)
|
355
|
+
when 2
|
352
356
|
create_validator_procedure_fast2(mod, original_method, method_sig, original_visibility,
|
353
|
-
|
354
|
-
|
355
|
-
|
357
|
+
arg_types[0][1].raw_type,
|
358
|
+
arg_types[1][1].raw_type)
|
359
|
+
when 3
|
356
360
|
create_validator_procedure_fast3(mod, original_method, method_sig, original_visibility,
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
+
arg_types[0][1].raw_type,
|
362
|
+
arg_types[1][1].raw_type,
|
363
|
+
arg_types[2][1].raw_type)
|
364
|
+
when 4
|
361
365
|
create_validator_procedure_fast4(mod, original_method, method_sig, original_visibility,
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
+
arg_types[0][1].raw_type,
|
367
|
+
arg_types[1][1].raw_type,
|
368
|
+
arg_types[2][1].raw_type,
|
369
|
+
arg_types[3][1].raw_type)
|
366
370
|
else
|
367
371
|
raise 'should not happen'
|
368
372
|
end
|
@@ -608,26 +612,28 @@ module T::Private::Methods::CallValidation
|
|
608
612
|
raise 'Should have used create_validator_procedure_medium'
|
609
613
|
end
|
610
614
|
# trampoline to reduce stack frame size
|
611
|
-
|
615
|
+
arg_types = method_sig.arg_types
|
616
|
+
case arg_types.length
|
617
|
+
when 0
|
612
618
|
create_validator_method_medium0(mod, original_method, method_sig, original_visibility, method_sig.return_type)
|
613
|
-
|
619
|
+
when 1
|
614
620
|
create_validator_method_medium1(mod, original_method, method_sig, original_visibility, method_sig.return_type,
|
615
|
-
|
616
|
-
|
621
|
+
arg_types[0][1])
|
622
|
+
when 2
|
617
623
|
create_validator_method_medium2(mod, original_method, method_sig, original_visibility, method_sig.return_type,
|
618
|
-
|
619
|
-
|
620
|
-
|
624
|
+
arg_types[0][1],
|
625
|
+
arg_types[1][1])
|
626
|
+
when 3
|
621
627
|
create_validator_method_medium3(mod, original_method, method_sig, original_visibility, method_sig.return_type,
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
628
|
+
arg_types[0][1],
|
629
|
+
arg_types[1][1],
|
630
|
+
arg_types[2][1])
|
631
|
+
when 4
|
626
632
|
create_validator_method_medium4(mod, original_method, method_sig, original_visibility, method_sig.return_type,
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
633
|
+
arg_types[0][1],
|
634
|
+
arg_types[1][1],
|
635
|
+
arg_types[2][1],
|
636
|
+
arg_types[3][1])
|
631
637
|
else
|
632
638
|
raise 'should not happen'
|
633
639
|
end
|
@@ -940,26 +946,28 @@ module T::Private::Methods::CallValidation
|
|
940
946
|
|
941
947
|
def self.create_validator_procedure_medium(mod, original_method, method_sig, original_visibility)
|
942
948
|
# trampoline to reduce stack frame size
|
943
|
-
|
949
|
+
arg_types = method_sig.arg_types
|
950
|
+
case arg_types.length
|
951
|
+
when 0
|
944
952
|
create_validator_procedure_medium0(mod, original_method, method_sig, original_visibility)
|
945
|
-
|
953
|
+
when 1
|
946
954
|
create_validator_procedure_medium1(mod, original_method, method_sig, original_visibility,
|
947
|
-
|
948
|
-
|
955
|
+
arg_types[0][1])
|
956
|
+
when 2
|
949
957
|
create_validator_procedure_medium2(mod, original_method, method_sig, original_visibility,
|
950
|
-
|
951
|
-
|
952
|
-
|
958
|
+
arg_types[0][1],
|
959
|
+
arg_types[1][1])
|
960
|
+
when 3
|
953
961
|
create_validator_procedure_medium3(mod, original_method, method_sig, original_visibility,
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
962
|
+
arg_types[0][1],
|
963
|
+
arg_types[1][1],
|
964
|
+
arg_types[2][1])
|
965
|
+
when 4
|
958
966
|
create_validator_procedure_medium4(mod, original_method, method_sig, original_visibility,
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
967
|
+
arg_types[0][1],
|
968
|
+
arg_types[1][1],
|
969
|
+
arg_types[2][1],
|
970
|
+
arg_types[3][1])
|
963
971
|
else
|
964
972
|
raise 'should not happen'
|
965
973
|
end
|
@@ -231,15 +231,17 @@ module T::Private::Methods
|
|
231
231
|
decl.on_failure = nil
|
232
232
|
end
|
233
233
|
if decl.params.equal?(ARG_NOT_PROVIDED)
|
234
|
-
decl.params =
|
234
|
+
decl.params = FROZEN_HASH
|
235
235
|
end
|
236
236
|
if decl.type_parameters.equal?(ARG_NOT_PROVIDED)
|
237
|
-
decl.type_parameters =
|
237
|
+
decl.type_parameters = FROZEN_HASH
|
238
238
|
end
|
239
239
|
|
240
240
|
decl.finalized = true
|
241
241
|
|
242
242
|
self
|
243
243
|
end
|
244
|
+
|
245
|
+
FROZEN_HASH = {}.freeze
|
244
246
|
end
|
245
247
|
end
|