typeprof 0.5.3 → 0.8.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 +6 -4
- data/doc/doc.ja.md +3 -4
- data/doc/doc.md +3 -4
- data/lib/typeprof/analyzer.rb +248 -166
- data/lib/typeprof/arguments.rb +12 -6
- data/lib/typeprof/builtin.rb +123 -23
- data/lib/typeprof/cli.rb +33 -34
- data/lib/typeprof/config.rb +6 -4
- data/lib/typeprof/container-type.rb +175 -112
- data/lib/typeprof/export.rb +23 -17
- data/lib/typeprof/import.rb +58 -53
- data/lib/typeprof/method.rb +59 -125
- data/lib/typeprof/type.rb +26 -14
- data/lib/typeprof/version.rb +1 -1
- data/smoke/alias.rb +1 -0
- data/smoke/any1.rb +1 -0
- data/smoke/any2.rb +1 -0
- data/smoke/arguments.rb +1 -0
- data/smoke/arguments2.rb +1 -0
- data/smoke/array-each.rb +1 -0
- data/smoke/array-each2.rb +1 -0
- data/smoke/array-each3.rb +2 -1
- data/smoke/array-ltlt.rb +1 -0
- data/smoke/array-ltlt2.rb +1 -0
- data/smoke/array-map.rb +1 -0
- data/smoke/array-map2.rb +1 -0
- data/smoke/array-map3.rb +1 -0
- data/smoke/array-mul.rb +1 -0
- data/smoke/array-plus1.rb +1 -0
- data/smoke/array-pop.rb +1 -0
- data/smoke/array-range-aref.rb +71 -0
- data/smoke/array-replace.rb +1 -0
- data/smoke/array-s-aref.rb +1 -0
- data/smoke/array1.rb +1 -0
- data/smoke/array10.rb +1 -0
- data/smoke/array11.rb +2 -1
- data/smoke/array12.rb +1 -0
- data/smoke/array13.rb +1 -0
- data/smoke/array14.rb +1 -0
- data/smoke/array2.rb +1 -0
- data/smoke/array4.rb +1 -0
- data/smoke/array5.rb +1 -0
- data/smoke/array6.rb +3 -2
- data/smoke/array7.rb +1 -0
- data/smoke/array8.rb +1 -1
- data/smoke/array9.rb +1 -0
- data/smoke/autoload.rb +14 -0
- data/smoke/backtrace.rb +1 -0
- data/smoke/block-ambiguous.rb +1 -0
- data/smoke/block-args1-rest.rb +1 -0
- data/smoke/block-args1.rb +1 -0
- data/smoke/block-args2-rest.rb +1 -0
- data/smoke/block-args2.rb +4 -3
- data/smoke/block-args3-rest.rb +1 -0
- data/smoke/block-args3.rb +5 -4
- data/smoke/block-blockarg.rb +2 -1
- data/smoke/block-kwarg.rb +1 -0
- data/smoke/block1.rb +1 -0
- data/smoke/block10.rb +1 -0
- data/smoke/block11.rb +1 -0
- data/smoke/block12.rb +1 -0
- data/smoke/block14.rb +1 -0
- data/smoke/block2.rb +1 -0
- data/smoke/block4.rb +1 -0
- data/smoke/block5.rb +2 -1
- data/smoke/block6.rb +1 -0
- data/smoke/block7.rb +1 -0
- data/smoke/block8.rb +1 -0
- data/smoke/block9.rb +1 -0
- data/smoke/blown.rb +1 -0
- data/smoke/break1.rb +1 -0
- data/smoke/break2.rb +1 -0
- data/smoke/case.rb +1 -0
- data/smoke/case2.rb +1 -0
- data/smoke/class_method3.rb +2 -0
- data/smoke/constant2.rb +2 -2
- data/smoke/constant3.rb +1 -0
- data/smoke/constant4.rb +1 -0
- data/smoke/context-sensitive1.rb +1 -0
- data/smoke/cvar.rb +1 -0
- data/smoke/define_method.rb +16 -0
- data/smoke/define_method2.rb +18 -0
- data/smoke/demo.rb +1 -0
- data/smoke/demo1.rb +1 -0
- data/smoke/demo10.rb +1 -0
- data/smoke/demo11.rb +1 -0
- data/smoke/demo2.rb +1 -0
- data/smoke/demo3.rb +1 -0
- data/smoke/demo5.rb +1 -1
- data/smoke/demo7.rb +1 -0
- data/smoke/demo8.rb +1 -0
- data/smoke/demo9.rb +2 -1
- data/smoke/dummy-execution1.rb +1 -0
- data/smoke/ensure1.rb +1 -0
- data/smoke/enumerator.rb +1 -0
- data/smoke/expandarray1.rb +1 -0
- data/smoke/expandarray2.rb +1 -0
- data/smoke/flow1.rb +1 -0
- data/smoke/flow2.rb +1 -0
- data/smoke/flow3.rb +1 -0
- data/smoke/flow5.rb +1 -0
- data/smoke/flow6.rb +1 -0
- data/smoke/flow7.rb +1 -0
- data/smoke/flow8.rb +1 -0
- data/smoke/freeze.rb +1 -0
- data/smoke/function.rb +1 -0
- data/smoke/gvar.rb +1 -0
- data/smoke/gvar2.rb +1 -0
- data/smoke/hash-fetch.rb +1 -0
- data/smoke/hash-merge-bang.rb +1 -0
- data/smoke/hash1.rb +3 -1
- data/smoke/hash2.rb +1 -0
- data/smoke/hash3.rb +1 -0
- data/smoke/hash4.rb +2 -1
- data/smoke/inheritance2.rb +2 -2
- data/smoke/initialize.rb +1 -0
- data/smoke/int_times.rb +1 -0
- data/smoke/integer.rb +1 -0
- data/smoke/ivar.rb +1 -0
- data/smoke/ivar2.rb +1 -1
- data/smoke/kernel-class.rb +2 -1
- data/smoke/keyword1.rb +1 -0
- data/smoke/keyword2.rb +1 -0
- data/smoke/keyword3.rb +1 -0
- data/smoke/keyword4.rb +1 -0
- data/smoke/keyword5.rb +1 -0
- data/smoke/kwrest.rb +12 -0
- data/smoke/kwrest.rbs +3 -0
- data/smoke/kwsplat1.rb +2 -1
- data/smoke/kwsplat2.rb +1 -0
- data/smoke/manual-rbs.rb +1 -0
- data/smoke/manual-rbs2.rb +1 -0
- data/smoke/masgn1.rb +1 -0
- data/smoke/masgn2.rb +1 -0
- data/smoke/masgn3.rb +1 -0
- data/smoke/method_in_branch.rb +1 -0
- data/smoke/method_missing.rb +28 -0
- data/smoke/multiple-superclass.rb +1 -1
- data/smoke/next1.rb +1 -0
- data/smoke/next2.rb +1 -0
- data/smoke/object-send1.rb +1 -0
- data/smoke/once.rb +1 -0
- data/smoke/optional1.rb +1 -0
- data/smoke/optional2.rb +1 -0
- data/smoke/optional3.rb +1 -0
- data/smoke/parameterizedd-self.rb +3 -2
- data/smoke/parameterizedd-self2.rb +15 -0
- data/smoke/pathname1.rb +1 -0
- data/smoke/pathname2.rb +1 -0
- data/smoke/pattern-match1.rb +1 -0
- data/smoke/pattern-match2.rb +1 -0
- data/smoke/proc.rb +1 -0
- data/smoke/proc2.rb +1 -0
- data/smoke/proc3.rb +1 -0
- data/smoke/proc4.rb +1 -0
- data/smoke/range.rb +1 -0
- data/smoke/rbs-alias.rb +1 -0
- data/smoke/rbs-attr.rb +3 -2
- data/smoke/rbs-attr2.rb +11 -0
- data/smoke/rbs-attr2.rbs +3 -0
- data/smoke/rbs-extend.rb +1 -0
- data/smoke/rbs-interface.rb +1 -0
- data/smoke/rbs-proc1.rb +1 -0
- data/smoke/rbs-proc2.rb +1 -0
- data/smoke/rbs-proc3.rb +1 -0
- data/smoke/rbs-record.rb +1 -0
- data/smoke/rbs-tyvar.rb +1 -0
- data/smoke/rbs-tyvar2.rb +1 -0
- data/smoke/rbs-tyvar3.rb +1 -0
- data/smoke/rbs-tyvar5.rb +1 -0
- data/smoke/rbs-tyvar6.rb +18 -0
- data/smoke/rbs-tyvar6.rbs +12 -0
- data/smoke/rbs-tyvar7.rb +12 -0
- data/smoke/rbs-tyvar7.rbs +7 -0
- data/smoke/rbs-vars.rb +1 -2
- data/smoke/redo1.rb +1 -0
- data/smoke/redo2.rb +1 -0
- data/smoke/req-keyword.rb +1 -0
- data/smoke/rescue1.rb +1 -0
- data/smoke/rescue2.rb +1 -0
- data/smoke/respond_to.rb +1 -0
- data/smoke/rest-farg.rb +1 -0
- data/smoke/rest1.rb +1 -0
- data/smoke/rest2.rb +1 -0
- data/smoke/rest3.rb +1 -0
- data/smoke/rest4.rb +1 -0
- data/smoke/rest5.rb +1 -0
- data/smoke/rest6.rb +1 -0
- data/smoke/retry1.rb +1 -0
- data/smoke/return.rb +1 -0
- data/smoke/step.rb +1 -0
- data/smoke/string-split.rb +1 -0
- data/smoke/struct.rb +2 -2
- data/smoke/struct2.rb +1 -0
- data/smoke/super1.rb +1 -0
- data/smoke/super4.rb +43 -0
- data/smoke/super5.rb +36 -0
- data/smoke/svar1.rb +1 -0
- data/smoke/symbol-proc.rb +1 -0
- data/smoke/tap1.rb +1 -0
- data/smoke/toplevel.rb +1 -0
- data/smoke/two-map.rb +1 -0
- data/smoke/type_var.rb +1 -0
- data/smoke/typed_method.rb +1 -0
- data/smoke/uninitialize-var.rb +1 -0
- data/smoke/union-recv.rb +2 -2
- metadata +18 -2
data/lib/typeprof/type.rb
CHANGED
@@ -149,6 +149,10 @@ module TypeProf
|
|
149
149
|
raise "cannot substitute abstract type: #{ self.class }"
|
150
150
|
end
|
151
151
|
|
152
|
+
def generate_substitution
|
153
|
+
{}
|
154
|
+
end
|
155
|
+
|
152
156
|
DummySubstitution = Object.new
|
153
157
|
def DummySubstitution.[](_)
|
154
158
|
Type.any
|
@@ -170,7 +174,7 @@ module TypeProf
|
|
170
174
|
"untyped"
|
171
175
|
end
|
172
176
|
|
173
|
-
def
|
177
|
+
def method_dispatch_info
|
174
178
|
nil
|
175
179
|
end
|
176
180
|
|
@@ -203,11 +207,12 @@ module TypeProf
|
|
203
207
|
local = nil
|
204
208
|
tys.each do |ty|
|
205
209
|
raise ty.inspect unless ty.is_a?(Type)
|
206
|
-
local = true if ty.is_a?(
|
210
|
+
local = true if ty.is_a?(Local)
|
207
211
|
end
|
208
212
|
raise if local && elems
|
209
213
|
|
210
214
|
@elems = elems
|
215
|
+
raise elems.inspect if elems && !elems.is_a?(::Hash)
|
211
216
|
end
|
212
217
|
|
213
218
|
def each_free_type_variable(&blk)
|
@@ -285,7 +290,7 @@ module TypeProf
|
|
285
290
|
types.delete(Type::Instance.new(Type::Builtin[:true]))
|
286
291
|
bool = true
|
287
292
|
end
|
288
|
-
types.delete(Type.any) unless Config.options[:
|
293
|
+
types.delete(Type.any) unless Config.options[:show_untyped]
|
289
294
|
proc_tys, types = types.partition {|ty| ty.is_a?(Proc) }
|
290
295
|
types = types.map {|ty| ty.screen_name(scratch) }
|
291
296
|
types << scratch.show_proc_signature(proc_tys) unless proc_tys.empty?
|
@@ -435,10 +440,12 @@ module TypeProf
|
|
435
440
|
@idx = idx
|
436
441
|
@type_params = type_params
|
437
442
|
@superclass = superclass
|
443
|
+
raise if @kind == :class && !@superclass
|
438
444
|
@_name = name
|
439
445
|
end
|
440
446
|
|
441
447
|
attr_reader :kind, :idx, :type_params, :superclass
|
448
|
+
attr_accessor :superclass_type_args
|
442
449
|
|
443
450
|
def inspect
|
444
451
|
if @_name
|
@@ -449,11 +456,11 @@ module TypeProf
|
|
449
456
|
end
|
450
457
|
|
451
458
|
def screen_name(scratch)
|
452
|
-
"#{ scratch.get_class_name(self) }
|
459
|
+
"singleton(#{ scratch.get_class_name(self) })"
|
453
460
|
end
|
454
461
|
|
455
|
-
def
|
456
|
-
|
462
|
+
def method_dispatch_info
|
463
|
+
[self, true]
|
457
464
|
end
|
458
465
|
|
459
466
|
def consistent?(other)
|
@@ -504,8 +511,8 @@ module TypeProf
|
|
504
511
|
end
|
505
512
|
end
|
506
513
|
|
507
|
-
def
|
508
|
-
|
514
|
+
def method_dispatch_info
|
515
|
+
[@klass, false]
|
509
516
|
end
|
510
517
|
|
511
518
|
def consistent?(other)
|
@@ -558,8 +565,8 @@ module TypeProf
|
|
558
565
|
end
|
559
566
|
end
|
560
567
|
|
561
|
-
def
|
562
|
-
@base_type.
|
568
|
+
def method_dispatch_info
|
569
|
+
@base_type.method_dispatch_info
|
563
570
|
end
|
564
571
|
|
565
572
|
def substitute(subst, depth)
|
@@ -600,8 +607,8 @@ module TypeProf
|
|
600
607
|
end
|
601
608
|
end
|
602
609
|
|
603
|
-
def
|
604
|
-
@base_type.
|
610
|
+
def method_dispatch_info
|
611
|
+
@base_type.method_dispatch_info
|
605
612
|
end
|
606
613
|
|
607
614
|
def substitute(_subst, _depth)
|
@@ -630,8 +637,8 @@ module TypeProf
|
|
630
637
|
@base_type
|
631
638
|
end
|
632
639
|
|
633
|
-
def
|
634
|
-
@base_type.
|
640
|
+
def method_dispatch_info
|
641
|
+
@base_type.method_dispatch_info
|
635
642
|
end
|
636
643
|
|
637
644
|
def consistent?(_other)
|
@@ -785,6 +792,10 @@ module TypeProf
|
|
785
792
|
end
|
786
793
|
str = str.empty? ? "" : "(#{ str.join(", ") })"
|
787
794
|
|
795
|
+
# Dirty Hack: Stop the iteration at most once!
|
796
|
+
# I'll remove this hack if RBS removes the limitation of nesting blocks
|
797
|
+
return str if caller_locations.any? {|frame| frame.label == "show_block_signature" }
|
798
|
+
|
788
799
|
optional = false
|
789
800
|
blks = []
|
790
801
|
@blk_ty.each_child_global do |ty|
|
@@ -811,6 +822,7 @@ module TypeProf
|
|
811
822
|
@opt_tys = opt_tys
|
812
823
|
@rest_ty = rest_ty
|
813
824
|
@post_tys = post_tys
|
825
|
+
raise unless post_tys
|
814
826
|
@kw_tys = kw_tys
|
815
827
|
kw_tys.each {|a| raise if a.size != 3 } if kw_tys
|
816
828
|
@kw_rest_ty = kw_rest_ty
|
data/lib/typeprof/version.rb
CHANGED
data/smoke/alias.rb
CHANGED
data/smoke/any1.rb
CHANGED
data/smoke/any2.rb
CHANGED
data/smoke/arguments.rb
CHANGED
data/smoke/arguments2.rb
CHANGED
data/smoke/array-each.rb
CHANGED
data/smoke/array-each2.rb
CHANGED
data/smoke/array-each3.rb
CHANGED
data/smoke/array-ltlt.rb
CHANGED
data/smoke/array-ltlt2.rb
CHANGED
data/smoke/array-map.rb
CHANGED
data/smoke/array-map2.rb
CHANGED
data/smoke/array-map3.rb
CHANGED
@@ -16,6 +16,7 @@ map_bang_test_known_bug([1, 2, 3])
|
|
16
16
|
__END__
|
17
17
|
# Classes
|
18
18
|
class Object
|
19
|
+
private
|
19
20
|
def map_test : ([Integer, Integer, Integer]) -> Array[String]
|
20
21
|
def map_bang_test : ([Integer, Integer, Integer]) -> (Array[Integer | String])
|
21
22
|
def map_bang_test_known_bug : ([Integer, Integer, Integer]) -> [Integer, Integer, Integer]
|
data/smoke/array-mul.rb
CHANGED
data/smoke/array-plus1.rb
CHANGED
data/smoke/array-pop.rb
CHANGED
@@ -0,0 +1,71 @@
|
|
1
|
+
def f1(*ary)
|
2
|
+
ary[1..3]
|
3
|
+
end
|
4
|
+
|
5
|
+
def f2(*ary)
|
6
|
+
ary[1...3]
|
7
|
+
end
|
8
|
+
|
9
|
+
def f3(*ary)
|
10
|
+
ary[1..-3]
|
11
|
+
end
|
12
|
+
|
13
|
+
def f4(*ary)
|
14
|
+
ary[1...-3]
|
15
|
+
end
|
16
|
+
|
17
|
+
def f5(*ary)
|
18
|
+
ary[-4..3]
|
19
|
+
end
|
20
|
+
|
21
|
+
def f6(*ary)
|
22
|
+
ary[-4...3]
|
23
|
+
end
|
24
|
+
|
25
|
+
def f7(*ary)
|
26
|
+
ary[-4..-3]
|
27
|
+
end
|
28
|
+
|
29
|
+
def f8(*ary)
|
30
|
+
ary[-4...-3]
|
31
|
+
end
|
32
|
+
|
33
|
+
def f9(*ary)
|
34
|
+
ary[...3]
|
35
|
+
end
|
36
|
+
|
37
|
+
def f10(*ary)
|
38
|
+
ary[3..]
|
39
|
+
end
|
40
|
+
|
41
|
+
def dispatch(*ary)
|
42
|
+
f1(*ary)
|
43
|
+
f2(*ary)
|
44
|
+
f3(*ary)
|
45
|
+
f4(*ary)
|
46
|
+
f5(*ary)
|
47
|
+
f6(*ary)
|
48
|
+
f7(*ary)
|
49
|
+
f8(*ary)
|
50
|
+
f9(*ary)
|
51
|
+
f10(*ary)
|
52
|
+
end
|
53
|
+
|
54
|
+
dispatch(:a, :b, :c, :d, :e)
|
55
|
+
|
56
|
+
__END__
|
57
|
+
# Classes
|
58
|
+
class Object
|
59
|
+
private
|
60
|
+
def f1 : (*:a | :b | :c | :d | :e) -> (Array[:a | :b | :c | :d | :e])
|
61
|
+
def f2 : (*:a | :b | :c | :d | :e) -> (Array[:a | :b | :c | :d | :e])
|
62
|
+
def f3 : (*:a | :b | :c | :d | :e) -> (Array[:a | :b | :c | :d | :e])
|
63
|
+
def f4 : (*:a | :b | :c | :d | :e) -> (Array[:a | :b | :c | :d | :e])
|
64
|
+
def f5 : (*:a | :b | :c | :d | :e) -> (Array[:a | :b | :c | :d | :e])
|
65
|
+
def f6 : (*:a | :b | :c | :d | :e) -> (Array[:a | :b | :c | :d | :e])
|
66
|
+
def f7 : (*:a | :b | :c | :d | :e) -> (Array[:a | :b | :c | :d | :e])
|
67
|
+
def f8 : (*:a | :b | :c | :d | :e) -> (Array[:a | :b | :c | :d | :e])
|
68
|
+
def f9 : (*:a | :b | :c | :d | :e) -> (Array[:a | :b | :c | :d | :e])
|
69
|
+
def f10 : (*:a | :b | :c | :d | :e) -> (Array[:a | :b | :c | :d | :e])
|
70
|
+
def dispatch : (*:a | :b | :c | :d | :e) -> (Array[:a | :b | :c | :d | :e])
|
71
|
+
end
|
data/smoke/array-replace.rb
CHANGED
data/smoke/array-s-aref.rb
CHANGED
data/smoke/array1.rb
CHANGED
data/smoke/array10.rb
CHANGED
data/smoke/array11.rb
CHANGED
@@ -9,5 +9,6 @@ array("foo")
|
|
9
9
|
__END__
|
10
10
|
# Classes
|
11
11
|
class Object
|
12
|
-
|
12
|
+
private
|
13
|
+
def array : (Array[Integer] | Hash[Integer, Integer] | String) -> (Array[Hash[Integer, Integer] | Integer | String])
|
13
14
|
end
|
data/smoke/array12.rb
CHANGED
data/smoke/array13.rb
CHANGED
data/smoke/array14.rb
CHANGED
data/smoke/array2.rb
CHANGED
data/smoke/array4.rb
CHANGED
data/smoke/array5.rb
CHANGED
data/smoke/array6.rb
CHANGED