sorbet-runtime 0.6.12690 → 0.6.12698
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 +1 -1
- data/lib/types/types/simple.rb +4 -4
- data/lib/types/types/typed_class.rb +1 -1
- data/lib/types/types/typed_module.rb +102 -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: ea3c0c3901405f4352a63a498d150ac369b433440ccf0acd515fa594edf3b699
|
|
4
|
+
data.tar.gz: c2484baf3e8474b6b8436990c2ddf6b4ad9cf6159e07c98a72f68d9268981fc8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bf62db0635168aa95ea58fde5693e3a9c3e15d016513ff1c332e527e71e5d9bade43e6e53f418c9fcf698361eb39a6e53f31f5d5f1f4d8ac67fc15e7bf540049
|
|
7
|
+
data.tar.gz: 89df13d1ca3567e2f8aa1d216a71168290d7f65e1b29d5aa879513877a797c63489fdedcfb77433959f1804209d98a9ea79314e49906ef742536932b3fb905c5
|
data/lib/sorbet-runtime.rb
CHANGED
data/lib/types/_types.rb
CHANGED
|
@@ -367,4 +367,16 @@ module T
|
|
|
367
367
|
end
|
|
368
368
|
end
|
|
369
369
|
end
|
|
370
|
+
|
|
371
|
+
module Module
|
|
372
|
+
def self.[](type)
|
|
373
|
+
if type.is_a?(T::Types::Untyped)
|
|
374
|
+
T::Types::TypedModule::Untyped::Private::INSTANCE
|
|
375
|
+
elsif type.is_a?(T::Types::Anything)
|
|
376
|
+
T::Types::TypedModule::Anything::Private::INSTANCE
|
|
377
|
+
else
|
|
378
|
+
T::Types::TypedModule::Private::Pool.type_for_module(type)
|
|
379
|
+
end
|
|
380
|
+
end
|
|
381
|
+
end
|
|
370
382
|
end
|
data/lib/types/types/class_of.rb
CHANGED
data/lib/types/types/simple.rb
CHANGED
|
@@ -41,7 +41,7 @@ module T::Types
|
|
|
41
41
|
case other
|
|
42
42
|
when Simple
|
|
43
43
|
@raw_type <= other.raw_type
|
|
44
|
-
when TypedClass
|
|
44
|
+
when TypedClass, TypedModule
|
|
45
45
|
# This case is a bit odd--we would have liked to solve this like we do
|
|
46
46
|
# for `T::Array` et al., but don't for backwards compatibility.
|
|
47
47
|
# See `type_for_module` below.
|
|
@@ -103,9 +103,9 @@ module T::Types
|
|
|
103
103
|
elsif !Object.autoload?(:Set) && Object.const_defined?(:Set) && mod == ::Set
|
|
104
104
|
T::Set[T.untyped]
|
|
105
105
|
else
|
|
106
|
-
# ideally we would have a case mapping from ::Class -> T::Class
|
|
107
|
-
# but for backwards compatibility we
|
|
108
|
-
# have a special case in subtype_of_single?
|
|
106
|
+
# ideally we would have a case mapping from ::Class -> T::Class and
|
|
107
|
+
# ::Module -> T::Module here but for backwards compatibility we
|
|
108
|
+
# don't have that, and instead have a special case in subtype_of_single?
|
|
109
109
|
Simple.new(mod)
|
|
110
110
|
end
|
|
111
111
|
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
3
|
+
|
|
4
|
+
module T::Types
|
|
5
|
+
class TypedModule < T::Types::Base
|
|
6
|
+
def initialize(type)
|
|
7
|
+
@inner_type = type
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def type
|
|
11
|
+
@type ||= T::Utils.coerce(@inner_type)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def build_type
|
|
15
|
+
type
|
|
16
|
+
nil
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# overrides Base
|
|
20
|
+
def name
|
|
21
|
+
"T::Module[#{type.name}]"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def underlying_class
|
|
25
|
+
Module
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# overrides Base
|
|
29
|
+
def valid?(obj)
|
|
30
|
+
Module.===(obj)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# overrides Base
|
|
34
|
+
private def subtype_of_single?(type)
|
|
35
|
+
case type
|
|
36
|
+
when TypedModule
|
|
37
|
+
# treat like generics are erased
|
|
38
|
+
true
|
|
39
|
+
when Simple
|
|
40
|
+
Module <= type.raw_type
|
|
41
|
+
else
|
|
42
|
+
false
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
module Private
|
|
47
|
+
module Pool
|
|
48
|
+
CACHE_FROZEN_OBJECTS =
|
|
49
|
+
begin
|
|
50
|
+
ObjectSpace::WeakMap.new[1] = 1
|
|
51
|
+
true # Ruby 2.7 and newer
|
|
52
|
+
rescue ArgumentError
|
|
53
|
+
false # Ruby 2.6 and older
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
@cache = ObjectSpace::WeakMap.new
|
|
57
|
+
|
|
58
|
+
def self.type_for_module(mod)
|
|
59
|
+
cached = @cache[mod]
|
|
60
|
+
return cached if cached
|
|
61
|
+
|
|
62
|
+
type = TypedModule.new(mod)
|
|
63
|
+
|
|
64
|
+
if CACHE_FROZEN_OBJECTS || (!mod.frozen? && !type.frozen?)
|
|
65
|
+
@cache[mod] = type
|
|
66
|
+
end
|
|
67
|
+
type
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
class Untyped < TypedModule
|
|
73
|
+
def initialize
|
|
74
|
+
super(T::Types::Untyped::Private::INSTANCE)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def freeze
|
|
78
|
+
build_type # force lazy initialization before freezing the object
|
|
79
|
+
super
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
module Private
|
|
83
|
+
INSTANCE = Untyped.new.freeze
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
class Anything < TypedModule
|
|
88
|
+
def initialize
|
|
89
|
+
super(T.anything)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def freeze
|
|
93
|
+
build_type # force lazy initialization before freezing the object
|
|
94
|
+
super
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
module Private
|
|
98
|
+
INSTANCE = Anything.new.freeze
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
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.6.
|
|
4
|
+
version: 0.6.12698
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Stripe
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-11-
|
|
11
|
+
date: 2025-11-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: minitest
|
|
@@ -237,6 +237,7 @@ files:
|
|
|
237
237
|
- lib/types/types/typed_enumerator_chain.rb
|
|
238
238
|
- lib/types/types/typed_enumerator_lazy.rb
|
|
239
239
|
- lib/types/types/typed_hash.rb
|
|
240
|
+
- lib/types/types/typed_module.rb
|
|
240
241
|
- lib/types/types/typed_range.rb
|
|
241
242
|
- lib/types/types/typed_set.rb
|
|
242
243
|
- lib/types/types/union.rb
|