typeprof 0.15.1 → 0.20.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (365) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/main.yml +1 -1
  3. data/Gemfile.lock +4 -4
  4. data/doc/ide.md +81 -0
  5. data/doc/typeprof-for-ide-log.png +0 -0
  6. data/doc/typeprof-for-ide.png +0 -0
  7. data/exe/typeprof +5 -1
  8. data/lib/typeprof/analyzer.rb +234 -55
  9. data/lib/typeprof/arguments.rb +1 -0
  10. data/lib/typeprof/builtin.rb +23 -23
  11. data/lib/typeprof/cli.rb +23 -5
  12. data/lib/typeprof/code-range.rb +177 -0
  13. data/lib/typeprof/config.rb +41 -20
  14. data/lib/typeprof/container-type.rb +10 -1
  15. data/lib/typeprof/export.rb +199 -20
  16. data/lib/typeprof/import.rb +38 -9
  17. data/lib/typeprof/iseq.rb +223 -16
  18. data/lib/typeprof/lsp.rb +884 -0
  19. data/lib/typeprof/method.rb +15 -11
  20. data/lib/typeprof/type.rb +46 -38
  21. data/lib/typeprof/utils.rb +18 -1
  22. data/lib/typeprof/version.rb +1 -1
  23. data/lib/typeprof.rb +3 -5
  24. data/typeprof-lsp +3 -0
  25. data/typeprof.gemspec +2 -2
  26. data/vscode/.gitignore +5 -0
  27. data/vscode/.vscode/launch.json +16 -0
  28. data/vscode/.vscodeignore +7 -0
  29. data/vscode/README.md +22 -0
  30. data/vscode/development.md +31 -0
  31. data/vscode/package-lock.json +2211 -0
  32. data/vscode/package.json +71 -0
  33. data/vscode/sandbox/test.rb +24 -0
  34. data/vscode/src/extension.ts +285 -0
  35. data/vscode/tsconfig.json +15 -0
  36. metadata +21 -334
  37. data/smoke/alias.rb +0 -31
  38. data/smoke/alias2.rb +0 -21
  39. data/smoke/any-cbase.rb +0 -5
  40. data/smoke/any1.rb +0 -16
  41. data/smoke/any2.rb +0 -18
  42. data/smoke/arguments.rb +0 -17
  43. data/smoke/arguments2.rb +0 -56
  44. data/smoke/array-each.rb +0 -15
  45. data/smoke/array-each2.rb +0 -16
  46. data/smoke/array-each3.rb +0 -13
  47. data/smoke/array-ltlt.rb +0 -14
  48. data/smoke/array-ltlt2.rb +0 -17
  49. data/smoke/array-map.rb +0 -12
  50. data/smoke/array-map2.rb +0 -11
  51. data/smoke/array-map3.rb +0 -23
  52. data/smoke/array-mul.rb +0 -18
  53. data/smoke/array-plus1.rb +0 -11
  54. data/smoke/array-plus2.rb +0 -16
  55. data/smoke/array-pop.rb +0 -12
  56. data/smoke/array-range-aref.rb +0 -71
  57. data/smoke/array-replace.rb +0 -13
  58. data/smoke/array-s-aref.rb +0 -12
  59. data/smoke/array1.rb +0 -27
  60. data/smoke/array10.rb +0 -15
  61. data/smoke/array11.rb +0 -14
  62. data/smoke/array12.rb +0 -25
  63. data/smoke/array13.rb +0 -31
  64. data/smoke/array14.rb +0 -14
  65. data/smoke/array15.rb +0 -16
  66. data/smoke/array2.rb +0 -28
  67. data/smoke/array3.rb +0 -26
  68. data/smoke/array4.rb +0 -15
  69. data/smoke/array5.rb +0 -14
  70. data/smoke/array6.rb +0 -17
  71. data/smoke/array7.rb +0 -14
  72. data/smoke/array8.rb +0 -13
  73. data/smoke/array9.rb +0 -13
  74. data/smoke/attr-module.rb +0 -24
  75. data/smoke/attr-vis.rb +0 -43
  76. data/smoke/attr-vis.rbs +0 -4
  77. data/smoke/attr.rb +0 -28
  78. data/smoke/autoload.rb +0 -14
  79. data/smoke/backtrace.rb +0 -33
  80. data/smoke/block-ambiguous.rb +0 -37
  81. data/smoke/block-args1-rest.rb +0 -64
  82. data/smoke/block-args1.rb +0 -60
  83. data/smoke/block-args2-rest.rb +0 -64
  84. data/smoke/block-args2.rb +0 -60
  85. data/smoke/block-args3-rest.rb +0 -75
  86. data/smoke/block-args3.rb +0 -71
  87. data/smoke/block-blockarg.rb +0 -28
  88. data/smoke/block-kwarg.rb +0 -53
  89. data/smoke/block1.rb +0 -23
  90. data/smoke/block10.rb +0 -15
  91. data/smoke/block11.rb +0 -40
  92. data/smoke/block12.rb +0 -23
  93. data/smoke/block13.rb +0 -9
  94. data/smoke/block13.rbs +0 -3
  95. data/smoke/block14.rb +0 -18
  96. data/smoke/block2.rb +0 -15
  97. data/smoke/block3.rb +0 -38
  98. data/smoke/block4.rb +0 -19
  99. data/smoke/block5.rb +0 -21
  100. data/smoke/block6.rb +0 -21
  101. data/smoke/block7.rb +0 -19
  102. data/smoke/block8.rb +0 -28
  103. data/smoke/block9.rb +0 -13
  104. data/smoke/block_given.rb +0 -37
  105. data/smoke/blown.rb +0 -13
  106. data/smoke/break1.rb +0 -19
  107. data/smoke/break2.rb +0 -16
  108. data/smoke/break3.rb +0 -13
  109. data/smoke/break4.rb +0 -17
  110. data/smoke/case.rb +0 -17
  111. data/smoke/case2.rb +0 -18
  112. data/smoke/case3.rb +0 -17
  113. data/smoke/class-hierarchy.rb +0 -54
  114. data/smoke/class-hierarchy2.rb +0 -27
  115. data/smoke/class-new.rb +0 -15
  116. data/smoke/class.rb +0 -7
  117. data/smoke/class_eval.rb +0 -22
  118. data/smoke/class_instance_var.rb +0 -9
  119. data/smoke/class_method.rb +0 -25
  120. data/smoke/class_method2.rb +0 -21
  121. data/smoke/class_method3.rb +0 -29
  122. data/smoke/constant1.rb +0 -46
  123. data/smoke/constant2.rb +0 -36
  124. data/smoke/constant3.rb +0 -10
  125. data/smoke/constant4.rb +0 -12
  126. data/smoke/context-sensitive1.rb +0 -13
  127. data/smoke/cvar.rb +0 -31
  128. data/smoke/cvar2.rb +0 -17
  129. data/smoke/define_method.rb +0 -16
  130. data/smoke/define_method2.rb +0 -18
  131. data/smoke/define_method3.rb +0 -14
  132. data/smoke/define_method3.rbs +0 -3
  133. data/smoke/define_method4.rb +0 -15
  134. data/smoke/define_method4.rbs +0 -3
  135. data/smoke/define_method5.rb +0 -12
  136. data/smoke/define_method6.rb +0 -19
  137. data/smoke/define_method7.rb +0 -18
  138. data/smoke/demo.rb +0 -81
  139. data/smoke/demo1.rb +0 -17
  140. data/smoke/demo10.rb +0 -21
  141. data/smoke/demo11.rb +0 -12
  142. data/smoke/demo2.rb +0 -15
  143. data/smoke/demo3.rb +0 -17
  144. data/smoke/demo4.rb +0 -27
  145. data/smoke/demo5.rb +0 -16
  146. data/smoke/demo6.rb +0 -22
  147. data/smoke/demo7.rb +0 -15
  148. data/smoke/demo8.rb +0 -19
  149. data/smoke/demo9.rb +0 -18
  150. data/smoke/dummy-execution1.rb +0 -15
  151. data/smoke/dummy-execution2.rb +0 -16
  152. data/smoke/dummy_element.rb +0 -14
  153. data/smoke/ensure1.rb +0 -21
  154. data/smoke/enum_for.rb +0 -15
  155. data/smoke/enum_for2.rb +0 -17
  156. data/smoke/enumerator.rb +0 -16
  157. data/smoke/expandarray1.rb +0 -23
  158. data/smoke/expandarray2.rb +0 -24
  159. data/smoke/extended.rb +0 -38
  160. data/smoke/fib.rb +0 -28
  161. data/smoke/flip-flop.rb +0 -28
  162. data/smoke/flow1.rb +0 -17
  163. data/smoke/flow10.rb +0 -17
  164. data/smoke/flow11.rb +0 -17
  165. data/smoke/flow2.rb +0 -15
  166. data/smoke/flow3.rb +0 -15
  167. data/smoke/flow4.rb +0 -5
  168. data/smoke/flow5.rb +0 -20
  169. data/smoke/flow6.rb +0 -20
  170. data/smoke/flow7.rb +0 -21
  171. data/smoke/flow8.rb +0 -14
  172. data/smoke/flow9.rb +0 -12
  173. data/smoke/for.rb +0 -9
  174. data/smoke/freeze.rb +0 -12
  175. data/smoke/function.rb +0 -17
  176. data/smoke/gvar.rb +0 -14
  177. data/smoke/gvar2.rb +0 -18
  178. data/smoke/gvar2.rbs +0 -1
  179. data/smoke/hash-bot.rb +0 -12
  180. data/smoke/hash-fetch.rb +0 -28
  181. data/smoke/hash-merge-bang.rb +0 -12
  182. data/smoke/hash1.rb +0 -20
  183. data/smoke/hash2.rb +0 -13
  184. data/smoke/hash3.rb +0 -14
  185. data/smoke/hash4.rb +0 -11
  186. data/smoke/hash5.rb +0 -14
  187. data/smoke/huge_union.rb +0 -86
  188. data/smoke/identifier_keywords.rb +0 -17
  189. data/smoke/included.rb +0 -38
  190. data/smoke/inheritance.rb +0 -34
  191. data/smoke/inheritance2.rb +0 -35
  192. data/smoke/inherited.rb +0 -26
  193. data/smoke/initialize.rb +0 -28
  194. data/smoke/instance_eval.rb +0 -18
  195. data/smoke/instance_eval2.rb +0 -10
  196. data/smoke/instance_eval3.rb +0 -25
  197. data/smoke/instance_eval4.rb +0 -12
  198. data/smoke/int_times.rb +0 -15
  199. data/smoke/integer.rb +0 -11
  200. data/smoke/ivar.rb +0 -31
  201. data/smoke/ivar2.rb +0 -30
  202. data/smoke/ivar3.rb +0 -17
  203. data/smoke/ivar3.rbs +0 -3
  204. data/smoke/ivar4.rb +0 -21
  205. data/smoke/kernel-class.rb +0 -13
  206. data/smoke/keyword1.rb +0 -12
  207. data/smoke/keyword2.rb +0 -12
  208. data/smoke/keyword3.rb +0 -12
  209. data/smoke/keyword4.rb +0 -12
  210. data/smoke/keyword5.rb +0 -16
  211. data/smoke/kwrest.rb +0 -13
  212. data/smoke/kwrest.rbs +0 -3
  213. data/smoke/kwsplat1.rb +0 -43
  214. data/smoke/kwsplat2.rb +0 -13
  215. data/smoke/lit-complex.rb +0 -10
  216. data/smoke/lit-encoding.rb +0 -10
  217. data/smoke/manual-rbs.rb +0 -29
  218. data/smoke/manual-rbs.rbs +0 -3
  219. data/smoke/manual-rbs2.rb +0 -21
  220. data/smoke/manual-rbs2.rbs +0 -8
  221. data/smoke/manual-rbs3.rb +0 -13
  222. data/smoke/manual-rbs3.rbs +0 -3
  223. data/smoke/masgn1.rb +0 -14
  224. data/smoke/masgn2.rb +0 -18
  225. data/smoke/masgn3.rb +0 -13
  226. data/smoke/method_in_branch.rb +0 -23
  227. data/smoke/method_missing.rb +0 -29
  228. data/smoke/module1.rb +0 -29
  229. data/smoke/module2.rb +0 -28
  230. data/smoke/module3.rb +0 -33
  231. data/smoke/module4.rb +0 -35
  232. data/smoke/module5.rb +0 -17
  233. data/smoke/module6.rb +0 -40
  234. data/smoke/module_function1.rb +0 -29
  235. data/smoke/module_function2.rb +0 -29
  236. data/smoke/multiple-include.rb +0 -15
  237. data/smoke/multiple-superclass.rb +0 -28
  238. data/smoke/next1.rb +0 -21
  239. data/smoke/next2.rb +0 -17
  240. data/smoke/noname.rb +0 -9
  241. data/smoke/object-send1.rb +0 -23
  242. data/smoke/object-send2.rb +0 -10
  243. data/smoke/object-send3.rb +0 -18
  244. data/smoke/once.rb +0 -13
  245. data/smoke/optional1.rb +0 -14
  246. data/smoke/optional2.rb +0 -16
  247. data/smoke/optional3.rb +0 -11
  248. data/smoke/or_raise.rb +0 -18
  249. data/smoke/parameterizedd-self.rb +0 -20
  250. data/smoke/parameterizedd-self2.rb +0 -15
  251. data/smoke/pathname1.rb +0 -14
  252. data/smoke/pathname2.rb +0 -14
  253. data/smoke/pattern-match1.rb +0 -19
  254. data/smoke/pattern-match2.rb +0 -16
  255. data/smoke/prepend1.rb +0 -33
  256. data/smoke/prepend2.rb +0 -10
  257. data/smoke/prepend2.rbs +0 -9
  258. data/smoke/primitive_method.rb +0 -19
  259. data/smoke/printf.rb +0 -20
  260. data/smoke/proc.rb +0 -20
  261. data/smoke/proc2.rb +0 -17
  262. data/smoke/proc3.rb +0 -15
  263. data/smoke/proc4.rb +0 -12
  264. data/smoke/proc5.rb +0 -19
  265. data/smoke/proc6.rb +0 -13
  266. data/smoke/proc7.rb +0 -32
  267. data/smoke/public.rb +0 -38
  268. data/smoke/range.rb +0 -14
  269. data/smoke/rbs-alias.rb +0 -10
  270. data/smoke/rbs-alias.rbs +0 -4
  271. data/smoke/rbs-attr.rb +0 -27
  272. data/smoke/rbs-attr.rbs +0 -5
  273. data/smoke/rbs-attr2.rb +0 -11
  274. data/smoke/rbs-attr2.rbs +0 -3
  275. data/smoke/rbs-extend.rb +0 -10
  276. data/smoke/rbs-extend.rbs +0 -7
  277. data/smoke/rbs-interface.rb +0 -25
  278. data/smoke/rbs-interface.rbs +0 -12
  279. data/smoke/rbs-module.rb +0 -26
  280. data/smoke/rbs-module.rbs +0 -4
  281. data/smoke/rbs-opt-and-rest.rb +0 -10
  282. data/smoke/rbs-opt-and-rest.rbs +0 -3
  283. data/smoke/rbs-proc1.rb +0 -10
  284. data/smoke/rbs-proc1.rbs +0 -3
  285. data/smoke/rbs-proc2.rb +0 -21
  286. data/smoke/rbs-proc2.rbs +0 -3
  287. data/smoke/rbs-proc3.rb +0 -14
  288. data/smoke/rbs-proc3.rbs +0 -4
  289. data/smoke/rbs-record.rb +0 -18
  290. data/smoke/rbs-record.rbs +0 -4
  291. data/smoke/rbs-tyvar.rb +0 -19
  292. data/smoke/rbs-tyvar.rbs +0 -5
  293. data/smoke/rbs-tyvar2.rb +0 -21
  294. data/smoke/rbs-tyvar2.rbs +0 -9
  295. data/smoke/rbs-tyvar3.rb +0 -18
  296. data/smoke/rbs-tyvar3.rbs +0 -5
  297. data/smoke/rbs-tyvar4.rb +0 -37
  298. data/smoke/rbs-tyvar5.rb +0 -13
  299. data/smoke/rbs-tyvar5.rbs +0 -8
  300. data/smoke/rbs-tyvar6.rb +0 -18
  301. data/smoke/rbs-tyvar6.rbs +0 -12
  302. data/smoke/rbs-tyvar7.rb +0 -12
  303. data/smoke/rbs-tyvar7.rbs +0 -7
  304. data/smoke/rbs-vars.rb +0 -38
  305. data/smoke/rbs-vars.rbs +0 -7
  306. data/smoke/redo1.rb +0 -22
  307. data/smoke/redo2.rb +0 -23
  308. data/smoke/req-keyword.rb +0 -13
  309. data/smoke/require1.rb +0 -13
  310. data/smoke/require2.rb +0 -13
  311. data/smoke/rescue1.rb +0 -21
  312. data/smoke/rescue2.rb +0 -23
  313. data/smoke/rescue3.rb +0 -20
  314. data/smoke/rescue4.rb +0 -17
  315. data/smoke/respond_to.rb +0 -23
  316. data/smoke/rest-farg.rb +0 -11
  317. data/smoke/rest1.rb +0 -26
  318. data/smoke/rest2.rb +0 -31
  319. data/smoke/rest3.rb +0 -37
  320. data/smoke/rest4.rb +0 -19
  321. data/smoke/rest5.rb +0 -11
  322. data/smoke/rest6.rb +0 -12
  323. data/smoke/retry1.rb +0 -21
  324. data/smoke/return.rb +0 -14
  325. data/smoke/reveal.rb +0 -13
  326. data/smoke/simple.rb +0 -12
  327. data/smoke/singleton_class.rb +0 -8
  328. data/smoke/singleton_method.rb +0 -12
  329. data/smoke/step.rb +0 -18
  330. data/smoke/string-split.rb +0 -12
  331. data/smoke/struct-keyword_init.rb +0 -10
  332. data/smoke/struct.rb +0 -13
  333. data/smoke/struct2.rb +0 -25
  334. data/smoke/struct3.rb +0 -14
  335. data/smoke/struct4.rb +0 -7
  336. data/smoke/struct5.rb +0 -16
  337. data/smoke/struct6.rb +0 -15
  338. data/smoke/struct7.rb +0 -17
  339. data/smoke/stub-keyword.rb +0 -10
  340. data/smoke/super1.rb +0 -69
  341. data/smoke/super2.rb +0 -16
  342. data/smoke/super3.rb +0 -20
  343. data/smoke/super4.rb +0 -45
  344. data/smoke/super5.rb +0 -38
  345. data/smoke/svar1.rb +0 -13
  346. data/smoke/symbol-proc-attr.rb +0 -22
  347. data/smoke/symbol-proc-attr2.rb +0 -15
  348. data/smoke/symbol-proc-bot.rb +0 -13
  349. data/smoke/symbol-proc.rb +0 -25
  350. data/smoke/tap1.rb +0 -18
  351. data/smoke/toplevel.rb +0 -13
  352. data/smoke/two-map.rb +0 -18
  353. data/smoke/type_var.rb +0 -11
  354. data/smoke/typed_method.rb +0 -16
  355. data/smoke/uninitialize-var.rb +0 -13
  356. data/smoke/union-recv.rb +0 -35
  357. data/smoke/user-demo.rb +0 -15
  358. data/smoke/wrong-extend.rb +0 -27
  359. data/smoke/wrong-include.rb +0 -27
  360. data/smoke/wrong-include2.rb +0 -17
  361. data/smoke/wrong-rbs.rb +0 -15
  362. data/smoke/wrong-rbs.rbs +0 -7
  363. data/testbed/ao.rb +0 -297
  364. data/testbed/diff-lcs-entrypoint.rb +0 -4
  365. data/testbed/goodcheck-Gemfile.lock +0 -51
@@ -1,18 +0,0 @@
1
- class C
2
- x = :x
3
- define_method(:foo) do
4
- x
5
- end
6
- define_method(:bar) do
7
- x
8
- end
9
- end
10
-
11
- C.new.foo
12
-
13
- __END__
14
- # Classes
15
- class C
16
- def foo: -> :x
17
- def bar: -> :x
18
- end
@@ -1,14 +0,0 @@
1
- class Foo
2
- x = 1
3
- define_method(:foo) {
4
- @log = x
5
- }
6
- end
7
-
8
- __END__
9
- # Classes
10
- class Foo
11
- @log: Integer
12
-
13
- # def foo: () -> void
14
- end
@@ -1,3 +0,0 @@
1
- class Foo
2
- def foo: () -> void
3
- end
@@ -1,15 +0,0 @@
1
- class Foo
2
- define_method(:foo) do |*messages, **kw|
3
- bar(*messages, **kw)
4
- end
5
-
6
- def bar(*messages, **kw)
7
- end
8
- end
9
-
10
- __END__
11
- # Classes
12
- class Foo
13
- # def foo: () -> NilClass
14
- def bar: (*untyped messages, **untyped) -> nil
15
- end
@@ -1,3 +0,0 @@
1
- class Foo
2
- def foo: () -> NilClass
3
- end
@@ -1,12 +0,0 @@
1
- class Foo
2
- foo = 42
3
- f = proc { foo }
4
-
5
- define_method(:foo, &f)
6
- end
7
-
8
- __END__
9
- # Classes
10
- class Foo
11
- def foo: -> Integer
12
- end
@@ -1,19 +0,0 @@
1
- class A
2
- %i[a b].each.with_index { |sym, i| define_method(sym) { i } }
3
- end
4
-
5
- def foo
6
- A.new.a + A.new.b
7
- end
8
-
9
- __END__
10
- # Classes
11
- class Object
12
- private
13
- def foo: -> Integer
14
- end
15
-
16
- class A
17
- def a: -> Integer
18
- def b: -> Integer
19
- end
@@ -1,18 +0,0 @@
1
- class Human
2
- define_method(:fo) { }
3
-
4
- [:a, :b].each { |m|
5
- define_method(m) { }
6
- }
7
- end
8
-
9
- Human.new.a
10
- Human.new.b
11
-
12
- __END__
13
- # Classes
14
- class Human
15
- def fo: -> nil
16
- def a: -> nil
17
- def b: -> nil
18
- end
data/smoke/demo.rb DELETED
@@ -1,81 +0,0 @@
1
- def foo(x)
2
- if x
3
- 42
4
- else
5
- "str"
6
- end
7
- end
8
-
9
- foo(true)
10
- foo(false)
11
-
12
- # Object#foo :: (Boolean) -> (String | Integer)
13
-
14
-
15
- # overrided method
16
- def identity(x)
17
- x
18
- end
19
-
20
- identity(42)
21
- identity("str")
22
- identity(:sym)
23
-
24
- # Object#identity :: (Integer) -> Integer
25
- # Object#identity :: (String) -> String
26
- # Object#identity :: (Symbol) -> Symbol
27
-
28
-
29
- # recursive method
30
- def fib(x)
31
- if x <= 1
32
- x
33
- else
34
- fib(x - 1) + fib(x - 2)
35
- end
36
- end
37
-
38
- fib(40000)
39
-
40
- # Object#fib :: (Integer) -> Integer
41
-
42
-
43
- # user-defined classes
44
- class A
45
- def foo(x)
46
- bar(x)
47
- end
48
-
49
- def bar(x)
50
- end
51
- end
52
-
53
- class B < A
54
- def bar(x)
55
- end
56
- end
57
- A.new.foo(1)
58
- B.new.foo("str")
59
-
60
- # A#foo :: (Integer) -> NilClass
61
- # A#bar :: (Integer) -> NilClass
62
- # B#foo :: (String) -> NilClass
63
- # B#bar :: (String) -> NilClass
64
-
65
- __END__
66
- # Classes
67
- class Object
68
- private
69
- def foo: (bool x) -> (Integer | String)
70
- def identity: (:sym | Integer | String x) -> (:sym | Integer | String)
71
- def fib: (Integer x) -> Integer
72
- end
73
-
74
- class A
75
- def foo: (Integer | String x) -> nil
76
- def bar: (Integer | String x) -> nil
77
- end
78
-
79
- class B < A
80
- def bar: (Integer | String x) -> nil
81
- end
data/smoke/demo1.rb DELETED
@@ -1,17 +0,0 @@
1
- def foo(x)
2
- if x
3
- 42
4
- else
5
- "str"
6
- end
7
- end
8
-
9
- foo(true)
10
- foo(false)
11
-
12
- __END__
13
- # Classes
14
- class Object
15
- private
16
- def foo: (bool x) -> (Integer | String)
17
- end
data/smoke/demo10.rb DELETED
@@ -1,21 +0,0 @@
1
- def bar
2
- yield
3
- end
4
-
5
- def foo
6
- x = 42
7
- bar do
8
- x = "STR"
9
- end
10
- x
11
- end
12
-
13
- foo
14
-
15
- __END__
16
- # Classes
17
- class Object
18
- private
19
- def bar: { -> String } -> String
20
- def foo: -> (Integer | String)
21
- end
data/smoke/demo11.rb DELETED
@@ -1,12 +0,0 @@
1
- def swap(a)
2
- [a[1], a[0]]
3
- end
4
- a = [42, "str"]
5
- swap(a)
6
-
7
- __END__
8
- # Classes
9
- class Object
10
- private
11
- def swap: ([Integer, String] a) -> [String, Integer]
12
- end
data/smoke/demo2.rb DELETED
@@ -1,15 +0,0 @@
1
- # override
2
- def my_to_s(x)
3
- x.to_s
4
- end
5
-
6
- my_to_s(42)
7
- my_to_s("str")
8
- my_to_s(:sym)
9
-
10
- __END__
11
- # Classes
12
- class Object
13
- private
14
- def my_to_s: (:sym | Integer | String x) -> String
15
- end
data/smoke/demo3.rb DELETED
@@ -1,17 +0,0 @@
1
- # recursive method
2
- def fib(x)
3
- if x <= 1
4
- x
5
- else
6
- fib(x - 1) + fib(x - 2)
7
- end
8
- end
9
-
10
- fib(40000)
11
-
12
- __END__
13
- # Classes
14
- class Object
15
- private
16
- def fib: (Integer x) -> Integer
17
- end
data/smoke/demo4.rb DELETED
@@ -1,27 +0,0 @@
1
- # user-defined classes
2
- class A
3
- def foo(x)
4
- bar(x)
5
- end
6
-
7
- def bar(x)
8
- end
9
- end
10
-
11
- class B < A
12
- def bar(x)
13
- end
14
- end
15
- A.new.foo(1)
16
- B.new.foo("str")
17
-
18
- __END__
19
- # Classes
20
- class A
21
- def foo: (Integer | String x) -> nil
22
- def bar: (Integer | String x) -> nil
23
- end
24
-
25
- class B < A
26
- def bar: (Integer | String x) -> nil
27
- end
data/smoke/demo5.rb DELETED
@@ -1,16 +0,0 @@
1
- class A
2
- def self.foo(x); "str"; end
3
- end
4
- class B < A
5
- end
6
- A.foo(1)
7
- B.foo(Integer)
8
-
9
- __END__
10
- # Classes
11
- class A
12
- def self.foo: (Integer | singleton(Integer) x) -> String
13
- end
14
-
15
- class B < A
16
- end
data/smoke/demo6.rb DELETED
@@ -1,22 +0,0 @@
1
- class Foo
2
- def foo=(x)
3
- @foo = x
4
- end
5
-
6
- def foo
7
- @foo
8
- end
9
- end
10
-
11
- Foo.new.foo = 1
12
- Foo.new.foo = "str"
13
- Foo.new.foo
14
-
15
- __END__
16
- # Classes
17
- class Foo
18
- @foo: Integer | String
19
-
20
- def foo=: (Integer | String x) -> (Integer | String)
21
- def foo: -> (Integer | String)
22
- end
data/smoke/demo7.rb DELETED
@@ -1,15 +0,0 @@
1
- def foo(x)
2
- yield 42
3
- end
4
-
5
- s = "str"
6
- foo(1) do |x|
7
- s
8
- end
9
-
10
- __END__
11
- # Classes
12
- class Object
13
- private
14
- def foo: (Integer x) { (Integer) -> String } -> String
15
- end
data/smoke/demo8.rb DELETED
@@ -1,19 +0,0 @@
1
- def foo
2
- yield "str"
3
- end
4
-
5
- def bar
6
- yield :sym
7
- end
8
-
9
- blk = -> x { x }
10
- foo(&blk)
11
- bar(&blk)
12
-
13
- __END__
14
- # Classes
15
- class Object
16
- private
17
- def foo: { (:sym | String) -> (:sym | String) } -> (:sym | String)
18
- def bar: { (:sym | String) -> (:sym | String) } -> (:sym | String)
19
- end
data/smoke/demo9.rb DELETED
@@ -1,18 +0,0 @@
1
- F = -> x { "str" }
2
-
3
- def foo(&blk)
4
- blk.call(:sym, &F)
5
- end
6
-
7
- foo do |dummy, &blk|
8
- blk.call(42)
9
- end
10
-
11
- __END__
12
- # Classes
13
- class Object
14
- F: ^(Integer) -> String
15
-
16
- private
17
- def foo: { (:sym) -> String } -> String
18
- end
@@ -1,15 +0,0 @@
1
- def foo(n)
2
- n
3
- end
4
-
5
- def bar
6
- foo(1)
7
- end
8
-
9
- __END__
10
- # Classes
11
- class Object
12
- private
13
- def foo: (Integer | untyped n) -> (Integer | untyped)
14
- def bar: -> (Integer | untyped)
15
- end
@@ -1,16 +0,0 @@
1
- class Foo
2
- def foo(n)
3
- n
4
- end
5
-
6
- def self.bar
7
- new.foo(1)
8
- end
9
- end
10
-
11
- __END__
12
- # Classes
13
- class Foo
14
- def foo: (Integer | untyped n) -> (Integer | untyped)
15
- def self.bar: -> (Integer | untyped)
16
- end
@@ -1,14 +0,0 @@
1
- # I'm unsure how, but this code calls ContainerType::Elements.dummy_elements
2
- # I should investigate the mechanism, but anyway I record this code
3
-
4
- class Foo
5
- define_method(:f) {|**h| }
6
- end
7
-
8
- Foo.new.f
9
-
10
- __END__
11
- # Classes
12
- class Foo
13
- def f: (**untyped) -> nil
14
- end
data/smoke/ensure1.rb DELETED
@@ -1,21 +0,0 @@
1
- def foo(x)
2
- 42
3
- end
4
-
5
- def bar
6
- x = 1
7
- x = "str"
8
- x = :sym
9
- ensure
10
- foo(x)
11
- end
12
-
13
- bar
14
-
15
- __END__
16
- # Classes
17
- class Object
18
- private
19
- def foo: ((:sym | Integer | String)? x) -> Integer
20
- def bar: -> :sym
21
- end
data/smoke/enum_for.rb DELETED
@@ -1,15 +0,0 @@
1
- def log
2
- nn = nil
3
- ary = [1, "str"].to_enum.map do |n|
4
- nn = n
5
- n.to_s
6
- end
7
- return nn, ary
8
- end
9
-
10
- __END__
11
- # Classes
12
- class Object
13
- private
14
- def log: -> ([(Integer | String)?, Array[String]])
15
- end
data/smoke/enum_for2.rb DELETED
@@ -1,17 +0,0 @@
1
- class Foo
2
- def int_and_str_enum
3
- return enum_for(__method__) unless block_given?
4
-
5
- yield 1
6
- yield 2
7
- yield 3
8
-
9
- 1.0
10
- end
11
- end
12
-
13
- __END__
14
- # Classes
15
- class Foo
16
- def int_and_str_enum: ?{ (Integer) -> untyped } -> (Enumerator[Integer, untyped] | Float)
17
- end
data/smoke/enumerator.rb DELETED
@@ -1,16 +0,0 @@
1
- def hoge
2
- [1, 2, 3].map
3
- end
4
- def fuga
5
- 1.then
6
- end
7
- hoge
8
- fuga
9
-
10
- __END__
11
- # Classes
12
- class Object
13
- private
14
- def hoge: -> Enumerator[Integer]
15
- def fuga: -> Enumerator[Integer]
16
- end
@@ -1,23 +0,0 @@
1
- def foo
2
- if rand < 0.5
3
- unknown
4
- else
5
- [:a, [:b, :c]]
6
- end
7
- end
8
-
9
- a, (b, c) = foo
10
-
11
- p(a)
12
- __END__
13
- # Errors
14
- smoke/expandarray1.rb:3: [error] undefined method: Object#unknown
15
-
16
- # Revealed types
17
- # smoke/expandarray1.rb:11 #=> :a | untyped
18
-
19
- # Classes
20
- class Object
21
- private
22
- def foo: -> ([:a, [:b, :c]] | untyped)
23
- end
@@ -1,24 +0,0 @@
1
- def foo
2
- if rand < 0.5
3
- unknown
4
- else
5
- [:a, [:b, :c]]
6
- end
7
- end
8
-
9
- a, *bc = foo
10
-
11
- p(a)
12
-
13
- __END__
14
- # Errors
15
- smoke/expandarray2.rb:3: [error] undefined method: Object#unknown
16
-
17
- # Revealed types
18
- # smoke/expandarray2.rb:11 #=> :a | untyped
19
-
20
- # Classes
21
- class Object
22
- private
23
- def foo: -> ([:a, [:b, :c]] | untyped)
24
- end
data/smoke/extended.rb DELETED
@@ -1,38 +0,0 @@
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/fib.rb DELETED
@@ -1,28 +0,0 @@
1
- class Fib
2
- def fib_loop(x)
3
- a, b = 0, 1
4
- while x > 0
5
- a, b = b, a+b
6
- x -= 1
7
- end
8
- a
9
- end
10
-
11
- def fib_rec(x)
12
- if x <= 1
13
- x
14
- else
15
- fib_rec(x-1) + fib_rec(x-2)
16
- end
17
- end
18
- end
19
-
20
- Fib.new.fib_loop(42)
21
- Fib.new.fib_rec(42)
22
-
23
- __END__
24
- # Classes
25
- class Fib
26
- def fib_loop: (Integer x) -> Integer
27
- def fib_rec: (Integer x) -> Integer
28
- end
data/smoke/flip-flop.rb DELETED
@@ -1,28 +0,0 @@
1
- def cond1?
2
- rand < 0.5
3
- end
4
-
5
- def cond2?
6
- rand < 0.5
7
- end
8
-
9
- def foo
10
- while true
11
- if cond1? .. cond2?
12
- return 42
13
- end
14
- if cond1? .. cond2?
15
- return "str"
16
- end
17
- end
18
- return
19
- end
20
-
21
- __END__
22
- # Classes
23
- class Object
24
- private
25
- def cond1?: -> bool
26
- def cond2?: -> bool
27
- def foo: -> (Integer | String)
28
- end
data/smoke/flow1.rb DELETED
@@ -1,17 +0,0 @@
1
- def foo(n)
2
- if n.is_a?(Integer)
3
- n + 1
4
- else
5
- n + "STR"
6
- end
7
- end
8
-
9
- foo(42)
10
- foo("str")
11
-
12
- __END__
13
- # Classes
14
- class Object
15
- private
16
- def foo: (Integer | String n) -> (Integer | String)
17
- end