typeprof 0.12.0 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/typeprof/analyzer.rb +77 -41
- data/lib/typeprof/block.rb +7 -6
- data/lib/typeprof/builtin.rb +27 -5
- data/lib/typeprof/config.rb +9 -15
- data/lib/typeprof/export.rb +9 -10
- data/lib/typeprof/import.rb +5 -1
- data/lib/typeprof/version.rb +1 -1
- data/smoke/class_eval.rb +22 -0
- data/smoke/define_method7.rb +18 -0
- data/smoke/extended.rb +38 -0
- data/smoke/included.rb +38 -0
- data/smoke/inherited.rb +26 -0
- data/smoke/instance_eval.rb +1 -1
- data/smoke/instance_eval4.rb +12 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 501623610b473ab2fdd870686387a26ae787b8e3af6254a7a443967acb0b9f17
|
4
|
+
data.tar.gz: 0ace065239fb606719b1a716c7ce38e312c3b1b07f238d3f1a67e66eaf261567
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5b437508d0b83d3966a07266cebef3aa64e98ef4b33e75cd9deb5a615019fdb054f00ffb433d2af573258192bfd7346845dc870db32540b928314999c8e818c
|
7
|
+
data.tar.gz: 2aaa6b88e7d41676d989b3ac01057af13cf7247569e68b9be57b919e210afa140d016e3d27522fa8f03362fa17a3fb46356d3be1bd770a251c825cb4477334e6
|
data/Gemfile.lock
CHANGED
data/lib/typeprof/analyzer.rb
CHANGED
@@ -42,6 +42,10 @@ module TypeProf
|
|
42
42
|
"<builtin>"
|
43
43
|
end
|
44
44
|
end
|
45
|
+
|
46
|
+
def replace_cref(cref)
|
47
|
+
Context.new(@iseq, cref, @mid)
|
48
|
+
end
|
45
49
|
end
|
46
50
|
|
47
51
|
class TypedContext
|
@@ -61,6 +65,10 @@ module TypeProf
|
|
61
65
|
"<typed-context:#{ @mid }>"
|
62
66
|
end
|
63
67
|
end
|
68
|
+
|
69
|
+
def replace_cref(cref)
|
70
|
+
# What to do?
|
71
|
+
end
|
64
72
|
end
|
65
73
|
|
66
74
|
class ExecutionPoint
|
@@ -86,6 +94,10 @@ module TypeProf
|
|
86
94
|
ExecutionPoint.new(@ctx, @pc + 1, @outer)
|
87
95
|
end
|
88
96
|
|
97
|
+
def replace_cref(cref)
|
98
|
+
ExecutionPoint.new(@ctx.replace_cref(cref), @pc, @outer)
|
99
|
+
end
|
100
|
+
|
89
101
|
def source_location
|
90
102
|
@ctx.source_location(@pc)
|
91
103
|
end
|
@@ -238,6 +250,8 @@ module TypeProf
|
|
238
250
|
end
|
239
251
|
|
240
252
|
def initialize
|
253
|
+
@entrypoints = []
|
254
|
+
|
241
255
|
@worklist = Utils::WorkList.new
|
242
256
|
|
243
257
|
@ep2env = {}
|
@@ -272,6 +286,10 @@ module TypeProf
|
|
272
286
|
@anonymous_struct_gen_id = 0
|
273
287
|
end
|
274
288
|
|
289
|
+
def add_entrypoint(iseq)
|
290
|
+
@entrypoints << iseq
|
291
|
+
end
|
292
|
+
|
275
293
|
attr_reader :return_envs, :loaded_features, :rbs_reader
|
276
294
|
|
277
295
|
def get_env(ep)
|
@@ -878,56 +896,68 @@ module TypeProf
|
|
878
896
|
iter_counter = 0
|
879
897
|
stat_eps = Utils::MutableSet.new
|
880
898
|
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
899
|
+
prologue_ctx = Context.new(nil, nil, nil)
|
900
|
+
prologue_ep = ExecutionPoint.new(prologue_ctx, -1, nil)
|
901
|
+
prologue_env = Env.new(StaticEnv.new(Type.bot, Type.nil, false, true), [], [], Utils::HashWrapper.new({}))
|
902
|
+
|
903
|
+
until @entrypoints.empty?
|
904
|
+
iseq = @entrypoints.shift
|
905
|
+
ep, env = TypeProf.starting_state(iseq)
|
906
|
+
merge_env(ep, env)
|
907
|
+
add_callsite!(ep.ctx, prologue_ep, prologue_env) {|ty, ep| }
|
908
|
+
|
909
|
+
while true
|
910
|
+
until @worklist.empty?
|
911
|
+
ep = @worklist.deletemin
|
912
|
+
|
913
|
+
iter_counter += 1
|
914
|
+
if Config.options[:show_indicator]
|
915
|
+
tick2 = Time.now
|
916
|
+
if tick2 - tick >= 1
|
917
|
+
tick = tick2
|
918
|
+
$stderr << "\rType Profiling... (%d instructions @ %s)\e[K" % [iter_counter, ep.source_location]
|
919
|
+
$stderr.flush
|
920
|
+
end
|
892
921
|
end
|
893
|
-
end
|
894
922
|
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
923
|
+
if (Config.max_sec && Time.now - start_time >= Config.max_sec) || (Config.max_iter && Config.max_iter <= iter_counter)
|
924
|
+
@terminated = true
|
925
|
+
break
|
926
|
+
end
|
899
927
|
|
900
|
-
|
901
|
-
|
902
|
-
|
928
|
+
stat_eps << ep
|
929
|
+
step(ep)
|
930
|
+
end
|
903
931
|
|
904
|
-
|
932
|
+
break if @terminated
|
905
933
|
|
906
|
-
|
934
|
+
break unless Config.options[:stub_execution]
|
907
935
|
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
936
|
+
begin
|
937
|
+
iseq, (kind, dummy_continuation) = @pending_execution.first
|
938
|
+
break if !iseq
|
939
|
+
@pending_execution.delete(iseq)
|
940
|
+
end while @executed_iseqs.include?(iseq)
|
913
941
|
|
914
|
-
|
942
|
+
puts "DEBUG: trigger stub execution (#{ iseq&.name || "(nil)" }): rest #{ @pending_execution.size }" if Config.verbose >= 2
|
915
943
|
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
merge_env(ep, env)
|
921
|
-
add_iseq_method_call!(meth, ep.ctx)
|
922
|
-
|
923
|
-
when :block
|
924
|
-
blk, epenvs = dummy_continuation
|
925
|
-
epenvs.each do |ep, env|
|
944
|
+
break if !iseq
|
945
|
+
case kind
|
946
|
+
when :method
|
947
|
+
meth, ep, env = dummy_continuation
|
926
948
|
merge_env(ep, env)
|
927
|
-
|
949
|
+
add_iseq_method_call!(meth, ep.ctx)
|
950
|
+
|
951
|
+
when :block
|
952
|
+
blk, epenvs = dummy_continuation
|
953
|
+
epenvs.each do |ep, env|
|
954
|
+
merge_env(ep, env)
|
955
|
+
add_block_to_ctx!(blk.block_body, ep.ctx)
|
956
|
+
end
|
928
957
|
end
|
929
958
|
end
|
930
959
|
end
|
960
|
+
|
931
961
|
$stderr.print "\r\e[K" if Config.options[:show_indicator]
|
932
962
|
|
933
963
|
stat_eps
|
@@ -1245,7 +1275,13 @@ module TypeProf
|
|
1245
1275
|
end
|
1246
1276
|
if cbase.is_a?(Type::Class)
|
1247
1277
|
klass = new_class(cbase, id, [], superclass, ep.ctx.iseq.absolute_path)
|
1248
|
-
|
1278
|
+
if superclass
|
1279
|
+
add_superclass_type_args!(klass, superclass.type_params.map { Type.any })
|
1280
|
+
|
1281
|
+
# inherited hook
|
1282
|
+
aargs = ActualArguments.new([klass], nil, {}, Type.nil)
|
1283
|
+
do_send(superclass, :inherited, aargs, ep, env) {|_ret_ty, _ep| }
|
1284
|
+
end
|
1249
1285
|
else
|
1250
1286
|
klass = Type.any
|
1251
1287
|
end
|
@@ -2091,10 +2127,10 @@ module TypeProf
|
|
2091
2127
|
end
|
2092
2128
|
end
|
2093
2129
|
|
2094
|
-
def do_invoke_block(blk, aargs, ep, env, replace_recv_ty: nil, &ctn)
|
2130
|
+
def do_invoke_block(blk, aargs, ep, env, replace_recv_ty: nil, replace_cref: nil, &ctn)
|
2095
2131
|
blk.each_child do |blk|
|
2096
2132
|
if blk.is_a?(Type::Proc)
|
2097
|
-
blk.block_body.do_call(aargs, ep, env, self, replace_recv_ty: replace_recv_ty, &ctn)
|
2133
|
+
blk.block_body.do_call(aargs, ep, env, self, replace_recv_ty: replace_recv_ty, replace_cref: replace_cref, &ctn)
|
2098
2134
|
else
|
2099
2135
|
warn(ep, "non-proc is passed as a block")
|
2100
2136
|
ctn[Type.any, ep, env]
|
data/lib/typeprof/block.rb
CHANGED
@@ -27,7 +27,7 @@ module TypeProf
|
|
27
27
|
self
|
28
28
|
end
|
29
29
|
|
30
|
-
def do_call(aargs, caller_ep, caller_env, scratch, replace_recv_ty:, &ctn)
|
30
|
+
def do_call(aargs, caller_ep, caller_env, scratch, replace_recv_ty:, replace_cref:, &ctn)
|
31
31
|
blk_env = scratch.return_envs[@outer_ep]
|
32
32
|
if replace_recv_ty
|
33
33
|
replace_recv_ty = scratch.globalize_type(replace_recv_ty, caller_env, caller_ep)
|
@@ -46,7 +46,8 @@ module TypeProf
|
|
46
46
|
return
|
47
47
|
end
|
48
48
|
|
49
|
-
|
49
|
+
cref = replace_cref || @outer_ep.ctx.cref
|
50
|
+
nctx = Context.new(@iseq, cref, nil)
|
50
51
|
callee_ep = ExecutionPoint.new(nctx, 0, @outer_ep)
|
51
52
|
nenv = Env.new(blk_env.static_env, locals, [], nil)
|
52
53
|
alloc_site = AllocationSite.new(callee_ep)
|
@@ -87,7 +88,7 @@ module TypeProf
|
|
87
88
|
TypedBlock.new(msig, ret_ty)
|
88
89
|
end
|
89
90
|
|
90
|
-
def do_call(aargs, caller_ep, caller_env, scratch, replace_recv_ty:, &ctn)
|
91
|
+
def do_call(aargs, caller_ep, caller_env, scratch, replace_recv_ty:, replace_cref:, &ctn)
|
91
92
|
aargs = scratch.globalize_type(aargs, caller_env, caller_ep)
|
92
93
|
subst = aargs.consistent_with_method_signature?(@msig)
|
93
94
|
unless subst
|
@@ -119,7 +120,7 @@ module TypeProf
|
|
119
120
|
self
|
120
121
|
end
|
121
122
|
|
122
|
-
def do_call(aargs, caller_ep, caller_env, scratch, replace_recv_ty:, &ctn)
|
123
|
+
def do_call(aargs, caller_ep, caller_env, scratch, replace_recv_ty:, replace_cref:, &ctn)
|
123
124
|
if aargs.lead_tys.size >= 1
|
124
125
|
recv = aargs.lead_tys[0]
|
125
126
|
recv = Type.any if recv == Type.bot
|
@@ -157,7 +158,7 @@ module TypeProf
|
|
157
158
|
self
|
158
159
|
end
|
159
160
|
|
160
|
-
def do_call(aargs, caller_ep, caller_env, scratch, replace_recv_ty:, &ctn)
|
161
|
+
def do_call(aargs, caller_ep, caller_env, scratch, replace_recv_ty:, replace_cref:, &ctn)
|
161
162
|
aargs = scratch.globalize_type(aargs, caller_env, caller_ep)
|
162
163
|
|
163
164
|
dummy_ctx = TypedContext.new(@caller_ep, @mid)
|
@@ -165,7 +166,7 @@ module TypeProf
|
|
165
166
|
scratch.add_block_signature!(self, aargs.to_block_signature)
|
166
167
|
scratch.add_block_to_ctx!(self, dummy_ctx)
|
167
168
|
|
168
|
-
@blk.call(aargs, caller_ep, caller_env, scratch, replace_recv_ty: replace_recv_ty) do |ret_ty, ep, env|
|
169
|
+
@blk.call(aargs, caller_ep, caller_env, scratch, replace_recv_ty: replace_recv_ty, replace_cref: replace_cref) do |ret_ty, ep, env|
|
169
170
|
scratch.add_return_value!(dummy_ctx, ret_ty)
|
170
171
|
ctn[ret_ty, ep, env]
|
171
172
|
end
|
data/lib/typeprof/builtin.rb
CHANGED
@@ -158,7 +158,22 @@ module TypeProf
|
|
158
158
|
naargs = ActualArguments.new([recv], nil, {}, Type.nil)
|
159
159
|
nrecv = recv
|
160
160
|
nrecv = nrecv.base_type if nrecv.is_a?(Type::ContainerType)
|
161
|
-
scratch.do_invoke_block(aargs.blk_ty, naargs, ep, env, replace_recv_ty: nrecv) do |
|
161
|
+
scratch.do_invoke_block(aargs.blk_ty, naargs, ep, env, replace_recv_ty: nrecv) do |ret_ty, ep|
|
162
|
+
ctn[ret_ty, ep, env]
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
def object_module_eval(recv, mid, aargs, ep, env, scratch, &ctn)
|
167
|
+
if aargs.lead_tys.size >= 1
|
168
|
+
scratch.warn(ep, "class_eval with arguments is ignored")
|
169
|
+
ctn[Type.any, ep, env]
|
170
|
+
return
|
171
|
+
end
|
172
|
+
naargs = ActualArguments.new([recv], nil, {}, Type.nil)
|
173
|
+
nrecv = recv
|
174
|
+
nrecv = nrecv.base_type if nrecv.is_a?(Type::ContainerType)
|
175
|
+
ncref = ep.ctx.cref.extend(nrecv, true)
|
176
|
+
scratch.do_invoke_block(aargs.blk_ty, naargs, ep, env, replace_recv_ty: nrecv, replace_cref: ncref) do |_ret_ty, ep|
|
162
177
|
ctn[recv, ep, env]
|
163
178
|
end
|
164
179
|
end
|
@@ -176,7 +191,7 @@ module TypeProf
|
|
176
191
|
end
|
177
192
|
|
178
193
|
elem_ty = Type.bot
|
179
|
-
enum_for_blk = CustomBlock.new(ep, mid) do |aargs, caller_ep, caller_env, scratch, replace_recv_ty:, &blk_ctn|
|
194
|
+
enum_for_blk = CustomBlock.new(ep, mid) do |aargs, caller_ep, caller_env, scratch, replace_recv_ty:, replace_cref:, &blk_ctn|
|
180
195
|
if aargs.lead_tys.size >= 1
|
181
196
|
elem_ty = elem_ty.union(aargs.lead_tys[0])
|
182
197
|
else
|
@@ -235,9 +250,12 @@ module TypeProf
|
|
235
250
|
return ctn[Type.any, ep, env]
|
236
251
|
end
|
237
252
|
|
253
|
+
# support multiple arguments: include M1, M2
|
238
254
|
arg = aargs.lead_tys[0]
|
239
255
|
arg.each_child do |arg|
|
240
256
|
if arg.is_a?(Type::Class)
|
257
|
+
aargs = ActualArguments.new([recv], nil, {}, Type.nil)
|
258
|
+
scratch.do_send(arg, :included, aargs, ep, env) {|_ret_ty, _ep| }
|
241
259
|
scratch.mix_module(:after, recv, arg, nil, ep.ctx.cref.singleton, ep)
|
242
260
|
end
|
243
261
|
end
|
@@ -259,6 +277,8 @@ module TypeProf
|
|
259
277
|
arg = aargs.lead_tys[0]
|
260
278
|
arg.each_child do |arg|
|
261
279
|
if arg.is_a?(Type::Class)
|
280
|
+
aargs = ActualArguments.new([recv], nil, {}, Type.nil)
|
281
|
+
scratch.do_send(arg, :extended, aargs, ep, env) {|_ret_ty, _ep| }
|
262
282
|
# if ep.ctx.cref.singleton is true, the meta-meta level is ignored. Should we warn?
|
263
283
|
scratch.mix_module(:after, recv, arg, nil, true, ep)
|
264
284
|
end
|
@@ -804,9 +824,11 @@ module TypeProf
|
|
804
824
|
scratch.set_custom_method(klass_module, :public, Builtin.method(:module_public), false)
|
805
825
|
scratch.set_custom_method(klass_module, :private, Builtin.method(:module_private), false)
|
806
826
|
scratch.set_custom_method(klass_module, :define_method, Builtin.method(:module_define_method))
|
807
|
-
scratch.set_custom_method(klass_module, :
|
808
|
-
scratch.set_custom_method(klass_module, :
|
809
|
-
scratch.set_custom_method(klass_module, :
|
827
|
+
scratch.set_custom_method(klass_module, :attr_accessor, Builtin.method(:module_attr_accessor))
|
828
|
+
scratch.set_custom_method(klass_module, :attr_reader, Builtin.method(:module_attr_reader))
|
829
|
+
scratch.set_custom_method(klass_module, :attr_writer, Builtin.method(:module_attr_writer))
|
830
|
+
scratch.set_custom_method(klass_module, :class_eval, Builtin.method(:object_module_eval))
|
831
|
+
scratch.set_custom_method(klass_module, :module_eval, Builtin.method(:object_module_eval))
|
810
832
|
|
811
833
|
scratch.set_custom_method(klass_proc, :[], Builtin.method(:proc_call))
|
812
834
|
scratch.set_custom_method(klass_proc, :call, Builtin.method(:proc_call))
|
data/lib/typeprof/config.rb
CHANGED
@@ -80,21 +80,6 @@ module TypeProf
|
|
80
80
|
Import.import_library(scratch, feature)
|
81
81
|
end
|
82
82
|
|
83
|
-
prologue_ctx = Context.new(nil, nil, nil)
|
84
|
-
prologue_ep = ExecutionPoint.new(prologue_ctx, -1, nil)
|
85
|
-
prologue_env = Env.new(StaticEnv.new(Type.bot, Type.nil, false, true), [], [], Utils::HashWrapper.new({}))
|
86
|
-
|
87
|
-
Config.rb_files.each do |rb|
|
88
|
-
if rb.is_a?(Array) # [String name, String content]
|
89
|
-
iseq = ISeq.compile_str(*rb.reverse)
|
90
|
-
else
|
91
|
-
iseq = ISeq.compile(rb)
|
92
|
-
end
|
93
|
-
ep, env = TypeProf.starting_state(iseq)
|
94
|
-
scratch.merge_env(ep, env)
|
95
|
-
scratch.add_callsite!(ep.ctx, prologue_ep, prologue_env) {|ty, ep| }
|
96
|
-
end
|
97
|
-
|
98
83
|
rbs_files = []
|
99
84
|
rbs_codes = []
|
100
85
|
Config.rbs_files.each do |rbs|
|
@@ -109,6 +94,15 @@ module TypeProf
|
|
109
94
|
Import.import_rbs_code(scratch, name, content)
|
110
95
|
end
|
111
96
|
|
97
|
+
Config.rb_files.each do |rb|
|
98
|
+
if rb.is_a?(Array) # [String name, String content]
|
99
|
+
iseq = ISeq.compile_str(*rb.reverse)
|
100
|
+
else
|
101
|
+
iseq = ISeq.compile(rb)
|
102
|
+
end
|
103
|
+
scratch.add_entrypoint(iseq)
|
104
|
+
end
|
105
|
+
|
112
106
|
result = scratch.type_profile
|
113
107
|
|
114
108
|
if Config.output.respond_to?(:write)
|
data/lib/typeprof/export.rb
CHANGED
@@ -137,18 +137,17 @@ module TypeProf
|
|
137
137
|
ctxs = @iseq_method_to_ctxs[mdef]
|
138
138
|
next unless ctxs
|
139
139
|
|
140
|
-
ctxs.
|
141
|
-
next if mid != ctx.mid
|
142
|
-
next if Config.check_dir_filter(ctx.iseq.absolute_path) == :exclude
|
140
|
+
ctx = ctxs.find {|ctx| ctx.mid == mid } || ctxs.first
|
143
141
|
|
144
|
-
|
145
|
-
method_name = "self.#{ method_name }" if singleton
|
142
|
+
next if Config.check_dir_filter(ctx.iseq.absolute_path) == :exclude
|
146
143
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
144
|
+
method_name = mid
|
145
|
+
method_name = "self.#{ method_name }" if singleton
|
146
|
+
|
147
|
+
key = [:iseq, method_name]
|
148
|
+
visibilities[key] ||= mdef.pub_meth
|
149
|
+
source_locations[key] ||= ctx.iseq.source_location(0)
|
150
|
+
(methods[key] ||= []) << @scratch.show_method_signature(ctx)
|
152
151
|
when AliasMethodDef
|
153
152
|
alias_name, orig_name = mid, mdef.orig_mid
|
154
153
|
if singleton
|
data/lib/typeprof/import.rb
CHANGED
@@ -189,11 +189,15 @@ module TypeProf
|
|
189
189
|
when RBS::AST::Members::Include
|
190
190
|
name = member.name
|
191
191
|
if name.kind == :class
|
192
|
+
# including a module
|
192
193
|
mod = conv_type_name(name)
|
193
194
|
type_args = member.args.map {|type| conv_type(type) }
|
194
195
|
modules[:include] << [mod, type_args]
|
195
196
|
else
|
196
|
-
# including an interface
|
197
|
+
# including an interface
|
198
|
+
mod = conv_type_name(name)
|
199
|
+
type_args = member.args.map {|type| conv_type(type) }
|
200
|
+
modules[:include] << [mod, type_args]
|
197
201
|
end
|
198
202
|
|
199
203
|
when RBS::AST::Members::Extend
|
data/lib/typeprof/version.rb
CHANGED
data/smoke/class_eval.rb
ADDED
data/smoke/extended.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
module Foo
|
2
|
+
@extended = []
|
3
|
+
def self.extended(klass)
|
4
|
+
@extended << klass
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
class C
|
9
|
+
extend Foo
|
10
|
+
end
|
11
|
+
|
12
|
+
class D
|
13
|
+
extend Foo
|
14
|
+
end
|
15
|
+
|
16
|
+
class E
|
17
|
+
extend Foo
|
18
|
+
end
|
19
|
+
|
20
|
+
__END__
|
21
|
+
# Classes
|
22
|
+
module Foo
|
23
|
+
self.@extended: Array[singleton(C) | singleton(D) | singleton(E)]
|
24
|
+
|
25
|
+
def self.extended: (singleton(C) | singleton(D) | singleton(E) klass) -> (Array[singleton(C) | singleton(D) | singleton(E)])
|
26
|
+
end
|
27
|
+
|
28
|
+
class C
|
29
|
+
extend Foo
|
30
|
+
end
|
31
|
+
|
32
|
+
class D
|
33
|
+
extend Foo
|
34
|
+
end
|
35
|
+
|
36
|
+
class E
|
37
|
+
extend Foo
|
38
|
+
end
|
data/smoke/included.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
module Foo
|
2
|
+
@included = []
|
3
|
+
def self.included(klass)
|
4
|
+
@included << klass
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
class C
|
9
|
+
include Foo
|
10
|
+
end
|
11
|
+
|
12
|
+
class D
|
13
|
+
include Foo
|
14
|
+
end
|
15
|
+
|
16
|
+
class E
|
17
|
+
include Foo
|
18
|
+
end
|
19
|
+
|
20
|
+
__END__
|
21
|
+
# Classes
|
22
|
+
module Foo
|
23
|
+
self.@included: Array[singleton(C) | singleton(D) | singleton(E)]
|
24
|
+
|
25
|
+
def self.included: (singleton(C) | singleton(D) | singleton(E) klass) -> (Array[singleton(C) | singleton(D) | singleton(E)])
|
26
|
+
end
|
27
|
+
|
28
|
+
class C
|
29
|
+
include Foo
|
30
|
+
end
|
31
|
+
|
32
|
+
class D
|
33
|
+
include Foo
|
34
|
+
end
|
35
|
+
|
36
|
+
class E
|
37
|
+
include Foo
|
38
|
+
end
|
data/smoke/inherited.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
class Foo
|
2
|
+
@inherited = []
|
3
|
+
def self.inherited(klass)
|
4
|
+
@inherited << klass
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
class Bar < Foo
|
9
|
+
end
|
10
|
+
|
11
|
+
class Baz < Foo
|
12
|
+
end
|
13
|
+
|
14
|
+
__END__
|
15
|
+
# Classes
|
16
|
+
class Foo
|
17
|
+
self.@inherited: Array[singleton(Bar) | singleton(Baz)]
|
18
|
+
|
19
|
+
def self.inherited: (singleton(Bar) | singleton(Baz) klass) -> (Array[singleton(Bar) | singleton(Baz)])
|
20
|
+
end
|
21
|
+
|
22
|
+
class Bar < Foo
|
23
|
+
end
|
24
|
+
|
25
|
+
class Baz < Foo
|
26
|
+
end
|
data/smoke/instance_eval.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: typeprof
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yusuke Endoh
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rbs
|
@@ -145,6 +145,7 @@ files:
|
|
145
145
|
- smoke/class-hierarchy2.rb
|
146
146
|
- smoke/class-new.rb
|
147
147
|
- smoke/class.rb
|
148
|
+
- smoke/class_eval.rb
|
148
149
|
- smoke/class_instance_var.rb
|
149
150
|
- smoke/class_method.rb
|
150
151
|
- smoke/class_method2.rb
|
@@ -164,6 +165,7 @@ files:
|
|
164
165
|
- smoke/define_method4.rbs
|
165
166
|
- smoke/define_method5.rb
|
166
167
|
- smoke/define_method6.rb
|
168
|
+
- smoke/define_method7.rb
|
167
169
|
- smoke/demo.rb
|
168
170
|
- smoke/demo1.rb
|
169
171
|
- smoke/demo10.rb
|
@@ -185,6 +187,7 @@ files:
|
|
185
187
|
- smoke/enumerator.rb
|
186
188
|
- smoke/expandarray1.rb
|
187
189
|
- smoke/expandarray2.rb
|
190
|
+
- smoke/extended.rb
|
188
191
|
- smoke/fib.rb
|
189
192
|
- smoke/flip-flop.rb
|
190
193
|
- smoke/flow1.rb
|
@@ -211,12 +214,15 @@ files:
|
|
211
214
|
- smoke/hash3.rb
|
212
215
|
- smoke/hash4.rb
|
213
216
|
- smoke/hash5.rb
|
217
|
+
- smoke/included.rb
|
214
218
|
- smoke/inheritance.rb
|
215
219
|
- smoke/inheritance2.rb
|
220
|
+
- smoke/inherited.rb
|
216
221
|
- smoke/initialize.rb
|
217
222
|
- smoke/instance_eval.rb
|
218
223
|
- smoke/instance_eval2.rb
|
219
224
|
- smoke/instance_eval3.rb
|
225
|
+
- smoke/instance_eval4.rb
|
220
226
|
- smoke/int_times.rb
|
221
227
|
- smoke/integer.rb
|
222
228
|
- smoke/ivar.rb
|