sorbet-runtime 0.5.9542 → 0.5.9579

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/types/props/decorator.rb +19 -1
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 05be982509e317b254ad35e213cf6a9e0c1ff18b257ef0761587c067c3a6db96
4
- data.tar.gz: 683282ca3d466ee2b8b81c63c60206de17bb7455297456e0e33c7b03d953cd39
3
+ metadata.gz: aa792dc9c36eb79dc26b94f4d3658a13dcfc00fb0a83644e593139f9a5fd2ebb
4
+ data.tar.gz: 2c25b5e84065c161417e40d07a7552cd0ae93a02c86e87588b1f253732209da8
5
5
  SHA512:
6
- metadata.gz: a5ad32ba78c48be474babcddbc804202e9b1c8b16c0f10562aad3cd5fda15461b82d34c70e1463c02f43d5d4e8b5107298e72f0c9f1911f25e8c8b5653f64bff
7
- data.tar.gz: e8fa16603d94f33f7cd10ee6ac42c54894a5a8737202bc86faa7faff85c2e5e441108e54a37295980e9e1aa9f1a16d7679d3439bc2a378afe0c63cf159cc18ee
6
+ metadata.gz: 0334f989646f8ba9cdcf20ef4e7417d386160eb0fc607b1af23f7e469c12e5e50ea960810518787a76c912e31f5256a78e0460a8b77b8173126836104cbebfc0
7
+ data.tar.gz: aa4861f175215f5871cfecbf9cdb4871f8d090f91f2e92717d247961e1d1b30b5f2eb0f73470489986bc922863da9ec85561ba112b43bc440b2f9e599aef06b1
@@ -277,6 +277,24 @@ class T::Props::Decorator
277
277
  end
278
278
  end
279
279
 
280
+ # Returns `true` when the type of the prop is nilable, or the field is typed
281
+ # as `T.untyped`, a `:default` is present in the rules hash, and its value is
282
+ # `nil`. The latter case is a workaround for explicitly not supporting the use
283
+ # of `T.nilable(T.untyped)`.
284
+ #
285
+ # checked(:never) - Rules hash is expensive to check
286
+ sig do
287
+ params(
288
+ cls: PropTypeOrClass,
289
+ rules: Rules,
290
+ )
291
+ .void
292
+ .checked(:never)
293
+ end
294
+ private def prop_nilable?(cls, rules)
295
+ T::Utils::Nilable.is_union_with_nilclass(cls) || (cls == T.untyped && rules.key?(:default) && rules[:default].nil?)
296
+ end
297
+
280
298
  # checked(:never) - Rules hash is expensive to check
281
299
  sig do
282
300
  params(
@@ -290,7 +308,7 @@ class T::Props::Decorator
290
308
  def prop_defined(name, cls, rules={})
291
309
  cls = T::Utils.resolve_alias(cls)
292
310
 
293
- if T::Utils::Nilable.is_union_with_nilclass(cls)
311
+ if prop_nilable?(cls, rules)
294
312
  # :_tnilable is introduced internally for performance purpose so that clients do not need to call
295
313
  # T::Utils::Nilable.is_tnilable(cls) again.
296
314
  # It is strictly internal: clients should always use T::Props::Utils.required_prop?() or
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.9542
4
+ version: 0.5.9579
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-22 00:00:00.000000000 Z
11
+ date: 2022-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest