sorbet-runtime 0.5.10818 → 0.5.10820
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 +4 -4
- data/lib/sorbet-runtime.rb +1 -0
- data/lib/types/_types.rb +12 -0
- data/lib/types/types/class_of.rb +2 -0
- data/lib/types/types/typed_class.rb +85 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 31e1d95e4d9432b739e9ff5d24434c73387a008a8545730f014ab21b54154706
|
|
4
|
+
data.tar.gz: 51caacddddeb714f872de2531bef586126df4b01ecaaa15b6925c7588c3684e1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1ebd9c1f1ceabcc31b5923f849c66fd2dfd6ea90ee50cce8340f771d5f135aee783016a60dade22f90b4576e2df1e566046147c55e52b6a5093b28d1c69a4815
|
|
7
|
+
data.tar.gz: 9ec4e2036b31c3394ecfcaf7c84fcf7fd8c3062ded3c853e041ecd6ae55c65f84f862e51ce8d5c32f0e4c0c29889bf90a7afe094ce8237b13363a2cf327c1fc7
|
data/lib/sorbet-runtime.rb
CHANGED
data/lib/types/_types.rb
CHANGED
|
@@ -355,4 +355,16 @@ module T
|
|
|
355
355
|
end
|
|
356
356
|
end
|
|
357
357
|
end
|
|
358
|
+
|
|
359
|
+
module Class
|
|
360
|
+
def self.[](type)
|
|
361
|
+
if type.is_a?(T::Types::Untyped)
|
|
362
|
+
T::Types::TypedClass::Untyped::Private::INSTANCE
|
|
363
|
+
elsif type.is_a?(T::Types::Anything)
|
|
364
|
+
T::Types::TypedClass::Anything::Private::INSTANCE
|
|
365
|
+
else
|
|
366
|
+
T::Types::TypedClass::Private::Pool.type_for_module(type)
|
|
367
|
+
end
|
|
368
|
+
end
|
|
369
|
+
end
|
|
358
370
|
end
|
data/lib/types/types/class_of.rb
CHANGED
|
@@ -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
|
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.
|
|
4
|
+
version: 0.5.10820
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Stripe
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2023-05-
|
|
11
|
+
date: 2023-05-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: minitest
|
|
@@ -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
|