sorbet-runtime 0.5.10894 → 0.5.10898

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e0e4ca50e40dba17d9e6525f9d45385b3e9323e1a0768501766dfaa16b55f50a
4
- data.tar.gz: d10b11ea6372bbdb52e16f384d8ed10d47319aab9815f88f0cfa3d4facb435f0
3
+ metadata.gz: 3e3ab9e95814ef422f4bf43b68d621a4729536f6fa50463e9e2af6aa5faf2e78
4
+ data.tar.gz: 77e0c25399ad50c72f0a10d159d808284bd137b203d138e4d1c6590d870d7bd8
5
5
  SHA512:
6
- metadata.gz: 196f8cd6fcc9c7adb30db052111187c41c7f6ea85aae010cc48bc5ea0149a1cd496547be98bc2a308c6d8307633e253fc680eec1e0352d840829658ab231ac3e
7
- data.tar.gz: deb86d5588fb3decdb5bb4826ebc0a2901b7b425cdeadfdb2f0436d92939c24978ca2004fbeb22459525dafd33e83a93ea0414cff23f691358407158819db9ae
6
+ metadata.gz: c9f7595af100b0883fbe66464d3341ebf6b3a60548b027fd381752db21f6e2f9526b6bdb85af89ac7ab98e6209fc8ccdb63962f4bad2fd8d24ff5a05ed3dbdb8
7
+ data.tar.gz: 9db28918c2cb24a1f16f16059002d590fce54a12c18fd1aad6dc03d503e905b5156fe916a8abeb1d26437194e371cd65637d9bbca52f9f02ff65bf3a7622ca24
@@ -39,8 +39,6 @@ class T::Private::Methods::Signature
39
39
  def initialize(method:, method_name:, raw_arg_types:, raw_return_type:, bind:, mode:, check_level:, on_failure:, parameters: method.parameters, override_allow_incompatible: false, defined_raw: false)
40
40
  @method = method
41
41
  @method_name = method_name
42
- @arg_types = []
43
- @kwarg_types = {}
44
42
  @block_type = nil
45
43
  @block_name = nil
46
44
  @rest_type = nil
@@ -51,8 +49,6 @@ class T::Private::Methods::Signature
51
49
  @bind = bind ? T::Utils.coerce(bind) : bind
52
50
  @mode = mode
53
51
  @check_level = check_level
54
- @req_arg_count = 0
55
- @req_kwarg_names = []
56
52
  @has_rest = false
57
53
  @has_keyrest = false
58
54
  @parameters = parameters
@@ -60,6 +56,12 @@ class T::Private::Methods::Signature
60
56
  @override_allow_incompatible = override_allow_incompatible
61
57
  @defined_raw = defined_raw
62
58
 
59
+ # Use T.untyped in lieu of T.nilable to try to avoid unnecessary allocations.
60
+ arg_types = T.let(nil, T.untyped)
61
+ kwarg_types = T.let(nil, T.untyped)
62
+ req_arg_count = 0
63
+ req_kwarg_names = T.let(nil, T.untyped)
64
+
63
65
  # If sig params are declared but there is a single parameter with a missing name
64
66
  # **and** the method ends with a "=", assume it is a writer method generated
65
67
  # by attr_writer or attr_accessor
@@ -109,7 +111,7 @@ class T::Private::Methods::Signature
109
111
 
110
112
  case param_kind
111
113
  when :req
112
- if @arg_types.length > @req_arg_count
114
+ if (arg_types ? arg_types.length : 0) > req_arg_count
113
115
  # Note that this is actually is supported by Ruby, but it would add complexity to
114
116
  # support it here, and I'm happy to discourage its use anyway.
115
117
  #
@@ -120,14 +122,14 @@ class T::Private::Methods::Signature
120
122
  # see this error. The simplest resolution is to rename your method.
121
123
  raise "Required params after optional params are not supported in method declarations. Method: #{method_desc}"
122
124
  end
123
- @arg_types << [param_name, type]
124
- @req_arg_count += 1
125
+ (arg_types ||= []) << [param_name, type]
126
+ req_arg_count += 1
125
127
  when :opt
126
- @arg_types << [param_name, type]
128
+ (arg_types ||= []) << [param_name, type]
127
129
  when :key, :keyreq
128
- @kwarg_types[param_name] = type
130
+ (kwarg_types ||= {})[param_name] = type
129
131
  if param_kind == :keyreq
130
- @req_kwarg_names << param_name
132
+ (req_kwarg_names ||= []) << param_name
131
133
  end
132
134
  when :block
133
135
  @block_name = param_name
@@ -146,6 +148,11 @@ class T::Private::Methods::Signature
146
148
 
147
149
  i += 1
148
150
  end
151
+
152
+ @arg_types = arg_types || EMPTY_LIST
153
+ @kwarg_types = kwarg_types || EMPTY_HASH
154
+ @req_arg_count = req_arg_count
155
+ @req_kwarg_names = req_kwarg_names || EMPTY_LIST
149
156
  end
150
157
 
151
158
  attr_writer :method_name
@@ -238,5 +245,6 @@ class T::Private::Methods::Signature
238
245
  "#{@method} at #{loc}"
239
246
  end
240
247
 
248
+ EMPTY_LIST = [].freeze
241
249
  EMPTY_HASH = {}.freeze
242
250
  end
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.10894
4
+ version: 0.5.10898
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-30 00:00:00.000000000 Z
11
+ date: 2023-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest