sorbet-runtime 0.5.6393 → 0.5.6401

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: 7fbf46d63aaa9683a0f5cc9b37bd9508119fe5eb01f76f34edee83b9fda3dbb8
4
- data.tar.gz: a5cba0e8924ef62d48ba29b717299fcfd03988336964c13f03c9a2dbdb311e5b
3
+ metadata.gz: 3baf5e6dbee3cab2198e345e42c1875e2336646b30a189992a9c2e3e129ca53b
4
+ data.tar.gz: c6a0eca3846188cc89e8ec44474907b27cb29fa6281fd2a93719e488a776697b
5
5
  SHA512:
6
- metadata.gz: 74becf00b4cd97520b801b09174f154b50211826cf38eba103342e7c7827cd380134ceaa804ee7fdaf2ca79750ab242362643798a07d8dee00413bf4f80c1d30
7
- data.tar.gz: b59514f9e53afa11a6eb1c954d079a155aefd13ce9f78dadb90dd1a0ada42e0f85012276f762759436d3abf932edf7b2a0226708c882842ee170fd24ecf2e196
6
+ metadata.gz: 7250061e134ee0d2ae8ccf0162610491853702164a02698962c09ba13246bc2aa779d676e95090e21338a0be22a159245d53414f95bd9186a096131736c1d7ba
7
+ data.tar.gz: 1a26c625cbd6f7a3621c6d1a715182ca7b487485aa822de10f5f32d659ce4b743bb44ce14ae0596a9e788c68398f9ac36ab2bb3445b88c5f670912708fd76b17
data/lib/types/_types.rb CHANGED
@@ -147,6 +147,25 @@ module T
147
147
  Private::Casts.cast(value, type, cast_method: "T.let")
148
148
  end
149
149
 
150
+ # Tells the type checker to treat `self` in the current block as `type`.
151
+ # Useful for blocks that are captured and executed later with instance_exec.
152
+ # Use like:
153
+ #
154
+ # seconds = lambda do
155
+ # T.bind(self, NewBinding)
156
+ # ...
157
+ # end
158
+ #
159
+ # `T.bind` behaves like `T.cast` in that it is assumed to be true statically.
160
+ #
161
+ # If `checked` is true, raises an exception at runtime if the value
162
+ # doesn't match the type (this is the default).
163
+ def self.bind(value, type, checked: true)
164
+ return value unless checked
165
+
166
+ Private::Casts.cast(value, type, cast_method: "T.bind")
167
+ end
168
+
150
169
  # Tells the typechecker to ensure that `value` is of type `type` (if not, the typechecker will
151
170
  # fail). Use this for debugging typechecking errors, or to ensure that type information is
152
171
  # statically known and being checked appropriately. If `checked` is true, raises an exception at
@@ -181,7 +181,7 @@ module T::Private::Methods::SignatureValidation
181
181
  # arg types must be contravariant
182
182
  super_signature.arg_types.zip(signature.arg_types).each_with_index do |((_super_name, super_type), (name, type)), index|
183
183
  if !super_type.subtype_of?(type)
184
- raise "Incompatible type for arg ##{index + 1} (`#{name}`) in #{mode_noun} of method " \
184
+ raise "Incompatible type for arg ##{index + 1} (`#{name}`) in signature for #{mode_noun} of method " \
185
185
  "`#{signature.method_name}`:\n" \
186
186
  "* Base: `#{super_type}` (in #{method_loc_str(super_signature.method)})\n" \
187
187
  "* #{mode_noun.capitalize}: `#{type}` (in #{method_loc_str(signature.method)})\n" \
@@ -193,7 +193,7 @@ module T::Private::Methods::SignatureValidation
193
193
  super_signature.kwarg_types.each do |name, super_type|
194
194
  type = signature.kwarg_types[name]
195
195
  if !super_type.subtype_of?(type)
196
- raise "Incompatible type for arg `#{name}` in #{mode_noun} of method `#{signature.method_name}`:\n" \
196
+ raise "Incompatible type for arg `#{name}` in signature for #{mode_noun} of method `#{signature.method_name}`:\n" \
197
197
  "* Base: `#{super_type}` (in #{method_loc_str(super_signature.method)})\n" \
198
198
  "* #{mode_noun.capitalize}: `#{type}` (in #{method_loc_str(signature.method)})\n" \
199
199
  "(The types must be contravariant.)"
@@ -202,7 +202,7 @@ module T::Private::Methods::SignatureValidation
202
202
 
203
203
  # return types must be covariant
204
204
  if !signature.return_type.subtype_of?(super_signature.return_type)
205
- raise "Incompatible return type in #{mode_noun} of method `#{signature.method_name}`:\n" \
205
+ raise "Incompatible return type in signature for #{mode_noun} of method `#{signature.method_name}`:\n" \
206
206
  "* Base: `#{super_signature.return_type}` (in #{method_loc_str(super_signature.method)})\n" \
207
207
  "* #{mode_noun.capitalize}: `#{signature.return_type}` (in #{method_loc_str(signature.method)})\n" \
208
208
  "(The types must be covariant.)"
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.6393
4
+ version: 0.5.6401
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-28 00:00:00.000000000 Z
11
+ date: 2021-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest