raap 0.5.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -1
- data/README.md +63 -2
- data/Rakefile +3 -1
- data/lib/raap/cli.rb +30 -15
- data/lib/raap/coverage.rb +188 -0
- data/lib/raap/function_type.rb +36 -16
- data/lib/raap/method_property.rb +47 -16
- data/lib/raap/method_type.rb +17 -8
- data/lib/raap/minitest.rb +2 -2
- data/lib/raap/rbs.rb +42 -0
- data/lib/raap/symbolic_caller.rb +2 -2
- data/lib/raap/type.rb +53 -45
- data/lib/raap/type_substitution.rb +7 -3
- data/lib/raap/value/interface.rb +13 -24
- data/lib/raap/value/intersection.rb +7 -8
- data/lib/raap/value/module.rb +1 -1
- data/lib/raap/value/variable.rb +1 -1
- data/lib/raap/version.rb +1 -1
- data/lib/raap.rb +2 -0
- data/lib/shims.rb +38 -0
- data/public/example.webp +0 -0
- data/rbs_collection.lock.yaml +5 -5
- data/sig/raap.rbs +52 -11
- metadata +7 -4
data/lib/raap/method_type.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module RaaP
|
4
4
|
class MethodType
|
5
|
-
attr_reader :rbs
|
5
|
+
attr_reader :rbs, :original_rbs
|
6
6
|
|
7
7
|
def initialize(method, type_params_decl: [], type_args: [], self_type: nil, instance_type: nil, class_type: nil)
|
8
8
|
rbs =
|
@@ -20,17 +20,19 @@ module RaaP
|
|
20
20
|
params = (type_params_decl + rbs.type_params).uniq
|
21
21
|
ts = TypeSubstitution.new(params, type_args)
|
22
22
|
|
23
|
-
@
|
24
|
-
@
|
23
|
+
@original_rbs = rbs
|
24
|
+
@rbs = ts.method_type_sub(rbs, self_type: self_type, instance_type: instance_type, class_type: class_type)
|
25
|
+
function_or_untypedfunction = __skip__ = @rbs.type
|
26
|
+
@fun_type = FunctionType.new(function_or_untypedfunction)
|
25
27
|
end
|
26
28
|
|
27
29
|
def pick_arguments(size: 10)
|
28
|
-
SymbolicCaller.new(arguments_to_symbolic_call(size:)).eval
|
30
|
+
SymbolicCaller.new(arguments_to_symbolic_call(size: size)).eval
|
29
31
|
end
|
30
32
|
|
31
33
|
def arguments_to_symbolic_call(size: 10)
|
32
|
-
args, kwargs = @fun_type.arguments_to_symbolic_call(size:)
|
33
|
-
block = pick_block(size:)
|
34
|
+
args, kwargs = @fun_type.arguments_to_symbolic_call(size: size)
|
35
|
+
block = pick_block(size: size)
|
34
36
|
|
35
37
|
[args, kwargs, block]
|
36
38
|
end
|
@@ -40,8 +42,15 @@ module RaaP
|
|
40
42
|
return nil if block.nil?
|
41
43
|
return nil if (block.required == false) && [true, false].sample
|
42
44
|
|
43
|
-
fixed_return_value = Type.new(block.type.return_type).pick(size:)
|
44
|
-
Proc.new
|
45
|
+
fixed_return_value = Type.new(block.type.return_type).pick(size: size)
|
46
|
+
Proc.new do
|
47
|
+
block.type.each_param.with_index do |_param, i|
|
48
|
+
Coverage.log("block_param_#{i}")
|
49
|
+
end
|
50
|
+
|
51
|
+
Coverage.new_type_with_log("block_return", block.type.return_type)
|
52
|
+
fixed_return_value
|
53
|
+
end
|
45
54
|
end
|
46
55
|
|
47
56
|
def check_return(return_value)
|
data/lib/raap/minitest.rb
CHANGED
@@ -13,7 +13,7 @@ module RaaP
|
|
13
13
|
method_type = RaaP::MethodType.new(type)
|
14
14
|
size_step.each do |size|
|
15
15
|
# TODO assert_send_type
|
16
|
-
args, kwargs, _block = method_type.pick_arguments(size:)
|
16
|
+
args, kwargs, _block = method_type.pick_arguments(size: size)
|
17
17
|
return_value = yield(*args, **kwargs)
|
18
18
|
i = BindCall.inspect(return_value)
|
19
19
|
c = BindCall.class(return_value)
|
@@ -30,7 +30,7 @@ module RaaP
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
size_step.each do |size|
|
33
|
-
values = types.map { |t| t.pick(size:) }
|
33
|
+
values = types.map { |t| t.pick(size: size) }
|
34
34
|
assert yield(*values)
|
35
35
|
end
|
36
36
|
end
|
data/lib/raap/rbs.rb
CHANGED
@@ -26,6 +26,48 @@ module RaaP
|
|
26
26
|
::RBS::Parser.parse_method_type(method_type, require_eof: true) or raise
|
27
27
|
end
|
28
28
|
|
29
|
+
def self.parse_member(member_type)
|
30
|
+
_, _, decls = ::RBS::Parser.parse_signature(<<~RBS)
|
31
|
+
module MemberScope
|
32
|
+
#{member_type}
|
33
|
+
end
|
34
|
+
RBS
|
35
|
+
decl = decls.first or raise
|
36
|
+
raise unless decl.is_a?(::RBS::AST::Declarations::Module)
|
37
|
+
|
38
|
+
member = decl.members.first or raise
|
39
|
+
raise unless member.is_a?(::RBS::AST::Members::Attribute)
|
40
|
+
|
41
|
+
member.tap do |m|
|
42
|
+
m = __skip__ = m
|
43
|
+
_shift_location(m.type, -m.location.start_pos)
|
44
|
+
_shift_location(m, -m.location.start_pos)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def self._shift_location(localable, shift)
|
49
|
+
return if localable.location.nil?
|
50
|
+
|
51
|
+
l = localable.instance_variable_get("@location")
|
52
|
+
localable.instance_variable_set(
|
53
|
+
"@location",
|
54
|
+
::RBS::Location.new(
|
55
|
+
buffer: ::RBS::Buffer.new(
|
56
|
+
name: l.buffer.name,
|
57
|
+
content: l.buffer.content[-shift..l.end_pos],
|
58
|
+
),
|
59
|
+
start_pos: l.start_pos + shift,
|
60
|
+
end_pos: l.end_pos + shift,
|
61
|
+
)
|
62
|
+
)
|
63
|
+
case localable
|
64
|
+
when ::RBS::Types::Union
|
65
|
+
localable.types.each { |t| _shift_location(t, shift) }
|
66
|
+
when ::RBS::Types::Optional
|
67
|
+
_shift_location(localable.type, shift)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
29
71
|
def self.find_alias_decl(type_name, method_name)
|
30
72
|
env.class_decls[type_name].decls.each do |d|
|
31
73
|
d.decl.members.each do |member|
|
data/lib/raap/symbolic_caller.rb
CHANGED
data/lib/raap/type.rb
CHANGED
@@ -24,6 +24,7 @@ module RaaP
|
|
24
24
|
def self.register(type_name, &block)
|
25
25
|
raise ArgumentError, "block is required" unless block
|
26
26
|
|
27
|
+
type_name = "::#{type_name}" if !type_name.start_with?("::")
|
27
28
|
GENERATORS[type_name] = __skip__ = block
|
28
29
|
end
|
29
30
|
|
@@ -52,28 +53,29 @@ module RaaP
|
|
52
53
|
method_type = MethodType.new(maped_rbs_method_type)
|
53
54
|
|
54
55
|
begin
|
55
|
-
args, kwargs, block = method_type.arguments_to_symbolic_call(size:)
|
56
|
+
args, kwargs, block = method_type.arguments_to_symbolic_call(size: size)
|
56
57
|
[:call, base, :new, args, kwargs, block]
|
57
58
|
rescue
|
58
59
|
$stderr.puts "Fail with `#{rbs_method_type}`"
|
59
60
|
raise
|
60
61
|
end
|
61
62
|
else
|
62
|
-
[:call, Value::Module, :new, [type.to_s], { size: }, nil]
|
63
|
+
[:call, Value::Module, :new, [type.to_s], { size: size }, nil]
|
63
64
|
end
|
64
65
|
end
|
65
66
|
|
66
67
|
# Special class case
|
67
68
|
register("::Array") do
|
68
69
|
instance = __skip__ = type
|
69
|
-
t = instance.args[0] ? Type.new(instance.args[0], range:) : Type.random
|
70
|
+
t = instance.args[0] ? Type.new(instance.args[0], range: range) : Type.random
|
70
71
|
array(t)
|
71
72
|
end
|
72
|
-
register("::Binding") {
|
73
|
+
register("::Binding") { binding }
|
73
74
|
register("::Complex") { complex }
|
74
|
-
register("::Data") {
|
75
|
+
register("::Data") { Data.define }
|
75
76
|
register("::Encoding") { encoding }
|
76
|
-
register("::FalseClass") {
|
77
|
+
register("::FalseClass") { false }
|
78
|
+
register("::File") { File.open("/dev/null") }
|
77
79
|
register("::Float") { float }
|
78
80
|
register("::Hash") do
|
79
81
|
instance = __skip__ = type
|
@@ -82,18 +84,18 @@ module RaaP
|
|
82
84
|
dict(key, value)
|
83
85
|
end
|
84
86
|
register("::Integer") { integer }
|
85
|
-
register("::IO") {
|
86
|
-
register("::Method") {
|
87
|
-
register("::NilClass") {
|
88
|
-
register("::Proc") {
|
87
|
+
register("::IO") { $stdout }
|
88
|
+
register("::Method") { temp_method_object }
|
89
|
+
register("::NilClass") { nil }
|
90
|
+
register("::Proc") { Proc.new {} }
|
89
91
|
register("::Rational") { rational }
|
90
|
-
register("::Regexp") { sized { |size| Regexp.new(string.pick(size:)) } }
|
92
|
+
register("::Regexp") { sized { |size| Regexp.new(string.pick(size: size)) } }
|
91
93
|
register("::String") { string }
|
92
|
-
register("::Struct") {
|
94
|
+
register("::Struct") { Struct.new(:foo, :bar).new }
|
93
95
|
register("::Symbol") { symbol }
|
94
|
-
register("::Time") {
|
95
|
-
register("::TrueClass") {
|
96
|
-
register("::UnboundMethod") {
|
96
|
+
register("::Time") { [:call, Time, :now, [], {}, nil] }
|
97
|
+
register("::TrueClass") { true }
|
98
|
+
register("::UnboundMethod") { temp_method_object.unbind }
|
97
99
|
|
98
100
|
attr_reader :type
|
99
101
|
attr_reader :range
|
@@ -118,11 +120,11 @@ module RaaP
|
|
118
120
|
end
|
119
121
|
|
120
122
|
def pick(size: 10)
|
121
|
-
to_symbolic_caller(size:).eval
|
123
|
+
to_symbolic_caller(size: size).eval
|
122
124
|
end
|
123
125
|
|
124
126
|
def to_symbolic_caller(size: 10)
|
125
|
-
SymbolicCaller.new(to_symbolic_call(size:))
|
127
|
+
SymbolicCaller.new(to_symbolic_call(size: size))
|
126
128
|
end
|
127
129
|
|
128
130
|
def to_symbolic_call(size: 10)
|
@@ -131,20 +133,20 @@ module RaaP
|
|
131
133
|
|
132
134
|
case type
|
133
135
|
when ::RBS::Types::Tuple
|
134
|
-
type.types.map { |t| Type.new(t).to_symbolic_call(size:) }
|
136
|
+
type.types.map { |t| Type.new(t).to_symbolic_call(size: size) }
|
135
137
|
when ::RBS::Types::Union
|
136
|
-
type.types.sample&.then { |t| Type.new(t).to_symbolic_call(size:) }
|
138
|
+
type.types.sample&.then { |t| Type.new(t).to_symbolic_call(size: size) }
|
137
139
|
when ::RBS::Types::Intersection
|
138
140
|
if type.free_variables.empty?
|
139
|
-
[:call, Value::Intersection, :new, [type.to_s], { size: }, nil]
|
141
|
+
[:call, Value::Intersection, :new, [type.to_s], { size: size }, nil]
|
140
142
|
else
|
141
|
-
[:call, Value::Intersection, :new, [type], { size: }, nil]
|
143
|
+
[:call, Value::Intersection, :new, [type], { size: size }, nil]
|
142
144
|
end
|
143
145
|
when ::RBS::Types::Interface
|
144
146
|
if type.free_variables.empty?
|
145
|
-
[:call, Value::Interface, :new, [type.to_s], { size: }, nil]
|
147
|
+
[:call, Value::Interface, :new, [type.to_s], { size: size }, nil]
|
146
148
|
else
|
147
|
-
[:call, Value::Interface, :new, [type], { size: }, nil]
|
149
|
+
[:call, Value::Interface, :new, [type], { size: size }, nil]
|
148
150
|
end
|
149
151
|
when ::RBS::Types::Variable
|
150
152
|
[:call, Value::Variable, :new, [type.to_s], {}, nil]
|
@@ -162,7 +164,7 @@ module RaaP
|
|
162
164
|
when ::RBS::Types::Alias
|
163
165
|
case gen = GENERATORS[type.name.absolute!.to_s]
|
164
166
|
in Proc then instance_exec(&gen)
|
165
|
-
in nil then Type.new(RBS.builder.expand_alias2(type.name, type.args)).to_symbolic_call(size:)
|
167
|
+
in nil then Type.new(RBS.builder.expand_alias2(type.name, type.args)).to_symbolic_call(size: size)
|
166
168
|
end
|
167
169
|
when ::RBS::Types::Bases::Class
|
168
170
|
RaaP.logger.warn("Unresolved `class` type, use Object instead.")
|
@@ -176,19 +178,19 @@ module RaaP
|
|
176
178
|
Object.const_get(type.name.to_s)
|
177
179
|
when ::RBS::Types::ClassInstance
|
178
180
|
case gen = GENERATORS[type.name.absolute!.to_s]
|
179
|
-
in Proc then
|
180
|
-
in nil then to_symbolic_call_from_initialize(type, size:)
|
181
|
+
in Proc then pick_by_generator(gen, size: size)
|
182
|
+
in nil then to_symbolic_call_from_initialize(type, size: size)
|
181
183
|
end
|
182
184
|
when ::RBS::Types::Record
|
183
185
|
type.fields.transform_values { |t| Type.new(t).to_symbolic_call(size: size / 2) }
|
184
186
|
when ::RBS::Types::Proc
|
185
|
-
Proc.new { Type.new(type.type.return_type).to_symbolic_call(size:) }
|
187
|
+
Proc.new { Type.new(type.type.return_type).to_symbolic_call(size: size) }
|
186
188
|
when ::RBS::Types::Literal
|
187
189
|
type.literal
|
188
190
|
when ::RBS::Types::Bases::Bool
|
189
|
-
bool
|
191
|
+
bool
|
190
192
|
when ::RBS::Types::Bases::Any
|
191
|
-
Type.random.to_symbolic_call(size:)
|
193
|
+
Type.random.to_symbolic_call(size: size)
|
192
194
|
when ::RBS::Types::Bases::Nil
|
193
195
|
nil
|
194
196
|
else
|
@@ -198,10 +200,20 @@ module RaaP
|
|
198
200
|
|
199
201
|
private
|
200
202
|
|
203
|
+
def pick_by_generator(gen, size:)
|
204
|
+
ret = instance_exec(&gen)
|
205
|
+
case ret
|
206
|
+
when Sized
|
207
|
+
ret.pick(size: size)
|
208
|
+
else
|
209
|
+
ret
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
201
213
|
def to_symbolic_call_from_initialize(type, size:)
|
202
214
|
type_name = type.name.absolute!
|
203
215
|
const = Object.const_get(type_name.to_s)
|
204
|
-
Type.call_new_from(const, type, size:)
|
216
|
+
Type.call_new_from(const, type, size: size)
|
205
217
|
end
|
206
218
|
|
207
219
|
def parse(type)
|
@@ -216,7 +228,7 @@ module RaaP
|
|
216
228
|
end
|
217
229
|
|
218
230
|
def integer
|
219
|
-
sized { |size| float.pick(size:).round }
|
231
|
+
sized { |size| float.pick(size: size).round }
|
220
232
|
end
|
221
233
|
|
222
234
|
def none_zero_integer
|
@@ -240,16 +252,16 @@ module RaaP
|
|
240
252
|
|
241
253
|
def rational
|
242
254
|
sized do |size|
|
243
|
-
a = integer.pick(size:)
|
244
|
-
b = none_zero_integer.pick(size:)
|
255
|
+
a = integer.pick(size: size)
|
256
|
+
b = none_zero_integer.pick(size: size)
|
245
257
|
[:call, Kernel, :Rational, [a, b], {}, nil]
|
246
258
|
end
|
247
259
|
end
|
248
260
|
|
249
261
|
def complex
|
250
262
|
sized do |size|
|
251
|
-
a = integer.pick(size:)
|
252
|
-
b = none_zero_integer.pick(size:)
|
263
|
+
a = integer.pick(size: size)
|
264
|
+
b = none_zero_integer.pick(size: size)
|
253
265
|
[:call, Kernel, :Complex, [a, b], {}, nil]
|
254
266
|
end
|
255
267
|
end
|
@@ -274,13 +286,13 @@ module RaaP
|
|
274
286
|
|
275
287
|
def symbol
|
276
288
|
sized do |size|
|
277
|
-
string.pick(size:).to_sym
|
289
|
+
string.pick(size: size).to_sym
|
278
290
|
end
|
279
291
|
end
|
280
292
|
|
281
293
|
def array(type)
|
282
294
|
sized do |size|
|
283
|
-
Array.new(integer.pick(size:).abs) do
|
295
|
+
Array.new(integer.pick(size: size).abs) do
|
284
296
|
type.to_symbolic_call(size: size / 2)
|
285
297
|
end
|
286
298
|
end
|
@@ -291,7 +303,7 @@ module RaaP
|
|
291
303
|
def dict(key_type, value_type)
|
292
304
|
sized do |size|
|
293
305
|
csize = size / 2
|
294
|
-
Array.new(integer.pick(size:).abs).to_h do
|
306
|
+
Array.new(integer.pick(size: size).abs).to_h do
|
295
307
|
[
|
296
308
|
key_type.to_symbolic_call(size: csize),
|
297
309
|
value_type.to_symbolic_call(size: csize)
|
@@ -301,16 +313,12 @@ module RaaP
|
|
301
313
|
end
|
302
314
|
|
303
315
|
def encoding
|
304
|
-
|
305
|
-
|
306
|
-
[:call, Encoding, :find, [e.name], {}, nil]
|
307
|
-
end
|
316
|
+
e = Encoding.list.sample or raise
|
317
|
+
[:call, Encoding, :find, [e.name], {}, nil]
|
308
318
|
end
|
309
319
|
|
310
320
|
def bool
|
311
|
-
|
312
|
-
Random.rand(2) == 0
|
313
|
-
end
|
321
|
+
Random.rand(2) == 0
|
314
322
|
end
|
315
323
|
|
316
324
|
def temp_method_object
|
@@ -25,10 +25,14 @@ module RaaP
|
|
25
25
|
instance_type = instance_type.is_a?(::String) ? RBS.parse_type(instance_type) : instance_type
|
26
26
|
class_type = class_type.is_a?(::String) ? RBS.parse_type(class_type) : class_type
|
27
27
|
sub = build
|
28
|
+
if sub.empty? && self_type.nil? && instance_type.nil? && class_type.nil?
|
29
|
+
return method_type
|
30
|
+
end
|
31
|
+
|
28
32
|
::RBS::MethodType.new(
|
29
33
|
type_params: [],
|
30
|
-
type: method_type.type.sub(sub).then { |ty| sub(ty, self_type
|
31
|
-
block: method_type.block&.sub(sub)&.then { |bl| sub(bl, self_type
|
34
|
+
type: method_type.type.sub(sub).then { |ty| sub(ty, self_type: self_type, instance_type: instance_type, class_type: class_type) },
|
35
|
+
block: method_type.block&.sub(sub)&.then { |bl| sub(bl, self_type: self_type, instance_type: instance_type, class_type: class_type) },
|
32
36
|
location: method_type.location
|
33
37
|
)
|
34
38
|
end
|
@@ -49,7 +53,7 @@ module RaaP
|
|
49
53
|
when ::RBS::Types::Bases::Class
|
50
54
|
class_type || ty
|
51
55
|
else
|
52
|
-
sub(ty, self_type
|
56
|
+
sub(ty, self_type: self_type, instance_type: instance_type, class_type: class_type)
|
53
57
|
end
|
54
58
|
end
|
55
59
|
end
|
data/lib/raap/value/interface.rb
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
module RaaP
|
4
4
|
module Value
|
5
|
-
class Interface
|
5
|
+
class Interface
|
6
6
|
class << self
|
7
|
-
def define_method_from_interface(
|
7
|
+
def define_method_from_interface(base_mod, type, size: 3)
|
8
8
|
type = type.is_a?(::String) ? RBS.parse_type(type) : type
|
9
9
|
unless type.instance_of?(::RBS::Types::Interface)
|
10
10
|
::Kernel.raise ::TypeError, "not an interface type: #{type}"
|
@@ -20,26 +20,23 @@ module RaaP
|
|
20
20
|
method_type = method.method_types.sample or ::Kernel.raise
|
21
21
|
type_params = definition.type_params_decl.concat(method_type.type_params.drop(definition.type_params_decl.length))
|
22
22
|
ts = TypeSubstitution.new(type_params, type.args)
|
23
|
-
subed_method_type = ts.method_type_sub(method_type, self_type
|
23
|
+
subed_method_type = ts.method_type_sub(method_type, self_type: self_type, instance_type: instance_type, class_type: class_type)
|
24
24
|
|
25
|
-
BindCall.define_method(
|
25
|
+
BindCall.define_method(base_mod, name) do |*_, &b|
|
26
26
|
@fixed_return_value ||= {}
|
27
27
|
@fixed_return_value[name] ||= if self_type == subed_method_type.type.return_type
|
28
28
|
self
|
29
29
|
else
|
30
|
-
Type.new(subed_method_type.type.return_type).pick(size:)
|
30
|
+
Type.new(subed_method_type.type.return_type).pick(size: size)
|
31
31
|
end
|
32
32
|
# @type var b: Proc?
|
33
|
-
if b
|
33
|
+
if b && subed_method_type.block && subed_method_type.block.type.is_a?(::RBS::Types::Function)
|
34
34
|
@fixed_block_arguments ||= {}
|
35
|
-
@fixed_block_arguments[name] ||=
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
else
|
41
|
-
[]
|
42
|
-
end
|
35
|
+
@fixed_block_arguments[name] ||= size.times.map do
|
36
|
+
FunctionType.new(subed_method_type.block.type)
|
37
|
+
.pick_arguments(size: size)
|
38
|
+
end
|
39
|
+
|
43
40
|
@fixed_block_arguments[name].each do |a, kw|
|
44
41
|
b.call(*a, **kw)
|
45
42
|
end
|
@@ -51,10 +48,10 @@ module RaaP
|
|
51
48
|
|
52
49
|
def new(type, size: 3)
|
53
50
|
temp_class = ::Class.new(Interface) do |c|
|
54
|
-
define_method_from_interface(c, type, size:)
|
51
|
+
define_method_from_interface(c, type, size: size)
|
55
52
|
end
|
56
53
|
instance = temp_class.allocate
|
57
|
-
instance.__send__(:initialize, type, size:)
|
54
|
+
instance.__send__(:initialize, type, size: size)
|
58
55
|
instance
|
59
56
|
end
|
60
57
|
end
|
@@ -68,14 +65,6 @@ module RaaP
|
|
68
65
|
@size = size
|
69
66
|
end
|
70
67
|
|
71
|
-
def respond_to?(name, _include_all = false)
|
72
|
-
@definition.methods.has_key?(name.to_sym)
|
73
|
-
end
|
74
|
-
|
75
|
-
def class
|
76
|
-
Interface
|
77
|
-
end
|
78
|
-
|
79
68
|
def inspect
|
80
69
|
"#<interface @type=`#{@type}` @methods=#{@definition.methods.keys} @size=#{@size}>"
|
81
70
|
end
|
@@ -17,23 +17,22 @@ module RaaP
|
|
17
17
|
raise ArgumentError, "intersection type must have at least one class instance type in `#{instances}`"
|
18
18
|
end
|
19
19
|
|
20
|
-
base = instances.find { |c| c.is_a?(::Class) } ||
|
20
|
+
base = instances.find { |c| c.is_a?(::Class) } || Object
|
21
21
|
|
22
22
|
c = Class.new(base) do
|
23
23
|
instances.select { |i| !i.is_a?(::Class) }.each do |m|
|
24
24
|
include(m)
|
25
25
|
end
|
26
26
|
|
27
|
-
|
28
|
-
t
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
Interface.define_method_from_interface(self, interface, size:)
|
27
|
+
type.types.each do |t|
|
28
|
+
case t
|
29
|
+
when ::RBS::Types::Interface
|
30
|
+
Interface.define_method_from_interface(self, t, size: size)
|
31
|
+
end
|
33
32
|
end
|
34
33
|
end
|
35
34
|
type = ::RBS::Types::ClassInstance.new(name: TypeName(base.name), args: [], location: nil)
|
36
|
-
SymbolicCaller.new(Type.call_new_from(c, type, size:)).eval
|
35
|
+
SymbolicCaller.new(Type.call_new_from(c, type, size: size)).eval
|
37
36
|
end
|
38
37
|
end
|
39
38
|
end
|
data/lib/raap/value/module.rb
CHANGED
@@ -35,7 +35,7 @@ module RaaP
|
|
35
35
|
if !ts.include?('::BasicObject') || ts.any? { |t| t.split('::').last&.start_with?('_') }
|
36
36
|
ts.unshift('Object')
|
37
37
|
end
|
38
|
-
Type.new(ts.uniq.join(' & ')).pick(size:)
|
38
|
+
Type.new(ts.uniq.join(' & ')).pick(size: size)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
const = ::Object.const_get(@type.name.absolute!.to_s)
|
data/lib/raap/value/variable.rb
CHANGED
data/lib/raap/version.rb
CHANGED
data/lib/raap.rb
CHANGED
@@ -9,6 +9,7 @@ require 'logger'
|
|
9
9
|
|
10
10
|
require_relative 'raap/version'
|
11
11
|
require_relative 'raap/value'
|
12
|
+
require_relative 'shims'
|
12
13
|
|
13
14
|
module RaaP
|
14
15
|
class << self
|
@@ -22,6 +23,7 @@ module RaaP
|
|
22
23
|
|
23
24
|
autoload :BindCall, "raap/bind_call"
|
24
25
|
autoload :CLI, "raap/cli"
|
26
|
+
autoload :Coverage, "raap/coverage"
|
25
27
|
autoload :FunctionType, "raap/function_type"
|
26
28
|
autoload :MethodProperty, "raap/method_property"
|
27
29
|
autoload :MethodType, "raap/method_type"
|
data/lib/shims.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Ruby 3.2
|
4
|
+
unless Exception.method_defined?(:detailed_message)
|
5
|
+
class Exception
|
6
|
+
alias detailed_message message
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
# Ruby 3.2
|
11
|
+
unless defined?(Data)
|
12
|
+
class Data
|
13
|
+
class << self
|
14
|
+
def define(*syms)
|
15
|
+
_ = Class.new do |c|
|
16
|
+
define_method(:initialize) do |*args, **kwargs|
|
17
|
+
if !args.empty?
|
18
|
+
syms.zip(args).each do |sym, arg|
|
19
|
+
instance_variable_set("@#{sym}", arg)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
if !kwargs.empty?
|
23
|
+
kwargs.each do |k, v|
|
24
|
+
instance_variable_set("@#{k}", v)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
syms.each do |sym|
|
30
|
+
c.define_method(sym) do
|
31
|
+
instance_variable_get("@#{sym}")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/public/example.webp
ADDED
Binary file
|
data/rbs_collection.lock.yaml
CHANGED
@@ -10,7 +10,7 @@ gems:
|
|
10
10
|
source:
|
11
11
|
type: git
|
12
12
|
name: ruby/gem_rbs_collection
|
13
|
-
revision:
|
13
|
+
revision: d2e93d426c927fdab90ef12e30a9875aa05d60d6
|
14
14
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
15
15
|
repo_dir: gems
|
16
16
|
- name: base64
|
@@ -26,7 +26,7 @@ gems:
|
|
26
26
|
source:
|
27
27
|
type: git
|
28
28
|
name: ruby/gem_rbs_collection
|
29
|
-
revision:
|
29
|
+
revision: d2e93d426c927fdab90ef12e30a9875aa05d60d6
|
30
30
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
31
31
|
repo_dir: gems
|
32
32
|
- name: connection_pool
|
@@ -34,7 +34,7 @@ gems:
|
|
34
34
|
source:
|
35
35
|
type: git
|
36
36
|
name: ruby/gem_rbs_collection
|
37
|
-
revision:
|
37
|
+
revision: d2e93d426c927fdab90ef12e30a9875aa05d60d6
|
38
38
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
39
39
|
repo_dir: gems
|
40
40
|
- name: date
|
@@ -54,7 +54,7 @@ gems:
|
|
54
54
|
source:
|
55
55
|
type: git
|
56
56
|
name: ruby/gem_rbs_collection
|
57
|
-
revision:
|
57
|
+
revision: d2e93d426c927fdab90ef12e30a9875aa05d60d6
|
58
58
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
59
59
|
repo_dir: gems
|
60
60
|
- name: io-console
|
@@ -94,7 +94,7 @@ gems:
|
|
94
94
|
source:
|
95
95
|
type: git
|
96
96
|
name: ruby/gem_rbs_collection
|
97
|
-
revision:
|
97
|
+
revision: d2e93d426c927fdab90ef12e30a9875aa05d60d6
|
98
98
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
99
99
|
repo_dir: gems
|
100
100
|
- name: rbs
|