sorbet-runtime 0.5.10782 → 0.5.10993

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+ # typed: true
3
+
4
+ module T::Types
5
+ class TypedClass < T::Types::Base
6
+ attr_reader :type
7
+
8
+ def initialize(type)
9
+ @type = T::Utils.coerce(type)
10
+ end
11
+
12
+ # overrides Base
13
+ def name
14
+ "T::Class[#{@type.name}]"
15
+ end
16
+
17
+ def underlying_class
18
+ Class
19
+ end
20
+
21
+ # overrides Base
22
+ def valid?(obj)
23
+ Class.===(obj)
24
+ end
25
+
26
+ # overrides Base
27
+ private def subtype_of_single?(type)
28
+ case type
29
+ when TypedClass
30
+ # treat like generics are erased
31
+ true
32
+ when Simple
33
+ Class <= type.raw_type
34
+ else
35
+ false
36
+ end
37
+ end
38
+
39
+ module Private
40
+ module Pool
41
+ CACHE_FROZEN_OBJECTS =
42
+ begin
43
+ ObjectSpace::WeakMap.new[1] = 1
44
+ true # Ruby 2.7 and newer
45
+ rescue ArgumentError
46
+ false # Ruby 2.6 and older
47
+ end
48
+
49
+ @cache = ObjectSpace::WeakMap.new
50
+
51
+ def self.type_for_module(mod)
52
+ cached = @cache[mod]
53
+ return cached if cached
54
+
55
+ type = TypedClass.new(mod)
56
+
57
+ if CACHE_FROZEN_OBJECTS || (!mod.frozen? && !type.frozen?)
58
+ @cache[mod] = type
59
+ end
60
+ type
61
+ end
62
+ end
63
+ end
64
+
65
+ class Untyped < TypedClass
66
+ def initialize
67
+ super(T.untyped)
68
+ end
69
+
70
+ module Private
71
+ INSTANCE = Untyped.new.freeze
72
+ end
73
+ end
74
+
75
+ class Anything < TypedClass
76
+ def initialize
77
+ super(T.anything)
78
+ end
79
+
80
+ module Private
81
+ INSTANCE = Anything.new.freeze
82
+ end
83
+ end
84
+ end
85
+ end
@@ -91,6 +91,8 @@ module T::Types
91
91
  # both reading and writing. However, Sorbet treats *all*
92
92
  # Enumerable subclasses as covariant for ease of adoption.
93
93
  @type.subtype_of?(other.type)
94
+ elsif other.class <= Simple
95
+ underlying_class <= other.raw_type
94
96
  else
95
97
  false
96
98
  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.10782
4
+ version: 0.5.10993
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-15 00:00:00.000000000 Z
11
+ date: 2023-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.7'
33
+ version: '2.1'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.7'
40
+ version: '2.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -233,6 +233,7 @@ files:
233
233
  - lib/types/types/type_template.rb
234
234
  - lib/types/types/type_variable.rb
235
235
  - lib/types/types/typed_array.rb
236
+ - lib/types/types/typed_class.rb
236
237
  - lib/types/types/typed_enumerable.rb
237
238
  - lib/types/types/typed_enumerator.rb
238
239
  - lib/types/types/typed_enumerator_chain.rb