sorbet-runtime 0.6.13192 → 0.6.13196
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/sorbet-runtime.rb +1 -0
- data/lib/types/configuration.rb +1 -1
- data/lib/types/private/abstract/validate.rb +4 -4
- data/lib/types/private/casts.rb +1 -1
- data/lib/types/private/class_utils.rb +4 -1
- data/lib/types/private/final.rb +4 -4
- data/lib/types/private/methods/_methods.rb +30 -14
- data/lib/types/private/methods/call_validation.rb +3 -3
- data/lib/types/private/methods/decl_builder.rb +3 -2
- data/lib/types/private/methods/signature.rb +19 -8
- data/lib/types/private/methods/signature_validation.rb +2 -2
- data/lib/types/private/runtime_levels.rb +1 -1
- data/lib/types/private/sealed.rb +3 -3
- data/lib/types/sig.rb +1 -1
- data/lib/types/types/fixed_array.rb +3 -3
- data/lib/types/types/simple.rb +6 -6
- data/lib/types/types/union.rb +1 -1
- data/lib/types/utils.rb +1 -1
- 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: 5b6b772ecaa9f6ce7788173f15073e96d619a88d575c72c36701e0f33b2f7796
|
|
4
|
+
data.tar.gz: e986c62848ac7bef03f533753b233d151167c285dc1011023dfff4378c74ae0c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 15840ef1936591b0b06fc987a1d53952e2ff5f3c0f83e3f8ed39da9a9a510c838b6aa9f451919262e39923f7f7af071b76e1b2b1323316038f2f8f84bfdb7be4
|
|
7
|
+
data.tar.gz: a9dcc51625a817d74cdc6be20cd7a66d6288df0b3d0628a66296c786859901c1f159cf9b33062c0a16cf653de2728e80d944b1438acbea7076c0cab9804e1079
|
data/lib/sorbet-runtime.rb
CHANGED
data/lib/types/configuration.rb
CHANGED
|
@@ -9,7 +9,7 @@ module T::Private::Abstract::Validate
|
|
|
9
9
|
|
|
10
10
|
def self.validate_abstract_module(mod)
|
|
11
11
|
type = Abstract::Data.get(mod, :abstract_type)
|
|
12
|
-
validate_interface(mod) if
|
|
12
|
+
validate_interface(mod) if :interface == type
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
# Validates a class/module with an abstract class/module as an ancestor. This must be called
|
|
@@ -56,7 +56,7 @@ module T::Private::Abstract::Validate
|
|
|
56
56
|
# signature and (b) methods from ancestors (note that these ancestors can come before or
|
|
57
57
|
# after the abstract module in the inheritance chain -- the former coming from
|
|
58
58
|
# walking `mod.ancestors` above).
|
|
59
|
-
abstract_signature = Methods.signature_for_method(abstract_method)
|
|
59
|
+
abstract_signature = Methods.signature_for_method(abstract_method) || raise("Method being abstract must imply it has a signature")
|
|
60
60
|
# We allow implementation methods to be defined without a signature.
|
|
61
61
|
# In that case, get its untyped signature.
|
|
62
62
|
implementation_signature ||= Methods::Signature.new_untyped(
|
|
@@ -111,8 +111,8 @@ module T::Private::Abstract::Validate
|
|
|
111
111
|
end
|
|
112
112
|
|
|
113
113
|
private_class_method def self.describe_method(method, show_owner: true)
|
|
114
|
-
loc = if method.source_location
|
|
115
|
-
|
|
114
|
+
loc = if (source_loc = method.source_location)
|
|
115
|
+
source_loc.join(':')
|
|
116
116
|
else
|
|
117
117
|
"<unknown location>"
|
|
118
118
|
end
|
data/lib/types/private/casts.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
# typed:
|
|
2
|
+
# typed: true
|
|
3
3
|
|
|
4
4
|
# Cut down version of Chalk::Tools::ClassUtils with only :replace_method functionality.
|
|
5
5
|
# Extracted to a separate namespace so the type system can be used standalone.
|
|
@@ -22,6 +22,9 @@ module T::Private::ClassUtils
|
|
|
22
22
|
# of these errors changed across Ruby VM versions, in ways that would sometimes
|
|
23
23
|
# cause tests to fail if they were dependent on hard coding errors).
|
|
24
24
|
mod.method(name)
|
|
25
|
+
# This is just to prove to Sorbet that this method raises.
|
|
26
|
+
# This line should be unreachable in practice due to the above call.
|
|
27
|
+
raise NameError.new("undefined method `#{name}' for class `#{mod}'")
|
|
25
28
|
end
|
|
26
29
|
end
|
|
27
30
|
|
data/lib/types/private/final.rb
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
# typed:
|
|
2
|
+
# typed: true
|
|
3
3
|
|
|
4
4
|
module T::Private::Final
|
|
5
5
|
module NoInherit
|
|
6
6
|
def inherited(arg)
|
|
7
7
|
super(arg)
|
|
8
|
-
raise "#{self} was declared as final and cannot be inherited"
|
|
8
|
+
Kernel.raise "#{self} was declared as final and cannot be inherited"
|
|
9
9
|
end
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
module NoIncludeExtend
|
|
13
13
|
def included(arg)
|
|
14
14
|
super(arg)
|
|
15
|
-
raise "#{self} was declared as final and cannot be included"
|
|
15
|
+
Kernel.raise "#{self} was declared as final and cannot be included"
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def extended(arg)
|
|
19
19
|
super(arg)
|
|
20
|
-
raise "#{self} was declared as final and cannot be extended"
|
|
20
|
+
Kernel.raise "#{self} was declared as final and cannot be extended"
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
23
|
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
# typed:
|
|
2
|
+
# typed: true
|
|
3
3
|
|
|
4
4
|
module T::Private::Methods
|
|
5
5
|
@installed_hooks = {}
|
|
6
6
|
if defined?(Concurrent::Hash)
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
# Hide the Concurrent::Hash so that we get better typing by lying and saying it's a Hash
|
|
8
|
+
instance_variable_set(:@signatures_by_method, Concurrent::Hash.new)
|
|
9
|
+
instance_variable_set(:@sig_wrappers, Concurrent::Hash.new)
|
|
9
10
|
else
|
|
10
11
|
@signatures_by_method = {}
|
|
11
12
|
@sig_wrappers = {}
|
|
@@ -31,8 +32,15 @@ module T::Private::Methods
|
|
|
31
32
|
# in installed_hooks.
|
|
32
33
|
@old_hooks = nil
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
# These names are for backwards compatibility from when these were `Object.new` instances
|
|
36
|
+
# rubocop:disable Naming/ClassAndModuleCamelCase
|
|
37
|
+
module ARG_NOT_PROVIDED
|
|
38
|
+
freeze
|
|
39
|
+
end
|
|
40
|
+
module PROC_TYPE
|
|
41
|
+
freeze
|
|
42
|
+
end
|
|
43
|
+
# rubocop:enable Naming/ClassAndModuleCamelCase
|
|
36
44
|
|
|
37
45
|
# blk_or_decl:
|
|
38
46
|
# - It's a `Proc` if we haven't forced the thunk yet.
|
|
@@ -50,7 +58,7 @@ module T::Private::Methods
|
|
|
50
58
|
|
|
51
59
|
# See tests for how to use this. But you shouldn't be using this.
|
|
52
60
|
def self._declare_sig(mod, arg=nil, &blk)
|
|
53
|
-
_declare_sig_internal(mod, caller_locations(1, 1)
|
|
61
|
+
_declare_sig_internal(mod, caller_locations(1, 1)&.first, arg, raw: true, &blk)
|
|
54
62
|
end
|
|
55
63
|
|
|
56
64
|
private_class_method def self._declare_sig_internal(mod, loc, arg, raw: false, &blk)
|
|
@@ -112,7 +120,9 @@ module T::Private::Methods
|
|
|
112
120
|
|
|
113
121
|
# Fetch the directory name of the file that defines the `T::Private` constant and
|
|
114
122
|
# add a trailing slash to allow us to match it as a directory prefix.
|
|
115
|
-
|
|
123
|
+
sorbet_runtime_loc = T.const_source_location(:Private)
|
|
124
|
+
raise "T::Private constant location not found" unless sorbet_runtime_loc
|
|
125
|
+
SORBET_RUNTIME_LIB_PATH = File.dirname(sorbet_runtime_loc.first) + File::SEPARATOR
|
|
116
126
|
private_constant :SORBET_RUNTIME_LIB_PATH
|
|
117
127
|
|
|
118
128
|
# when target includes a module with instance methods source_method_names, ensure there is zero intersection between
|
|
@@ -123,6 +133,10 @@ module T::Private::Methods
|
|
|
123
133
|
# names that were declared final at one point.
|
|
124
134
|
def self._check_final_ancestors(target, target_ancestors, source_method_names, source)
|
|
125
135
|
source_ancestors = nil
|
|
136
|
+
if T::Private::IS_TYPECHECKING
|
|
137
|
+
# Need to avoid a pinning error, but don't want to use runtime types in _methods.rb
|
|
138
|
+
source_ancestors = T.let(nil, T.nilable(T::Array[T::Module[T.anything]]))
|
|
139
|
+
end
|
|
126
140
|
# use reverse_each to check farther-up ancestors first, for better error messages.
|
|
127
141
|
target_ancestors.reverse_each do |ancestor|
|
|
128
142
|
final_methods = @modules_with_final.fetch(ancestor, nil)
|
|
@@ -154,7 +168,8 @@ module T::Private::Methods
|
|
|
154
168
|
next if defining_ancestor_idx && source_ancestors[defining_ancestor_idx] == ancestor
|
|
155
169
|
end
|
|
156
170
|
|
|
157
|
-
|
|
171
|
+
final_sig = T::Private::Methods.signature_for_method(ancestor.instance_method(method_name))
|
|
172
|
+
definition_file, definition_line = final_sig&.method&.source_location
|
|
158
173
|
is_redefined = target == ancestor
|
|
159
174
|
caller_loc = T::Private::CallerUtils.find_caller { |loc| !loc.path.to_s.start_with?(SORBET_RUNTIME_LIB_PATH) }
|
|
160
175
|
extra_info = "\n"
|
|
@@ -247,7 +262,7 @@ module T::Private::Methods
|
|
|
247
262
|
method_sig ||= T::Private::Methods._handle_missing_method_signature(
|
|
248
263
|
self,
|
|
249
264
|
original_method,
|
|
250
|
-
__callee__,
|
|
265
|
+
__callee__ || raise("Unknown __callee__ for method without a signature"),
|
|
251
266
|
)
|
|
252
267
|
|
|
253
268
|
# Should be the same logic as CallValidation.wrap_method_if_needed but we
|
|
@@ -392,7 +407,7 @@ module T::Private::Methods
|
|
|
392
407
|
SignatureValidation.validate(signature)
|
|
393
408
|
signature
|
|
394
409
|
rescue => e
|
|
395
|
-
super_method = original_method
|
|
410
|
+
super_method = original_method.super_method
|
|
396
411
|
super_signature = signature_for_method(super_method) if super_method
|
|
397
412
|
|
|
398
413
|
T::Configuration.sig_validation_error_handler(
|
|
@@ -490,8 +505,9 @@ module T::Private::Methods
|
|
|
490
505
|
|
|
491
506
|
def self.run_all_sig_blocks(force_type_init: true)
|
|
492
507
|
loop do
|
|
493
|
-
|
|
494
|
-
|
|
508
|
+
first_wrapper = @sig_wrappers.first
|
|
509
|
+
break unless first_wrapper
|
|
510
|
+
key, = first_wrapper
|
|
495
511
|
run_sig_block_for_key(key, force_type_init: force_type_init)
|
|
496
512
|
end
|
|
497
513
|
end
|
|
@@ -565,14 +581,14 @@ module T::Private::Methods
|
|
|
565
581
|
|
|
566
582
|
module MethodHooks
|
|
567
583
|
def method_added(name)
|
|
568
|
-
::T::Private::Methods._on_method_added(self, self, name)
|
|
584
|
+
::T::Private::Methods._on_method_added(T.unsafe(self), T.unsafe(self), name)
|
|
569
585
|
super(name)
|
|
570
586
|
end
|
|
571
587
|
end
|
|
572
588
|
|
|
573
589
|
module SingletonMethodHooks
|
|
574
590
|
def singleton_method_added(name)
|
|
575
|
-
::T::Private::Methods._on_method_added(self, singleton_class, name)
|
|
591
|
+
::T::Private::Methods._on_method_added(T.unsafe(self), singleton_class, name)
|
|
576
592
|
super(name)
|
|
577
593
|
end
|
|
578
594
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
# typed:
|
|
2
|
+
# typed: true
|
|
3
3
|
|
|
4
4
|
module T::Private::Methods::CallValidation
|
|
5
5
|
CallValidation = T::Private::Methods::CallValidation
|
|
@@ -139,7 +139,7 @@ module T::Private::Methods::CallValidation
|
|
|
139
139
|
# reduce number of allocations that happen here.
|
|
140
140
|
|
|
141
141
|
if method_sig.bind
|
|
142
|
-
message = method_sig.bind
|
|
142
|
+
message = method_sig.bind&.error_message_for_obj(instance)
|
|
143
143
|
if message
|
|
144
144
|
CallValidation.report_error(
|
|
145
145
|
method_sig,
|
|
@@ -338,7 +338,7 @@ module T::Private::Methods::CallValidation
|
|
|
338
338
|
end
|
|
339
339
|
|
|
340
340
|
pretty_message = "#{kind}#{name ? " '#{name}'" : ''}: #{error_message}\n" \
|
|
341
|
-
"Caller: #{caller_loc
|
|
341
|
+
"Caller: #{caller_loc&.path}:#{caller_loc&.lineno}\n" \
|
|
342
342
|
"Definition: #{definition_file}:#{definition_line} (#{pretty_method_name})"
|
|
343
343
|
|
|
344
344
|
T::Configuration.call_validation_error_handler(
|
|
@@ -208,7 +208,7 @@ module T::Private::Methods
|
|
|
208
208
|
check_live!
|
|
209
209
|
|
|
210
210
|
names.each do |name|
|
|
211
|
-
raise BuilderError.new("not a symbol: #{name}") unless name
|
|
211
|
+
raise BuilderError.new("not a symbol: #{name}") unless Symbol === name
|
|
212
212
|
end
|
|
213
213
|
|
|
214
214
|
if !decl.type_parameters.equal?(ARG_NOT_PROVIDED)
|
|
@@ -237,7 +237,7 @@ module T::Private::Methods
|
|
|
237
237
|
decl.params = FROZEN_HASH
|
|
238
238
|
end
|
|
239
239
|
if decl.type_parameters.equal?(ARG_NOT_PROVIDED)
|
|
240
|
-
decl.type_parameters =
|
|
240
|
+
decl.type_parameters = FROZEN_ARRAY
|
|
241
241
|
end
|
|
242
242
|
|
|
243
243
|
decl.finalized = true
|
|
@@ -246,5 +246,6 @@ module T::Private::Methods
|
|
|
246
246
|
end
|
|
247
247
|
|
|
248
248
|
FROZEN_HASH = {}.freeze
|
|
249
|
+
FROZEN_ARRAY = [].freeze
|
|
249
250
|
end
|
|
250
251
|
end
|
|
@@ -8,7 +8,13 @@ class T::Private::Methods::Signature
|
|
|
8
8
|
:check_level, :parameters, :on_failure, :override_allow_incompatible,
|
|
9
9
|
:defined_raw
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
# T.unsafe: `UnboundMethod#parameters` lies and says `T::Array[[Symbol, Symbol]]`.
|
|
12
|
+
# Sorbet can't lub tuple types, meaning that `T.any([Symbol], [Symbol,
|
|
13
|
+
# Symbol])` would just be `T::Array[T.untyped]`. But Sorbet can see that
|
|
14
|
+
# UNNAMED_REQUIRED_PARAMETERS, which is an array of 1-tuples, can never
|
|
15
|
+
# equal an array of 2-tuples, and calls the code dead. There's no good
|
|
16
|
+
# option, let's just unsafe until tuples are better and we can fix the sig.
|
|
17
|
+
UNNAMED_REQUIRED_PARAMETERS = T.unsafe([[:req]].freeze)
|
|
12
18
|
|
|
13
19
|
def self.new_untyped(method:, mode: T::Private::Methods::Modes.untyped, parameters: method.parameters)
|
|
14
20
|
# Using `NotTyped` ensures we'll get an error if we ever try validation on these.
|
|
@@ -16,7 +22,7 @@ class T::Private::Methods::Signature
|
|
|
16
22
|
raw_return_type = not_typed
|
|
17
23
|
# Map missing parameter names to "argN" positionally
|
|
18
24
|
parameters = parameters.each_with_index.map do |(param_kind, param_name), index|
|
|
19
|
-
[param_kind, param_name || "arg#{index}"]
|
|
25
|
+
[param_kind, T.unsafe(param_name) || "arg#{index}".to_sym]
|
|
20
26
|
end
|
|
21
27
|
raw_arg_types = {}
|
|
22
28
|
parameters.each do |_, param_name|
|
|
@@ -52,7 +58,7 @@ class T::Private::Methods::Signature
|
|
|
52
58
|
else
|
|
53
59
|
@return_type
|
|
54
60
|
end
|
|
55
|
-
@bind = bind ? T::Utils.coerce(bind)
|
|
61
|
+
@bind = NilClass.===(bind) ? bind : T::Utils.coerce(bind)
|
|
56
62
|
@mode = mode
|
|
57
63
|
@check_level = check_level
|
|
58
64
|
@parameters = parameters
|
|
@@ -61,10 +67,15 @@ class T::Private::Methods::Signature
|
|
|
61
67
|
@defined_raw = defined_raw
|
|
62
68
|
|
|
63
69
|
# Use T.untyped in lieu of T.nilable to try to avoid unnecessary allocations.
|
|
64
|
-
arg_types =
|
|
65
|
-
kwarg_types =
|
|
70
|
+
arg_types = nil
|
|
71
|
+
kwarg_types = nil
|
|
72
|
+
req_kwarg_names = nil
|
|
73
|
+
if T::Private::IS_TYPECHECKING
|
|
74
|
+
arg_types = T.let(nil, T.nilable(T::Array[[Symbol, T::Types::Base]]))
|
|
75
|
+
kwarg_types = T.let(nil, T.nilable(T::Hash[Symbol, T::Types::Base]))
|
|
76
|
+
req_kwarg_names = T.let(nil, T.nilable(T::Array[Symbol]))
|
|
77
|
+
end
|
|
66
78
|
req_arg_count = 0
|
|
67
|
-
req_kwarg_names = T.let(nil, T.untyped)
|
|
68
79
|
|
|
69
80
|
# If sig params are declared but there is a single parameter with a missing name
|
|
70
81
|
# **and** the method ends with a "=", assume it is a writer method generated
|
|
@@ -91,7 +102,7 @@ class T::Private::Methods::Signature
|
|
|
91
102
|
end
|
|
92
103
|
i = 0
|
|
93
104
|
raw_arg_types.each do |type_name, raw_type|
|
|
94
|
-
param_kind, param_name = parameters
|
|
105
|
+
param_kind, param_name = parameters.fetch(i)
|
|
95
106
|
|
|
96
107
|
if type_name != param_name
|
|
97
108
|
hint = ""
|
|
@@ -107,7 +118,7 @@ class T::Private::Methods::Signature
|
|
|
107
118
|
|
|
108
119
|
raise "Parameter `#{type_name}` is declared out of order (declared as arg number " \
|
|
109
120
|
"#{i + 1}, defined in the method as arg number " \
|
|
110
|
-
"#{parameters.index { |_, name| name == type_name } + 1}).#{hint}\nMethod: #{method_desc}"
|
|
121
|
+
"#{T.must(parameters.index { |_, name| name == type_name }) + 1}).#{hint}\nMethod: #{method_desc}"
|
|
111
122
|
end
|
|
112
123
|
|
|
113
124
|
type = T::Utils.coerce(raw_type)
|
|
@@ -168,7 +168,7 @@ module T::Private::Methods::SignatureValidation
|
|
|
168
168
|
# for any class.
|
|
169
169
|
owner = signature.method.owner
|
|
170
170
|
if (signature.mode == Modes.abstract || Modes::OVERRIDABLE_MODES.include?(signature.mode)) &&
|
|
171
|
-
owner.singleton_class? && owner.superclass == Module
|
|
171
|
+
owner.singleton_class? && Class === owner && owner.superclass == Module
|
|
172
172
|
raise "Defining an overridable class method (via #{pretty_mode(signature)}) " \
|
|
173
173
|
"on a module is not allowed. Class methods on " \
|
|
174
174
|
"modules do not get inherited and thus cannot be overridden."
|
|
@@ -312,7 +312,7 @@ module T::Private::Methods::SignatureValidation
|
|
|
312
312
|
private_constant :METHOD_VISIBILITIES
|
|
313
313
|
|
|
314
314
|
private_class_method def self.visibility_strength(vis)
|
|
315
|
-
METHOD_VISIBILITIES.find_index(vis)
|
|
315
|
+
METHOD_VISIBILITIES.find_index(vis) || raise("Unexpected visibility `#{vis}`")
|
|
316
316
|
end
|
|
317
317
|
|
|
318
318
|
private_class_method def self.base_override_loc_str(signature, super_signature)
|
|
@@ -32,7 +32,7 @@ module T::Private::RuntimeLevels
|
|
|
32
32
|
def self.enable_checking_in_tests
|
|
33
33
|
if !@check_tests && @wrapped_tests_with_validation
|
|
34
34
|
all_checked_tests_sigs = T::Private::Methods.all_checked_tests_sigs
|
|
35
|
-
locations = all_checked_tests_sigs.map { |sig| sig.method.source_location
|
|
35
|
+
locations = all_checked_tests_sigs.map { |sig| sig.method.source_location&.join(':') }.join("\n- ")
|
|
36
36
|
raise "Toggle `:tests`-level runtime type checking earlier. " \
|
|
37
37
|
"There are already some methods wrapped with `sig.checked(:tests)`:\n" \
|
|
38
38
|
"- #{locations}"
|
data/lib/types/private/sealed.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
# typed:
|
|
2
|
+
# typed: true
|
|
3
3
|
|
|
4
4
|
module T::Private::Sealed
|
|
5
5
|
module NoInherit
|
|
@@ -13,7 +13,7 @@ module T::Private::Sealed
|
|
|
13
13
|
def sealed_subclasses
|
|
14
14
|
@sorbet_sealed_module_all_subclasses_set ||= # rubocop:disable Naming/MemoizedInstanceVariableName
|
|
15
15
|
begin
|
|
16
|
-
require 'set'
|
|
16
|
+
Kernel.require 'set'
|
|
17
17
|
Set.new(@sorbet_sealed_module_all_subclasses).freeze
|
|
18
18
|
end
|
|
19
19
|
end
|
|
@@ -40,7 +40,7 @@ module T::Private::Sealed
|
|
|
40
40
|
# else will add to it
|
|
41
41
|
@sorbet_sealed_module_all_subclasses_set ||= # rubocop:disable Naming/MemoizedInstanceVariableName
|
|
42
42
|
begin
|
|
43
|
-
require 'set'
|
|
43
|
+
Kernel.require 'set'
|
|
44
44
|
Set.new(@sorbet_sealed_module_all_subclasses).freeze
|
|
45
45
|
end
|
|
46
46
|
end
|
data/lib/types/sig.rb
CHANGED
|
@@ -25,6 +25,6 @@ module T::Sig
|
|
|
25
25
|
# {T::Helpers}
|
|
26
26
|
T::Sig::WithoutRuntime.sig { params(arg0: T.nilable(Symbol), blk: T.proc.bind(T::Private::Methods::DeclBuilder).void).void }
|
|
27
27
|
def sig(arg0=nil, &blk)
|
|
28
|
-
T::Private::Methods.declare_sig(self, Kernel.caller_locations(1, 1)&.first, arg0, &blk)
|
|
28
|
+
T::Private::Methods.declare_sig(T.unsafe(self), Kernel.caller_locations(1, 1)&.first, arg0, &blk)
|
|
29
29
|
end
|
|
30
30
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
# https://jira.corp.stripe.com/browse/RUBYPLAT-1107
|
|
3
|
-
# typed:
|
|
3
|
+
# typed: true
|
|
4
4
|
|
|
5
5
|
module T::Types
|
|
6
6
|
# Takes a list of types. Validates each item in an array using the type in the same position
|
|
@@ -29,7 +29,7 @@ module T::Types
|
|
|
29
29
|
if obj.is_a?(Array) && obj.length == types.length
|
|
30
30
|
i = 0
|
|
31
31
|
while i < types.length
|
|
32
|
-
if !types
|
|
32
|
+
if !types.fetch(i).recursively_valid?(obj[i])
|
|
33
33
|
return false
|
|
34
34
|
end
|
|
35
35
|
i += 1
|
|
@@ -45,7 +45,7 @@ module T::Types
|
|
|
45
45
|
if obj.is_a?(Array) && obj.length == types.length
|
|
46
46
|
i = 0
|
|
47
47
|
while i < types.length
|
|
48
|
-
if !types
|
|
48
|
+
if !types.fetch(i).valid?(obj[i])
|
|
49
49
|
return false
|
|
50
50
|
end
|
|
51
51
|
i += 1
|
data/lib/types/types/simple.rb
CHANGED
|
@@ -91,17 +91,17 @@ module T::Types
|
|
|
91
91
|
return cached if cached
|
|
92
92
|
|
|
93
93
|
type = if mod == ::Array
|
|
94
|
-
|
|
94
|
+
TypedArray::Untyped::Private::INSTANCE
|
|
95
95
|
elsif mod == ::Hash
|
|
96
|
-
|
|
96
|
+
TypedHash::Untyped.new
|
|
97
97
|
elsif mod == ::Enumerable
|
|
98
|
-
|
|
98
|
+
TypedEnumerable::Untyped.new
|
|
99
99
|
elsif mod == ::Enumerator
|
|
100
|
-
|
|
100
|
+
TypedEnumerator::Untyped.new
|
|
101
101
|
elsif mod == ::Range
|
|
102
|
-
|
|
102
|
+
TypedRange.new(type)
|
|
103
103
|
elsif !Object.autoload?(:Set) && Object.const_defined?(:Set) && mod == ::Set
|
|
104
|
-
|
|
104
|
+
TypedSet::Untyped.new
|
|
105
105
|
else
|
|
106
106
|
# ideally we would have a case mapping from ::Class -> T::Class and
|
|
107
107
|
# ::Module -> T::Module here but for backwards compatibility we
|
data/lib/types/types/union.rb
CHANGED
|
@@ -39,7 +39,7 @@ module T::Types
|
|
|
39
39
|
# evades Sorbet's static check and we end up on the slow path, or if someone
|
|
40
40
|
# is using the T:Types::Union constructor directly (the latter possibility
|
|
41
41
|
# is why we don't just move the `uniq` into `Private::Pool.union_of_types`).
|
|
42
|
-
return types
|
|
42
|
+
return types.fetch(0).name
|
|
43
43
|
end
|
|
44
44
|
nilable = T::Utils.coerce(NilClass)
|
|
45
45
|
trueclass = T::Utils.coerce(TrueClass)
|
data/lib/types/utils.rb
CHANGED
|
@@ -133,7 +133,7 @@ module T::Utils
|
|
|
133
133
|
# @return [String]
|
|
134
134
|
#
|
|
135
135
|
def self.string_truncate_middle(str, start_len, end_len, ellipsis='...')
|
|
136
|
-
return unless str
|
|
136
|
+
return str unless str
|
|
137
137
|
|
|
138
138
|
raise ArgumentError.new('must provide start_len') unless start_len
|
|
139
139
|
raise ArgumentError.new('must provide end_len') unless end_len
|
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.6.
|
|
4
|
+
version: 0.6.13196
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Stripe
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-05-
|
|
11
|
+
date: 2026-05-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: benchmark
|