typeprof 0.20.4 → 0.21.0
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/Gemfile.lock +5 -5
- data/lib/typeprof/analyzer.rb +53 -13
- data/lib/typeprof/block.rb +2 -1
- data/lib/typeprof/container-type.rb +3 -2
- data/lib/typeprof/export.rb +39 -4
- data/lib/typeprof/import.rb +33 -4
- data/lib/typeprof/iseq.rb +1 -1
- data/lib/typeprof/method.rb +25 -4
- data/lib/typeprof/version.rb +1 -1
- data/typeprof.gemspec +1 -1
- data/vscode/src/extension.ts +3 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18bdb9e24afde0cb827e78bc77825f9d316fa4959f0276b961f8fd897787810a
|
4
|
+
data.tar.gz: '095fdf956b09a88940adfe99f68bc6d6afe6d01f2e521b0ca8801691b3df7ab3'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df332ec8c3b08f13d6bf35dd3ae60604ddb31ea4e27d959b0c027b0fb616ab74df582b292ff27169daf6a962f34b21550a21214826ac8a2815829a57b94dd5ed
|
7
|
+
data.tar.gz: cf47173a218dca213e96cc3ebeb84b86c1376cca6f5f06703fb95c1d3de6c0d289d719324ac9d887eefbb36662458bd636250239389fe16bd0f34a66f402abb7
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
typeprof (0.
|
5
|
-
rbs (>= 1.
|
4
|
+
typeprof (0.21.0)
|
5
|
+
rbs (>= 1.8.1)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
@@ -11,7 +11,7 @@ GEM
|
|
11
11
|
docile (1.4.0)
|
12
12
|
power_assert (2.0.1)
|
13
13
|
rake (13.0.1)
|
14
|
-
rbs (1.
|
14
|
+
rbs (1.8.1)
|
15
15
|
simplecov (0.21.2)
|
16
16
|
docile (~> 1.1)
|
17
17
|
simplecov-html (~> 0.11)
|
@@ -19,7 +19,7 @@ GEM
|
|
19
19
|
simplecov-html (0.12.3)
|
20
20
|
simplecov_json_formatter (0.1.3)
|
21
21
|
stackprof (0.2.17)
|
22
|
-
test-unit (3.5.
|
22
|
+
test-unit (3.5.3)
|
23
23
|
power_assert
|
24
24
|
|
25
25
|
PLATFORMS
|
@@ -36,4 +36,4 @@ DEPENDENCIES
|
|
36
36
|
typeprof!
|
37
37
|
|
38
38
|
BUNDLED WITH
|
39
|
-
2.
|
39
|
+
2.3.0.dev
|
data/lib/typeprof/analyzer.rb
CHANGED
@@ -345,7 +345,7 @@ module TypeProf
|
|
345
345
|
attr_reader :class_defs
|
346
346
|
|
347
347
|
class ClassDef # or ModuleDef
|
348
|
-
def initialize(kind, name, absolute_path)
|
348
|
+
def initialize(kind, name, absolute_path, superclass)
|
349
349
|
raise unless name.is_a?(Array)
|
350
350
|
@kind = kind
|
351
351
|
@modules = {
|
@@ -359,10 +359,11 @@ module TypeProf
|
|
359
359
|
@cvars = VarTable.new
|
360
360
|
@absolute_path = absolute_path
|
361
361
|
@namespace = nil
|
362
|
+
@superclass = superclass
|
362
363
|
@subclasses = []
|
363
364
|
end
|
364
365
|
|
365
|
-
attr_reader :kind, :modules, :methods, :ivars, :cvars, :absolute_path, :subclasses
|
366
|
+
attr_reader :kind, :modules, :methods, :ivars, :cvars, :absolute_path, :superclass, :subclasses
|
366
367
|
attr_accessor :name, :klass_obj
|
367
368
|
|
368
369
|
def mix_module(kind, mod, type_args, singleton, absolute_path)
|
@@ -446,14 +447,22 @@ module TypeProf
|
|
446
447
|
end
|
447
448
|
end
|
448
449
|
|
449
|
-
def
|
450
|
+
def check_typed(mid, singleton, klass)
|
450
451
|
set = @methods[[singleton, mid]]
|
451
452
|
return nil unless set
|
452
|
-
set = set.select {|mdef| mdef.is_a?(
|
453
|
+
set = set.select {|mdef| mdef.is_a?(klass) }
|
453
454
|
return nil if set.empty?
|
454
455
|
return set
|
455
456
|
end
|
456
457
|
|
458
|
+
def check_typed_method(mid, singleton)
|
459
|
+
check_typed(mid, singleton, TypedMethodDef)
|
460
|
+
end
|
461
|
+
|
462
|
+
def check_typed_attr(mid, singleton)
|
463
|
+
check_typed(mid, singleton, TypedAttrMethodDef)
|
464
|
+
end
|
465
|
+
|
457
466
|
def add_method(mid, singleton, mdef)
|
458
467
|
@methods[[singleton, mid]] ||= Utils::MutableSet.new
|
459
468
|
@methods[[singleton, mid]] << mdef
|
@@ -494,8 +503,9 @@ module TypeProf
|
|
494
503
|
show_name = cbase_path(cbase) + [name]
|
495
504
|
idx = @class_defs.size
|
496
505
|
if superclass
|
497
|
-
@class_defs[idx]
|
498
|
-
@class_defs[
|
506
|
+
superclass_def = @class_defs[superclass.idx] unless superclass == :__root__
|
507
|
+
@class_defs[idx] = ClassDef.new(:class, show_name, def_ep&.absolute_path, superclass_def)
|
508
|
+
superclass_def.subclasses << idx if superclass_def
|
499
509
|
klass = Type::Class.new(:class, idx, type_params, superclass, show_name)
|
500
510
|
@class_defs[idx].klass_obj = klass
|
501
511
|
cbase ||= klass # for bootstrap
|
@@ -503,7 +513,7 @@ module TypeProf
|
|
503
513
|
return klass
|
504
514
|
else
|
505
515
|
# module
|
506
|
-
@class_defs[idx] = ClassDef.new(:module, show_name, def_ep&.absolute_path)
|
516
|
+
@class_defs[idx] = ClassDef.new(:module, show_name, def_ep&.absolute_path, nil)
|
507
517
|
mod = Type::Class.new(:module, idx, type_params, nil, show_name)
|
508
518
|
@class_defs[idx].klass_obj = mod
|
509
519
|
add_constant(cbase, name, mod, def_ep)
|
@@ -521,7 +531,8 @@ module TypeProf
|
|
521
531
|
idx = @class_defs.size
|
522
532
|
superclass = Type::Builtin[:struct]
|
523
533
|
name = "AnonymousStruct_generated_#{ @anonymous_struct_gen_id += 1 }"
|
524
|
-
|
534
|
+
# Should we pass a superclass here?
|
535
|
+
@class_defs[idx] = ClassDef.new(:class, [name], ep.ctx.iseq.absolute_path, nil)
|
525
536
|
#@class_defs[superclass.idx].subclasses << idx # needed?
|
526
537
|
klass = Type::Class.new(:class, idx, [], superclass, name)
|
527
538
|
add_superclass_type_args!(klass, [Type.any])
|
@@ -701,6 +712,10 @@ module TypeProf
|
|
701
712
|
@class_defs[klass.idx].check_typed_method(mid, singleton)
|
702
713
|
end
|
703
714
|
|
715
|
+
def check_typed_attr(klass, mid, singleton)
|
716
|
+
@class_defs[klass.idx].check_typed_attr(mid, singleton)
|
717
|
+
end
|
718
|
+
|
704
719
|
def add_method(klass, mid, singleton, mdef)
|
705
720
|
@class_defs[klass.idx].add_method(mid, singleton, mdef)
|
706
721
|
mdef
|
@@ -713,13 +728,26 @@ module TypeProf
|
|
713
728
|
|
714
729
|
def add_attr_method(klass, mid, ivar, kind, pub_meth, ep)
|
715
730
|
if kind == :reader || kind == :accessor
|
716
|
-
|
731
|
+
typed_mdef = check_typed_attr(klass, mid, ep.ctx.cref.singleton)
|
732
|
+
unless typed_mdef
|
733
|
+
add_method(klass, mid, false, ExecutedAttrMethodDef.new(ivar, :reader, pub_meth, ep))
|
734
|
+
end
|
717
735
|
end
|
718
736
|
if kind == :writer || kind == :accessor
|
719
|
-
|
737
|
+
mid = :"#{ mid }="
|
738
|
+
typed_mdef = check_typed_attr(klass, mid, ep.ctx.cref.singleton)
|
739
|
+
unless typed_mdef
|
740
|
+
add_method(klass, mid, false, ExecutedAttrMethodDef.new(ivar, :writer, pub_meth, ep))
|
741
|
+
end
|
720
742
|
end
|
721
743
|
end
|
722
744
|
|
745
|
+
def add_typed_attr_method(klass, mdef)
|
746
|
+
name = mdef.ivar[1..-1]
|
747
|
+
name = mdef.kind == :writer ? :"#{ name }=" : name.to_sym
|
748
|
+
add_method(klass, name, false, mdef)
|
749
|
+
end
|
750
|
+
|
723
751
|
def add_iseq_method(klass, mid, iseq, cref, outer_ep, pub_meth)
|
724
752
|
add_method(klass, mid, false, ISeqMethodDef.new(iseq, cref, outer_ep, pub_meth))
|
725
753
|
end
|
@@ -848,7 +876,7 @@ module TypeProf
|
|
848
876
|
end
|
849
877
|
entry.type = entry.type.union(ty)
|
850
878
|
entry.read_continuations.each do |read_ep, ctn|
|
851
|
-
ctn[ty, read_ep, [ep]]
|
879
|
+
ctn[ty, read_ep, ep ? [ep] : []]
|
852
880
|
end
|
853
881
|
end
|
854
882
|
|
@@ -1393,9 +1421,12 @@ module TypeProf
|
|
1393
1421
|
num, = operands
|
1394
1422
|
env, = env.pop(num)
|
1395
1423
|
env = env.push(Type::Instance.new(Type::Builtin[:str]))
|
1396
|
-
when :tostring, :
|
1424
|
+
when :tostring, :anytostring
|
1397
1425
|
env, (_ty1, _ty2,) = env.pop(2)
|
1398
1426
|
env = env.push(Type::Instance.new(Type::Builtin[:str]))
|
1427
|
+
when :objtostring
|
1428
|
+
env, (_ty1,) = env.pop(1)
|
1429
|
+
env = env.push(Type::Instance.new(Type::Builtin[:str]))
|
1399
1430
|
when :freezestring
|
1400
1431
|
# do nothing
|
1401
1432
|
when :toregexp
|
@@ -1418,7 +1449,16 @@ module TypeProf
|
|
1418
1449
|
cref = ep.ctx.cref
|
1419
1450
|
recv.each_child do |recv|
|
1420
1451
|
if recv.is_a?(Type::Class)
|
1421
|
-
|
1452
|
+
typed_mdef = check_typed_method(recv, mid, true)
|
1453
|
+
if typed_mdef
|
1454
|
+
mdef = ISeqMethodDef.new(iseq, cref, nil, env.static_env.pub_meth)
|
1455
|
+
typed_mdef.each do |typed_mdef|
|
1456
|
+
typed_mdef.do_match_iseq_mdef(mdef, recv, mid, env, ep, self)
|
1457
|
+
end
|
1458
|
+
else
|
1459
|
+
meth = add_singleton_iseq_method(recv, mid, iseq, cref, nil, env.static_env.pub_meth)
|
1460
|
+
end
|
1461
|
+
|
1422
1462
|
pend_method_execution(iseq, meth, recv, mid, ep.ctx.cref, nil)
|
1423
1463
|
else
|
1424
1464
|
recv = Type.any # XXX: what to do?
|
data/lib/typeprof/block.rb
CHANGED
@@ -97,7 +97,8 @@ module TypeProf
|
|
97
97
|
# check?
|
98
98
|
#subst = { Type::Var.new(:self) => caller_env.static_env.recv_ty }
|
99
99
|
# XXX: Update type vars
|
100
|
-
|
100
|
+
ret_ty = @ret_ty.remove_type_vars
|
101
|
+
ctn[ret_ty, caller_ep, caller_env]
|
101
102
|
end
|
102
103
|
end
|
103
104
|
|
@@ -227,8 +227,9 @@ module TypeProf
|
|
227
227
|
|
228
228
|
def screen_name(scratch)
|
229
229
|
str = @elems.screen_name(scratch)
|
230
|
-
if str
|
231
|
-
str = @base_type.
|
230
|
+
if str =~ /\A\*\[(.*)\]\z/
|
231
|
+
str = @base_type.klass.type_params.map {|var_name,| var_name == :Elem ? $1 : "untyped" }.join(", ")
|
232
|
+
str = "#{ @base_type.screen_name(scratch) }[#{ str }]"
|
232
233
|
end
|
233
234
|
str
|
234
235
|
end
|
data/lib/typeprof/export.rb
CHANGED
@@ -163,8 +163,7 @@ module TypeProf
|
|
163
163
|
visibilities[key] ||= mdef.pub_meth
|
164
164
|
source_locations[key] ||= mdef.def_ep&.source_location
|
165
165
|
methods[key] = orig_name
|
166
|
-
when
|
167
|
-
next if !mdef.def_ep
|
166
|
+
when ExecutedAttrMethodDef
|
168
167
|
absolute_path = mdef.def_ep.ctx.iseq.absolute_path
|
169
168
|
next if !absolute_path || Config.current.check_dir_filter(absolute_path) == :exclude
|
170
169
|
mid = mid.to_s[0..-2].to_sym if mid.to_s.end_with?("=")
|
@@ -191,14 +190,46 @@ module TypeProf
|
|
191
190
|
visibilities[key] ||= mdef.pub_meth
|
192
191
|
source_locations[key] ||= mdef.iseq&.source_location(0)
|
193
192
|
end
|
193
|
+
when TypedAttrMethodDef
|
194
|
+
if mdef.rbs_source
|
195
|
+
mid = mid.to_s[0..-2].to_sym if mid.to_s.end_with?("=")
|
196
|
+
method_name = mid
|
197
|
+
method_name = [method_name, :"@#{ mid }" != mdef.ivar]
|
198
|
+
key = [:rbs_attr, method_name]
|
199
|
+
visibilities[key] ||= mdef.pub_meth
|
200
|
+
if methods[key]
|
201
|
+
if methods[key][0] != mdef.kind
|
202
|
+
methods[key][0] = :accessor
|
203
|
+
end
|
204
|
+
else
|
205
|
+
entry = ivars[[singleton, mdef.ivar]]
|
206
|
+
ty = entry ? entry.type : Type.any
|
207
|
+
methods[key] = [mdef.kind, ty.screen_name(@scratch), ty.include_untyped?(@scratch)]
|
208
|
+
end
|
209
|
+
end
|
194
210
|
end
|
195
211
|
end
|
196
212
|
end
|
197
213
|
|
214
|
+
superclass_ivars = {}
|
215
|
+
while (superclass_def = (superclass_def || class_def).superclass)
|
216
|
+
superclass_ivars.merge!(superclass_def.ivars.dump)
|
217
|
+
end
|
218
|
+
|
198
219
|
ivars = ivars.map do |(singleton, var), entry|
|
199
220
|
next if entry.absolute_paths.all? {|path| Config.current.check_dir_filter(path) == :exclude }
|
200
221
|
ty = entry.type
|
201
222
|
next unless var.to_s.start_with?("@")
|
223
|
+
|
224
|
+
if (_, existing = superclass_ivars.find {|((s, v), _)| s == singleton && v == var })
|
225
|
+
existing_types = existing.type.is_a?(Type::Union) ? existing.type.types : [existing.type]
|
226
|
+
entry_types = entry.type.is_a?(Type::Union) ? entry.type.types : [entry.type]
|
227
|
+
if entry_types.all? { |t| existing_types.include?(t) }
|
228
|
+
# This type is a subset of the parent type
|
229
|
+
next
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
202
233
|
var = "self.#{ var }" if singleton
|
203
234
|
next if methods[[:attr, [singleton ? "self.#{ var.to_s[1..] }" : var.to_s[1..].to_sym, false]]]
|
204
235
|
next if entry.rbs_declared
|
@@ -302,7 +333,7 @@ module TypeProf
|
|
302
333
|
visibilities[key] ||= mdef.pub_meth
|
303
334
|
source_locations[key] ||= [mdef.def_ep&.source_location]
|
304
335
|
methods[key] = orig_name
|
305
|
-
when
|
336
|
+
when ExecutedAttrMethodDef
|
306
337
|
next if !mdef.def_ep
|
307
338
|
absolute_path = mdef.def_ep.ctx.iseq.absolute_path
|
308
339
|
next if !absolute_path || Config.current.check_dir_filter(absolute_path) == :exclude
|
@@ -383,7 +414,7 @@ module TypeProf
|
|
383
414
|
source_location, rbs_code_range = class_data.source_locations[key]
|
384
415
|
type, (method_name, hidden) = key
|
385
416
|
case type
|
386
|
-
when :attr
|
417
|
+
when :attr, :rbs_attr
|
387
418
|
kind, ty, untyped = *arg
|
388
419
|
line = "attr_#{ kind } #{ method_name }#{ hidden ? "()" : "" }: #{ ty }"
|
389
420
|
when :rbs
|
@@ -522,11 +553,15 @@ module TypeProf
|
|
522
553
|
end
|
523
554
|
type, (method_name, hidden) = key
|
524
555
|
case type
|
556
|
+
when :rbs_attr
|
557
|
+
kind, ty, untyped = *arg
|
558
|
+
lines << (indent + "# attr_#{ kind } #{ method_name }#{ hidden ? "()" : "" }: #{ ty }")
|
525
559
|
when :attr
|
526
560
|
kind, ty, untyped = *arg
|
527
561
|
exclude = Config.current.options[:exclude_untyped] && untyped ? "#" : " " # XXX
|
528
562
|
lines << (indent + "#{ exclude } attr_#{ kind } #{ method_name }#{ hidden ? "()" : "" }: #{ ty }")
|
529
563
|
when :rbs
|
564
|
+
arg = arg.map { |a| a.split("\n").join("\n" + indent + "#" + " " * (method_name.size + 5)) }
|
530
565
|
sigs = arg.sort.join("\n" + indent + "#" + " " * (method_name.size + 5) + "| ")
|
531
566
|
lines << (indent + "# def #{ method_name }: #{ sigs }")
|
532
567
|
when :iseq
|
data/lib/typeprof/import.rb
CHANGED
@@ -191,12 +191,15 @@ module TypeProf
|
|
191
191
|
when RBS::AST::Members::AttrReader
|
192
192
|
ty = conv_type(member.type)
|
193
193
|
attr_methods[[false, member.name]] = attr_method_def(:reader, member.name, ty, visibility)
|
194
|
+
rbs_sources[[false, member.name]] = attr_rbs_source(member)
|
194
195
|
when RBS::AST::Members::AttrWriter
|
195
196
|
ty = conv_type(member.type)
|
196
197
|
attr_methods[[false, member.name]] = attr_method_def(:writer, member.name, ty, visibility)
|
198
|
+
rbs_sources[[false, member.name]] = attr_rbs_source(member)
|
197
199
|
when RBS::AST::Members::AttrAccessor
|
198
200
|
ty = conv_type(member.type)
|
199
201
|
attr_methods[[false, member.name]] = attr_method_def(:accessor, member.name, ty, visibility)
|
202
|
+
rbs_sources[[false, member.name]] = attr_rbs_source(member)
|
200
203
|
when RBS::AST::Members::Alias
|
201
204
|
# XXX: an alias to attr methods?
|
202
205
|
if member.instance?
|
@@ -394,6 +397,14 @@ module TypeProf
|
|
394
397
|
}
|
395
398
|
end
|
396
399
|
|
400
|
+
def attr_rbs_source(member)
|
401
|
+
[
|
402
|
+
member.name.to_s,
|
403
|
+
member.type.location.source,
|
404
|
+
[member.location.name, CodeRange.from_rbs(member.location)],
|
405
|
+
]
|
406
|
+
end
|
407
|
+
|
397
408
|
def conv_block(rbs_block)
|
398
409
|
blk = rbs_block.type
|
399
410
|
|
@@ -604,11 +615,13 @@ module TypeProf
|
|
604
615
|
end
|
605
616
|
|
606
617
|
attr_methods.each do |(singleton, method_name), mdef|
|
607
|
-
|
608
|
-
ivar = mdef[:ivar]
|
618
|
+
rbs_source = explicit ? rbs_sources[[singleton, method_name]] : nil
|
609
619
|
ty = conv_type(mdef[:ty]).remove_type_vars
|
610
|
-
|
611
|
-
|
620
|
+
mdefs = conv_attr_defs(mdef, rbs_source)
|
621
|
+
mdefs.each do |mdef|
|
622
|
+
@scratch.add_typed_attr_method(klass, mdef)
|
623
|
+
end
|
624
|
+
@scratch.add_ivar_write!(Type::Instance.new(klass), :"@#{ mdef[:ivar] }", ty, nil)
|
612
625
|
end
|
613
626
|
|
614
627
|
ivars.each do |ivar_name, ty|
|
@@ -644,6 +657,22 @@ module TypeProf
|
|
644
657
|
TypedMethodDef.new(sig_rets, rbs_source, mdef[:visibility])
|
645
658
|
end
|
646
659
|
|
660
|
+
def conv_attr_defs(mdef, rbs_source)
|
661
|
+
ivar = :"@#{ mdef[:ivar] }"
|
662
|
+
kind = mdef[:kind]
|
663
|
+
pub_meth = mdef[:visibility]
|
664
|
+
|
665
|
+
defs = []
|
666
|
+
if kind == :reader || kind == :accessor
|
667
|
+
defs << TypedAttrMethodDef.new(ivar, :reader, pub_meth, rbs_source)
|
668
|
+
end
|
669
|
+
if kind == :writer || kind == :accessor
|
670
|
+
defs << TypedAttrMethodDef.new(ivar, :writer, pub_meth, rbs_source)
|
671
|
+
end
|
672
|
+
raise if defs.empty?
|
673
|
+
defs
|
674
|
+
end
|
675
|
+
|
647
676
|
def conv_func(sig_ret)
|
648
677
|
#type_params = sig_ret[:type_params] # XXX
|
649
678
|
lead_tys = sig_ret[:lead_tys]
|
data/lib/typeprof/iseq.rb
CHANGED
@@ -753,7 +753,7 @@ module TypeProf
|
|
753
753
|
when :setlocal, :setblockparam
|
754
754
|
return # conservative
|
755
755
|
when :getinstancevariable, :getclassvariable, :getglobal,
|
756
|
-
:getlocal, :getblockparam, :getblockparamproxy
|
756
|
+
:getlocal, :getblockparam, :getblockparamproxy, :getlocal_checkmatch_branch
|
757
757
|
sp += 1
|
758
758
|
when :getconstant
|
759
759
|
sp -= 2
|
data/lib/typeprof/method.rb
CHANGED
@@ -67,6 +67,10 @@ module TypeProf
|
|
67
67
|
if rest_start
|
68
68
|
# almost ok
|
69
69
|
else
|
70
|
+
if msig.rest_ty
|
71
|
+
scratch.error(ep, "RBS says that a rest argument is accepted, but the method definition does not accept one")
|
72
|
+
return
|
73
|
+
end
|
70
74
|
if msig.lead_tys.size + msig.post_tys.size < lead_num + post_num
|
71
75
|
scratch.error(ep, "RBS says that the arity may be %d, but the method definition requires at least %d arguments" % [msig.lead_tys.size + msig.post_tys.size, lead_num + post_num])
|
72
76
|
return
|
@@ -79,7 +83,6 @@ module TypeProf
|
|
79
83
|
|
80
84
|
lead_num = @iseq.fargs_format[:lead_num] || 0
|
81
85
|
post_start = @iseq.fargs_format[:post_start]
|
82
|
-
rest_start = @iseq.fargs_format[:rest_start]
|
83
86
|
kw_start = @iseq.fargs_format[:kwbits]
|
84
87
|
keyword = @iseq.fargs_format[:keyword]
|
85
88
|
kw_start -= keyword.size if kw_start
|
@@ -175,14 +178,13 @@ module TypeProf
|
|
175
178
|
end
|
176
179
|
|
177
180
|
class AttrMethodDef < MethodDef
|
178
|
-
def initialize(ivar, kind, pub_meth
|
181
|
+
def initialize(ivar, kind, pub_meth)
|
179
182
|
@ivar = ivar
|
180
183
|
@kind = kind # :reader | :writer
|
181
184
|
@pub_meth = pub_meth
|
182
|
-
@def_ep = def_ep
|
183
185
|
end
|
184
186
|
|
185
|
-
attr_reader :ivar, :kind
|
187
|
+
attr_reader :ivar, :kind
|
186
188
|
|
187
189
|
def do_send(recv, mid, aargs, caller_ep, caller_env, scratch, &ctn)
|
188
190
|
case @kind
|
@@ -206,6 +208,25 @@ module TypeProf
|
|
206
208
|
end
|
207
209
|
end
|
208
210
|
|
211
|
+
class ExecutedAttrMethodDef < AttrMethodDef
|
212
|
+
def initialize(ivar, kind, pub_meth, def_ep)
|
213
|
+
super(ivar, kind, pub_meth)
|
214
|
+
@def_ep = def_ep
|
215
|
+
end
|
216
|
+
|
217
|
+
attr_reader :def_ep
|
218
|
+
end
|
219
|
+
|
220
|
+
class TypedAttrMethodDef < AttrMethodDef
|
221
|
+
def initialize(ivar, kind, pub_meth, rbs_source)
|
222
|
+
@rbs_source = rbs_source
|
223
|
+
|
224
|
+
super(ivar, kind, pub_meth)
|
225
|
+
end
|
226
|
+
|
227
|
+
attr_reader :rbs_source
|
228
|
+
end
|
229
|
+
|
209
230
|
class TypedMethodDef < MethodDef
|
210
231
|
def initialize(sig_rets, rbs_source, pub_meth) # sig_rets: Array<[MethodSignature, (return)Type]>
|
211
232
|
@sig_rets = sig_rets
|
data/lib/typeprof/version.rb
CHANGED
data/typeprof.gemspec
CHANGED
data/vscode/src/extension.ts
CHANGED
@@ -88,6 +88,9 @@ function executeTypeProf(folder: vscode.WorkspaceFolder, arg: String): child_pro
|
|
88
88
|
if (shell && (shell.endsWith("bash") || shell.endsWith("zsh") || shell.endsWith("fish"))) {
|
89
89
|
typeprof = child_process.spawn(shell, ["-c", "-l", cmd], { cwd });
|
90
90
|
}
|
91
|
+
else if (process.platform === "win32") {
|
92
|
+
typeprof = child_process.spawn("C:\\Windows\\System32\\cmd.exe", ["/c", cmd], { cwd });
|
93
|
+
}
|
91
94
|
else {
|
92
95
|
typeprof = child_process.spawn(cmd, { cwd });
|
93
96
|
}
|
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.21.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-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rbs
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: 1.8.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: 1.8.1
|
27
27
|
description: |
|
28
28
|
TypeProf performs a type analysis of non-annotated Ruby code.
|
29
29
|
|