sorbet-runtime 0.5.5820 → 0.5.5841

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: 8c19b71f3236547819e70d9a0f9682949196ae0b62b8b179071a36428b293972
4
- data.tar.gz: 4b16911c2dbc5794643b817ce516e8922fec7c842655971d6874a7cf0239be78
3
+ metadata.gz: 02df0e4234d0887f7584ed03f2efd4ceabe7cd2aad902a198617207b02d92a6a
4
+ data.tar.gz: 3cef81d70c297f03d9b6307c32c7c6b079e120ac5a92681ff371bb3d010205b8
5
5
  SHA512:
6
- metadata.gz: 6bf50afd1be733252dfc627d8a33c38c601f5eaf06cc46f8da7bf47f17ee37094852342f708ca6698acb6550c05e74f6fe096ebbe7bdc78a4f62153125df12ab
7
- data.tar.gz: 020b024b9eac659d2274707f1d2569ed59658edc5d1692c86eb8d07c97c80007ae1a58da49e50d9359a3f880e3a96d6487afb1ae0a93f6cbb01fd5dcec9126e5
6
+ metadata.gz: 6e0cb83492e866202da027d8f8a5800a52fb7f0e3e4353952ec0250b28122704ad1bc5317ebd30b388df247d0a353afa239393aeafe3421d100d81a5f5456c81
7
+ data.tar.gz: 6a8b52a3830af73aec07c37bd6afba1081fbd47fbe0d37601803a1ccd73fa1edd08d9fbb233bb9c0556d81baff8571f791e723e7c84f117622c5fcf42ec91e40
@@ -37,12 +37,12 @@ module T
37
37
  # Matches any object. In the static checker, T.untyped allows any
38
38
  # method calls or operations.
39
39
  def self.untyped
40
- T::Types::Untyped.new
40
+ T::Types::Untyped::Private::INSTANCE
41
41
  end
42
42
 
43
43
  # Indicates a function never returns (e.g. "Kernel#raise")
44
44
  def self.noreturn
45
- T::Types::NoReturn.new
45
+ T::Types::NoReturn::Private::INSTANCE
46
46
  end
47
47
 
48
48
  # T.all(<Type>, <Type>, ...) -- matches an object that has all of the types listed
@@ -62,12 +62,12 @@ module T
62
62
 
63
63
  # Matches `self`:
64
64
  def self.self_type
65
- T::Types::SelfType.new
65
+ T::Types::SelfType::Private::INSTANCE
66
66
  end
67
67
 
68
68
  # Matches the instance type in a singleton-class context
69
69
  def self.attached_class
70
- T::Types::AttachedClassType.new
70
+ T::Types::AttachedClassType::Private::INSTANCE
71
71
  end
72
72
 
73
73
  # Matches any class that subclasses or includes the provided class
@@ -10,7 +10,11 @@ module T::Profile
10
10
  def typecheck_duration_estimate
11
11
  total_typechecks = typecheck_samples * SAMPLE_RATE + (SAMPLE_RATE - typecheck_sample_attempts)
12
12
  typechecks_measured = typecheck_samples * SAMPLE_RATE
13
- typecheck_duration * SAMPLE_RATE * 1.0 * total_typechecks / typechecks_measured
13
+ if typechecks_measured.positive?
14
+ typecheck_duration * SAMPLE_RATE * 1.0 * total_typechecks / typechecks_measured
15
+ else
16
+ 0.0
17
+ end
14
18
  end
15
19
 
16
20
  def typecheck_count_estimate
@@ -17,11 +17,16 @@ module T::Props::Constructor::DecoratorMethods
17
17
  # checked(:never) - O(runtime object construction)
18
18
  sig {params(instance: T::Props::Constructor, hash: T::Hash[Symbol, T.untyped]).returns(Integer).checked(:never)}
19
19
  def construct_props_without_defaults(instance, hash)
20
- @props_without_defaults&.count do |p, setter_proc|
20
+ # Use `each_pair` rather than `count` because, as of Ruby 2.6, the latter delegates to Enumerator
21
+ # and therefore allocates for each entry.
22
+ result = 0
23
+ @props_without_defaults&.each_pair do |p, setter_proc|
21
24
  begin
22
25
  val = hash[p]
23
26
  instance.instance_exec(val, &setter_proc)
24
- val || hash.key?(p)
27
+ if val || hash.key?(p)
28
+ result += 1
29
+ end
25
30
  rescue TypeError, T::Props::InvalidValueError
26
31
  if !hash.key?(p)
27
32
  raise ArgumentError.new("Missing required prop `#{p}` for class `#{instance.class.name}`")
@@ -29,6 +34,7 @@ module T::Props::Constructor::DecoratorMethods
29
34
  raise
30
35
  end
31
36
  end
32
- end || 0
37
+ end
38
+ result
33
39
  end
34
40
  end
@@ -30,14 +30,16 @@ module T::Props::WeakConstructor::DecoratorMethods
30
30
  # checked(:never) - O(runtime object construction)
31
31
  sig {params(instance: T::Props::WeakConstructor, hash: T::Hash[Symbol, T.untyped]).returns(Integer).checked(:never)}
32
32
  def construct_props_without_defaults(instance, hash)
33
- @props_without_defaults&.count do |p, setter_proc|
33
+ # Use `each_pair` rather than `count` because, as of Ruby 2.6, the latter delegates to Enumerator
34
+ # and therefore allocates for each entry.
35
+ result = 0
36
+ @props_without_defaults&.each_pair do |p, setter_proc|
34
37
  if hash.key?(p)
35
38
  instance.instance_exec(hash[p], &setter_proc)
36
- true
37
- else
38
- false
39
+ result += 1
39
40
  end
40
- end || 0
41
+ end
42
+ result
41
43
  end
42
44
 
43
45
  # Set values for all props that have defaults. Use the default if and only if
@@ -49,14 +51,17 @@ module T::Props::WeakConstructor::DecoratorMethods
49
51
  # checked(:never) - O(runtime object construction)
50
52
  sig {params(instance: T::Props::WeakConstructor, hash: T::Hash[Symbol, T.untyped]).returns(Integer).checked(:never)}
51
53
  def construct_props_with_defaults(instance, hash)
52
- @props_with_defaults&.count do |p, default_struct|
54
+ # Use `each_pair` rather than `count` because, as of Ruby 2.6, the latter delegates to Enumerator
55
+ # and therefore allocates for each entry.
56
+ result = 0
57
+ @props_with_defaults&.each_pair do |p, default_struct|
53
58
  if hash.key?(p)
54
59
  instance.instance_exec(hash[p], &default_struct.setter_proc)
55
- true
60
+ result += 1
56
61
  else
57
62
  default_struct.set_default(instance)
58
- false
59
63
  end
60
- end || 0
64
+ end
65
+ result
61
66
  end
62
67
  end
@@ -29,5 +29,9 @@ module T::Types
29
29
  false
30
30
  end
31
31
  end
32
+
33
+ module Private
34
+ INSTANCE = AttachedClassType.new.freeze
35
+ end
32
36
  end
33
37
  end
@@ -21,5 +21,9 @@ module T::Types
21
21
  private def subtype_of_single?(other)
22
22
  true
23
23
  end
24
+
25
+ module Private
26
+ INSTANCE = NoReturn.new.freeze
27
+ end
24
28
  end
25
29
  end
@@ -27,5 +27,9 @@ module T::Types
27
27
  false
28
28
  end
29
29
  end
30
+
31
+ module Private
32
+ INSTANCE = SelfType.new.freeze
33
+ end
30
34
  end
31
35
  end
@@ -44,11 +44,7 @@ module T::Types
44
44
 
45
45
  # @override Base
46
46
  def valid?(obj)
47
- @types.each do |type|
48
- return true if type.valid?(obj)
49
- end
50
-
51
- false
47
+ @types.any? {|type| type.valid?(obj)}
52
48
  end
53
49
 
54
50
  # @override Base
@@ -21,5 +21,9 @@ module T::Types
21
21
  private def subtype_of_single?(other)
22
22
  true
23
23
  end
24
+
25
+ module Private
26
+ INSTANCE = Untyped.new.freeze
27
+ end
24
28
  end
25
29
  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.5820
4
+ version: 0.5.5841
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-15 00:00:00.000000000 Z
11
+ date: 2020-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest