sorbet-runtime 0.5.6397 → 0.5.6405

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: e22fe1a2ba1aac1478254198329fc7b30da44cd2db6fc7489734f308b428a6d1
4
- data.tar.gz: 89a386ff90ed3098d2e27f5133217294d02da33b39555c7e65cc15a2f2baee39
3
+ metadata.gz: 7a0e940eff3c6512780d4b148a716a80aaf446e4c92be4aa190f8f530d9a8b57
4
+ data.tar.gz: d467a3a10ede769405f44c92a62f50a8ed14d93249ad48128d6ffd89e94b9425
5
5
  SHA512:
6
- metadata.gz: 9d7259cc9f799ecc16fe64b2c67ac6f1a6d543a8887d4fad50c0c2c3eaf8c753f4c6b68557cc14e2beaf4552299488bc38a66ae78d41ab917812f112efd94965
7
- data.tar.gz: f7f49616b79dad873cc2433e52ef4c2dea6cdb47d236dfdefc3fc002fa10153d520c57096623b548650193832be585660199a0237bf06607a5d84bef3f6dfc14
6
+ metadata.gz: 8ddc56972dd9c2361b66af78d5c90e11437c27853027eb1e0d0373ef75a543a6534a9684b2605863d08dc170566381c60b52e0174534100409f702a92498b15b
7
+ data.tar.gz: b89a80c70a983f6a34695866d595b487bcbc0f931491814537cea570750974d4e43403d599d16fc481fa59da979dbbeda6216319593ada70bb913685e4bace49
@@ -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.)"
@@ -41,11 +41,26 @@ module T::Types
41
41
  module Private
42
42
  module Pool
43
43
  def self.type_for_module(mod)
44
- cached = mod.instance_variable_get(:@__as_sorbet_simple_type)
44
+ cached = mod.instance_variable_get(:@__as_sorbet_type)
45
45
  return cached if cached
46
46
 
47
- type = Simple.new(mod)
48
- mod.instance_variable_set(:@__as_sorbet_simple_type, type) unless mod.frozen?
47
+ type = if mod == ::Array
48
+ T::Array[T.untyped]
49
+ elsif mod == ::Set
50
+ T::Set[T.untyped]
51
+ elsif mod == ::Hash
52
+ T::Hash[T.untyped, T.untyped]
53
+ elsif mod == ::Enumerable
54
+ T::Enumerable[T.untyped]
55
+ elsif mod == ::Enumerator
56
+ T::Enumerator[T.untyped]
57
+ elsif mod == ::Range
58
+ T::Range[T.untyped]
59
+ else
60
+ Simple.new(mod)
61
+ end
62
+
63
+ mod.instance_variable_set(:@__as_sorbet_type, type) unless mod.frozen?
49
64
  type
50
65
  end
51
66
  end
@@ -8,12 +8,12 @@ module T::Types
8
8
 
9
9
  def initialize(types)
10
10
  @types = types.flat_map do |type|
11
- type = T::Utils.resolve_alias(type)
11
+ type = T::Utils.coerce(type)
12
12
  if type.is_a?(Union)
13
13
  # Simplify nested unions (mostly so `name` returns a nicer value)
14
14
  type.types
15
15
  else
16
- T::Utils.coerce(type)
16
+ type
17
17
  end
18
18
  end.uniq
19
19
  end
data/lib/types/utils.rb CHANGED
@@ -8,18 +8,6 @@ module T::Utils
8
8
  val.aliased_type
9
9
  elsif val.is_a?(T::Types::Base)
10
10
  val
11
- elsif val == ::Array
12
- T::Array[T.untyped]
13
- elsif val == ::Set
14
- T::Set[T.untyped]
15
- elsif val == ::Hash
16
- T::Hash[T.untyped, T.untyped]
17
- elsif val == ::Enumerable
18
- T::Enumerable[T.untyped]
19
- elsif val == ::Enumerator
20
- T::Enumerator[T.untyped]
21
- elsif val == ::Range
22
- T::Range[T.untyped]
23
11
  elsif val.is_a?(Module)
24
12
  T::Types::Simple::Private::Pool.type_for_module(val)
25
13
  elsif val.is_a?(::Array)
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.6397
4
+ version: 0.5.6405
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-01 00:00:00.000000000 Z
11
+ date: 2021-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest