tapioca 0.7.2 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tapioca/sorbet_ext/generic_name_patch.rb +45 -32
- data/lib/tapioca/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b06e8ec67c72db19639c21a8a123ecbe7c3c58ad27eb8956d6e3772cb68dc1e
|
4
|
+
data.tar.gz: e8c0bb1073cc08c2fc9d7eea7b523ebe1bc87e7f162c0413e2f0f29be67481c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd44669e05b95b61ea62c3c5e7a640bc664a036418d66fad6734065caadaa52ec545408376d4e9ada732d2a976dc599b92fc374ec53ad2a1ffa247adee989acd
|
7
|
+
data.tar.gz: 8f6e3a4223c42f9271321b31c8f26199a9b371865041f3455b3e3350e356adaf0eca2c5d83bcec9e0247f76ed0434c1b93627e19f8c3d10893e084e5c88f7d3e
|
@@ -21,47 +21,33 @@ module T
|
|
21
21
|
Tapioca::Runtime::GenericTypeRegistry.register_type(constant, types)
|
22
22
|
end
|
23
23
|
|
24
|
-
def type_member(variance = :invariant, fixed: nil, lower: nil, upper: nil, &
|
24
|
+
def type_member(variance = :invariant, fixed: nil, lower: nil, upper: nil, &bounds_proc)
|
25
25
|
# `T::Generic#type_member` just instantiates a `T::Type::TypeMember` instance and returns it.
|
26
26
|
# We use that when registering the type member and then later return it from this method.
|
27
|
-
hash = if blk
|
28
|
-
blk.call
|
29
|
-
else
|
30
|
-
{
|
31
|
-
fixed: fixed,
|
32
|
-
lower: lower,
|
33
|
-
upper: upper,
|
34
|
-
}
|
35
|
-
end
|
36
|
-
|
37
27
|
Tapioca::TypeVariableModule.new(
|
38
28
|
T.cast(self, Module),
|
39
29
|
Tapioca::TypeVariableModule::Type::Member,
|
40
30
|
variance,
|
41
|
-
|
31
|
+
fixed,
|
32
|
+
lower,
|
33
|
+
upper,
|
34
|
+
bounds_proc
|
42
35
|
).tap do |type_variable|
|
43
36
|
Tapioca::Runtime::GenericTypeRegistry.register_type_variable(self, type_variable)
|
44
37
|
end
|
45
38
|
end
|
46
39
|
|
47
|
-
def type_template(variance = :invariant, fixed: nil, lower: nil, upper: nil, &
|
40
|
+
def type_template(variance = :invariant, fixed: nil, lower: nil, upper: nil, &bounds_proc)
|
48
41
|
# `T::Generic#type_template` just instantiates a `T::Type::TypeTemplate` instance and returns it.
|
49
42
|
# We use that when registering the type template and then later return it from this method.
|
50
|
-
hash = if blk
|
51
|
-
blk.call
|
52
|
-
else
|
53
|
-
{
|
54
|
-
fixed: fixed,
|
55
|
-
lower: lower,
|
56
|
-
upper: upper,
|
57
|
-
}
|
58
|
-
end
|
59
|
-
|
60
43
|
Tapioca::TypeVariableModule.new(
|
61
44
|
T.cast(self, Module),
|
62
45
|
Tapioca::TypeVariableModule::Type::Template,
|
63
46
|
variance,
|
64
|
-
|
47
|
+
fixed,
|
48
|
+
lower,
|
49
|
+
upper,
|
50
|
+
bounds_proc
|
65
51
|
).tap do |type_variable|
|
66
52
|
Tapioca::Runtime::GenericTypeRegistry.register_type_variable(self, type_variable)
|
67
53
|
end
|
@@ -136,18 +122,31 @@ module Tapioca
|
|
136
122
|
end
|
137
123
|
end
|
138
124
|
|
125
|
+
# rubocop:disable Metrics/ParameterLists
|
139
126
|
sig do
|
140
|
-
params(
|
127
|
+
params(
|
128
|
+
context: Module,
|
129
|
+
type: Type,
|
130
|
+
variance: Symbol,
|
131
|
+
fixed: T.untyped,
|
132
|
+
lower: T.untyped,
|
133
|
+
upper: T.untyped,
|
134
|
+
bounds_proc: T.nilable(T.proc.returns(T::Hash[Symbol, T.untyped]))
|
135
|
+
).void
|
141
136
|
end
|
142
|
-
def initialize(context, type, variance, fixed
|
137
|
+
def initialize(context, type, variance, fixed, lower, upper, bounds_proc)
|
143
138
|
@context = context
|
144
139
|
@type = type
|
145
140
|
@variance = variance
|
146
|
-
@
|
147
|
-
|
148
|
-
|
141
|
+
@bounds_proc = if bounds_proc
|
142
|
+
bounds_proc
|
143
|
+
else
|
144
|
+
build_bounds_proc(fixed, lower, upper)
|
145
|
+
end
|
146
|
+
|
149
147
|
super()
|
150
148
|
end
|
149
|
+
# rubocop:enable Metrics/ParameterLists
|
151
150
|
|
152
151
|
sig { returns(T.nilable(String)) }
|
153
152
|
def name
|
@@ -170,9 +169,10 @@ module Tapioca
|
|
170
169
|
|
171
170
|
sig { returns(String) }
|
172
171
|
def serialize
|
173
|
-
|
174
|
-
|
175
|
-
lower =
|
172
|
+
bounds = @bounds_proc.call
|
173
|
+
fixed = bounds[:fixed].to_s if bounds.key?(:fixed)
|
174
|
+
lower = bounds[:lower].to_s if bounds.key?(:lower)
|
175
|
+
upper = bounds[:upper].to_s if bounds.key?(:upper)
|
176
176
|
|
177
177
|
TypeVariableHelper.serialize_type_variable(
|
178
178
|
@type.serialize,
|
@@ -190,6 +190,19 @@ module Tapioca
|
|
190
190
|
|
191
191
|
private
|
192
192
|
|
193
|
+
sig do
|
194
|
+
params(fixed: T.untyped, lower: T.untyped, upper: T.untyped)
|
195
|
+
.returns(T.proc.returns(T::Hash[Symbol, T.untyped]))
|
196
|
+
end
|
197
|
+
def build_bounds_proc(fixed, lower, upper)
|
198
|
+
bounds = {}
|
199
|
+
bounds[:fixed] = fixed unless fixed.nil?
|
200
|
+
bounds[:lower] = lower unless lower.nil?
|
201
|
+
bounds[:upper] = upper unless upper.nil?
|
202
|
+
|
203
|
+
-> { bounds }
|
204
|
+
end
|
205
|
+
|
193
206
|
sig do
|
194
207
|
type_parameters(:Result)
|
195
208
|
.params(block: T.proc.returns(T.type_parameter(:Result)))
|
data/lib/tapioca/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tapioca
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ufuk Kayserilioglu
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: exe
|
13
13
|
cert_chain: []
|
14
|
-
date: 2022-
|
14
|
+
date: 2022-05-30 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|