sorbet-runtime 0.5.10676 → 0.5.10679

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7af4dd278e99d924889ddfc3e61d864a109755a805bd516a0ec94b9af59226fd
4
- data.tar.gz: f09610bc852ac70b0fed6e6934b63c981aec7302e78cc1ae918c09018de6d062
3
+ metadata.gz: 10e2f25720f79e5e0ab5bfb00abc030dc87c73be629112c11d8844f89726a4a3
4
+ data.tar.gz: b05c04621a3779ded3f6000abaaf1a69aba85a4f73c3310e445d334e90f505c8
5
5
  SHA512:
6
- metadata.gz: 6c3b30eeaa8b157178a64a1c479e372e767baa2932d4da6e78ae0322fdb1691b82d28628f17f3a5f976ce25326fa77e0b14eb5390d075c9dac47ac57db2f55a1
7
- data.tar.gz: 4de95cdb730556c7401ab29b012b150e1a787cbe4e9fd65365f1d604f4c96d7375364eb31c5f85f2c84aa3ba5fba3a35056b8aebed270b138aec4c8945732c1e
6
+ metadata.gz: c87d22bce8fc6ccd7e001a54d625465a15a0a3d004a92d9cb2f7f2db233adbd339974bb281a242fa0fe4f2181b34201714da546bae40143e701480c6772cca97
7
+ data.tar.gz: 1756ba572c0bf4cd6a0915d1b085bb5fa2bc3cdfaced16babc0098c5750bab76829e5b8b1cef322418ee654363b3d0afc265f52b0f107d60e62d8210d208ada5
@@ -39,4 +39,17 @@ class T::Private::Types::SimplePairUnion < T::Types::Union
39
39
  T::Types::Simple::Private::Pool.type_for_module(@raw_b),
40
40
  ]
41
41
  end
42
+
43
+ # overrides Union
44
+ def unwrap_nilable
45
+ a_nil = @raw_a.equal?(NilClass)
46
+ b_nil = @raw_b.equal?(NilClass)
47
+ if a_nil
48
+ return types[1]
49
+ end
50
+ if b_nil
51
+ return types[0]
52
+ end
53
+ nil
54
+ end
42
55
  end
@@ -54,6 +54,12 @@ module T::Types
54
54
  return t1.aliased_type.subtype_of?(t2)
55
55
  end
56
56
 
57
+ if t1.is_a?(T::Types::TypeVariable) || t2.is_a?(T::Types::TypeVariable)
58
+ # Generics are erased at runtime. Let's treat them like `T.untyped` for
59
+ # the purpose of things like override checking.
60
+ return true
61
+ end
62
+
57
63
  # pairs to cover: 1 (_, _)
58
64
  # 2 (_, And)
59
65
  # 3 (_, Or)
@@ -64,6 +64,17 @@ module T::Types
64
64
  raise "This should never be reached if you're going through `subtype_of?` (and you should be)"
65
65
  end
66
66
 
67
+ def unwrap_nilable
68
+ non_nil_types = types.reject {|t| t == T::Utils::Nilable::NIL_TYPE}
69
+ return nil if types.length == non_nil_types.length
70
+ case non_nil_types.length
71
+ when 0 then nil
72
+ when 1 then non_nil_types.first
73
+ else
74
+ T::Types::Union::Private::Pool.union_of_types(non_nil_types[0], non_nil_types[1], non_nil_types[2..-1])
75
+ end
76
+ end
77
+
67
78
  module Private
68
79
  module Pool
69
80
  EMPTY_ARRAY = [].freeze
data/lib/types/utils.rb CHANGED
@@ -98,14 +98,7 @@ module T::Utils
98
98
  def self.unwrap_nilable(type)
99
99
  case type
100
100
  when T::Types::Union
101
- non_nil_types = type.types.reject {|t| t == Nilable::NIL_TYPE}
102
- return nil if type.types.length == non_nil_types.length
103
- case non_nil_types.length
104
- when 0 then nil
105
- when 1 then non_nil_types.first
106
- else
107
- T::Types::Union::Private::Pool.union_of_types(non_nil_types[0], non_nil_types[1], non_nil_types[2..-1])
108
- end
101
+ type.unwrap_nilable
109
102
  else
110
103
  nil
111
104
  end
@@ -179,7 +172,7 @@ module T::Utils
179
172
 
180
173
  def self.get_type_info(prop_type)
181
174
  if prop_type.is_a?(T::Types::Union)
182
- non_nilable_type = T::Utils.unwrap_nilable(prop_type)
175
+ non_nilable_type = prop_type.unwrap_nilable
183
176
  if non_nilable_type&.is_a?(T::Types::Simple)
184
177
  non_nilable_type = non_nilable_type.raw_type
185
178
  end
@@ -193,9 +186,12 @@ module T::Utils
193
186
  # - if the type is A, the function returns A
194
187
  # - if the type is T.nilable(A), the function returns A
195
188
  def self.get_underlying_type(prop_type)
196
- type_info = get_type_info(prop_type)
197
- if type_info.is_union_type
198
- type_info.non_nilable_type || prop_type
189
+ if prop_type.is_a?(T::Types::Union)
190
+ non_nilable_type = prop_type.unwrap_nilable
191
+ if non_nilable_type&.is_a?(T::Types::Simple)
192
+ non_nilable_type = non_nilable_type.raw_type
193
+ end
194
+ non_nilable_type || prop_type
199
195
  elsif prop_type.is_a?(T::Types::Simple)
200
196
  prop_type.raw_type
201
197
  else
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.10676
4
+ version: 0.5.10679
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-18 00:00:00.000000000 Z
11
+ date: 2023-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest