typeprof 0.8.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (298) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +6 -5
  3. data/doc/demo.md +1 -1
  4. data/doc/todo.md +133 -0
  5. data/lib/typeprof/analyzer.rb +177 -76
  6. data/lib/typeprof/arguments.rb +2 -0
  7. data/lib/typeprof/block.rb +40 -2
  8. data/lib/typeprof/builtin.rb +279 -111
  9. data/lib/typeprof/cli.rb +5 -0
  10. data/lib/typeprof/config.rb +15 -1
  11. data/lib/typeprof/container-type.rb +5 -4
  12. data/lib/typeprof/export.rb +115 -70
  13. data/lib/typeprof/import.rb +71 -33
  14. data/lib/typeprof/iseq.rb +46 -11
  15. data/lib/typeprof/method.rb +42 -21
  16. data/lib/typeprof/type.rb +93 -15
  17. data/lib/typeprof/version.rb +1 -1
  18. data/smoke/alias.rb +4 -4
  19. data/smoke/alias2.rb +6 -4
  20. data/smoke/any1.rb +1 -1
  21. data/smoke/any2.rb +2 -2
  22. data/smoke/arguments.rb +2 -2
  23. data/smoke/arguments2.rb +10 -10
  24. data/smoke/array-each.rb +1 -1
  25. data/smoke/array-each2.rb +1 -1
  26. data/smoke/array-each3.rb +1 -1
  27. data/smoke/array-ltlt.rb +1 -1
  28. data/smoke/array-ltlt2.rb +1 -1
  29. data/smoke/array-map.rb +1 -1
  30. data/smoke/array-map2.rb +1 -1
  31. data/smoke/array-map3.rb +3 -3
  32. data/smoke/array-mul.rb +2 -2
  33. data/smoke/array-plus1.rb +1 -1
  34. data/smoke/array-plus2.rb +3 -2
  35. data/smoke/array-pop.rb +1 -1
  36. data/smoke/array-range-aref.rb +11 -11
  37. data/smoke/array-replace.rb +1 -1
  38. data/smoke/array-s-aref.rb +1 -1
  39. data/smoke/array1.rb +5 -5
  40. data/smoke/array10.rb +1 -1
  41. data/smoke/array11.rb +1 -1
  42. data/smoke/array12.rb +3 -3
  43. data/smoke/array13.rb +4 -4
  44. data/smoke/array14.rb +1 -1
  45. data/smoke/array15.rb +16 -0
  46. data/smoke/array2.rb +3 -3
  47. data/smoke/array3.rb +5 -4
  48. data/smoke/array4.rb +1 -1
  49. data/smoke/array5.rb +1 -1
  50. data/smoke/array6.rb +3 -2
  51. data/smoke/array7.rb +1 -1
  52. data/smoke/array8.rb +1 -1
  53. data/smoke/array9.rb +1 -1
  54. data/smoke/attr-module.rb +27 -0
  55. data/smoke/attr-vis.rb +43 -0
  56. data/smoke/attr-vis.rbs +4 -0
  57. data/smoke/attr.rb +5 -5
  58. data/smoke/autoload.rb +1 -1
  59. data/smoke/backtrace.rb +3 -3
  60. data/smoke/block-ambiguous.rb +8 -8
  61. data/smoke/block-args1-rest.rb +12 -11
  62. data/smoke/block-args1.rb +10 -10
  63. data/smoke/block-args2-rest.rb +12 -11
  64. data/smoke/block-args2.rb +10 -10
  65. data/smoke/block-args3-rest.rb +14 -13
  66. data/smoke/block-args3.rb +12 -12
  67. data/smoke/block-blockarg.rb +4 -4
  68. data/smoke/block-kwarg.rb +10 -10
  69. data/smoke/block1.rb +1 -1
  70. data/smoke/block10.rb +1 -1
  71. data/smoke/block11.rb +5 -5
  72. data/smoke/block12.rb +2 -2
  73. data/smoke/block14.rb +2 -2
  74. data/smoke/block2.rb +1 -1
  75. data/smoke/block3.rb +3 -3
  76. data/smoke/block4.rb +2 -2
  77. data/smoke/block5.rb +3 -2
  78. data/smoke/block6.rb +2 -2
  79. data/smoke/block7.rb +1 -1
  80. data/smoke/block8.rb +3 -3
  81. data/smoke/block9.rb +1 -1
  82. data/smoke/block_given.rb +37 -0
  83. data/smoke/blown.rb +1 -1
  84. data/smoke/break1.rb +2 -2
  85. data/smoke/break2.rb +1 -1
  86. data/smoke/break3.rb +13 -0
  87. data/smoke/case.rb +1 -1
  88. data/smoke/case2.rb +1 -1
  89. data/smoke/case3.rb +17 -0
  90. data/smoke/class-hierarchy.rb +5 -5
  91. data/smoke/class-hierarchy2.rb +3 -3
  92. data/smoke/class-new.rb +15 -0
  93. data/smoke/class_instance_var.rb +1 -1
  94. data/smoke/class_method.rb +2 -2
  95. data/smoke/class_method2.rb +2 -2
  96. data/smoke/class_method3.rb +2 -2
  97. data/smoke/constant1.rb +6 -6
  98. data/smoke/constant2.rb +5 -4
  99. data/smoke/constant3.rb +1 -1
  100. data/smoke/constant4.rb +1 -1
  101. data/smoke/context-sensitive1.rb +1 -1
  102. data/smoke/cvar.rb +6 -5
  103. data/smoke/cvar2.rb +2 -2
  104. data/smoke/define_method.rb +2 -2
  105. data/smoke/define_method2.rb +2 -2
  106. data/smoke/define_method3.rb +14 -0
  107. data/smoke/define_method3.rbs +3 -0
  108. data/smoke/define_method4.rb +15 -0
  109. data/smoke/define_method4.rbs +3 -0
  110. data/smoke/define_method5.rb +12 -0
  111. data/smoke/define_method6.rb +19 -0
  112. data/smoke/demo.rb +6 -6
  113. data/smoke/demo1.rb +1 -1
  114. data/smoke/demo10.rb +2 -2
  115. data/smoke/demo11.rb +1 -1
  116. data/smoke/demo2.rb +1 -1
  117. data/smoke/demo3.rb +1 -1
  118. data/smoke/demo4.rb +3 -3
  119. data/smoke/demo5.rb +1 -1
  120. data/smoke/demo6.rb +4 -3
  121. data/smoke/demo7.rb +1 -1
  122. data/smoke/demo8.rb +2 -2
  123. data/smoke/demo9.rb +3 -2
  124. data/smoke/dummy-execution1.rb +2 -2
  125. data/smoke/dummy-execution2.rb +2 -2
  126. data/smoke/dummy_element.rb +14 -0
  127. data/smoke/ensure1.rb +2 -2
  128. data/smoke/enum_for.rb +15 -0
  129. data/smoke/enum_for2.rb +17 -0
  130. data/smoke/enumerator.rb +2 -2
  131. data/smoke/expandarray1.rb +1 -1
  132. data/smoke/expandarray2.rb +1 -1
  133. data/smoke/fib.rb +2 -2
  134. data/smoke/flip-flop.rb +28 -0
  135. data/smoke/flow1.rb +1 -1
  136. data/smoke/flow10.rb +17 -0
  137. data/smoke/flow2.rb +1 -1
  138. data/smoke/flow3.rb +1 -1
  139. data/smoke/flow5.rb +1 -1
  140. data/smoke/flow6.rb +1 -1
  141. data/smoke/flow7.rb +1 -1
  142. data/smoke/flow8.rb +1 -1
  143. data/smoke/flow9.rb +12 -0
  144. data/smoke/freeze.rb +1 -1
  145. data/smoke/function.rb +2 -2
  146. data/smoke/gvar.rb +2 -2
  147. data/smoke/gvar2.rb +3 -3
  148. data/smoke/hash-bot.rb +12 -0
  149. data/smoke/hash-fetch.rb +3 -3
  150. data/smoke/hash-merge-bang.rb +1 -1
  151. data/smoke/hash1.rb +2 -2
  152. data/smoke/hash2.rb +1 -1
  153. data/smoke/hash3.rb +1 -1
  154. data/smoke/hash4.rb +1 -1
  155. data/smoke/hash5.rb +1 -1
  156. data/smoke/inheritance.rb +4 -4
  157. data/smoke/inheritance2.rb +2 -2
  158. data/smoke/initialize.rb +6 -5
  159. data/smoke/instance_eval.rb +2 -2
  160. data/smoke/instance_eval2.rb +10 -0
  161. data/smoke/instance_eval3.rb +25 -0
  162. data/smoke/int_times.rb +1 -1
  163. data/smoke/integer.rb +1 -1
  164. data/smoke/ivar.rb +5 -4
  165. data/smoke/ivar2.rb +4 -4
  166. data/smoke/ivar3.rb +4 -3
  167. data/smoke/ivar4.rb +21 -0
  168. data/smoke/kernel-class.rb +1 -1
  169. data/smoke/keyword1.rb +1 -1
  170. data/smoke/keyword2.rb +1 -1
  171. data/smoke/keyword3.rb +1 -1
  172. data/smoke/keyword4.rb +1 -1
  173. data/smoke/keyword5.rb +1 -1
  174. data/smoke/kwrest.rb +3 -2
  175. data/smoke/kwsplat1.rb +4 -4
  176. data/smoke/kwsplat2.rb +1 -1
  177. data/smoke/lit-complex.rb +10 -0
  178. data/smoke/lit-encoding.rb +10 -0
  179. data/smoke/manual-rbs.rb +5 -4
  180. data/smoke/manual-rbs2.rb +1 -1
  181. data/smoke/manual-rbs3.rb +3 -2
  182. data/smoke/masgn1.rb +1 -1
  183. data/smoke/masgn2.rb +2 -2
  184. data/smoke/masgn3.rb +1 -1
  185. data/smoke/method_in_branch.rb +3 -3
  186. data/smoke/method_missing.rb +5 -4
  187. data/smoke/module1.rb +2 -2
  188. data/smoke/module2.rb +1 -1
  189. data/smoke/module3.rb +3 -3
  190. data/smoke/module4.rb +3 -2
  191. data/smoke/module5.rb +17 -0
  192. data/smoke/module6.rb +40 -0
  193. data/smoke/module_function1.rb +4 -3
  194. data/smoke/module_function2.rb +4 -3
  195. data/smoke/multiple-include.rb +2 -1
  196. data/smoke/multiple-superclass.rb +1 -1
  197. data/smoke/next1.rb +2 -2
  198. data/smoke/next2.rb +1 -1
  199. data/smoke/object-send1.rb +3 -3
  200. data/smoke/object-send2.rb +10 -0
  201. data/smoke/object-send3.rb +18 -0
  202. data/smoke/once.rb +1 -1
  203. data/smoke/optional1.rb +1 -1
  204. data/smoke/optional2.rb +1 -1
  205. data/smoke/optional3.rb +1 -1
  206. data/smoke/parameterizedd-self.rb +3 -2
  207. data/smoke/parameterizedd-self2.rb +1 -1
  208. data/smoke/pathname1.rb +1 -1
  209. data/smoke/pathname2.rb +1 -1
  210. data/smoke/pattern-match1.rb +1 -1
  211. data/smoke/pattern-match2.rb +1 -1
  212. data/smoke/prepend1.rb +33 -0
  213. data/smoke/prepend2.rb +10 -0
  214. data/smoke/prepend2.rbs +9 -0
  215. data/smoke/primitive_method.rb +19 -0
  216. data/smoke/printf.rb +2 -2
  217. data/smoke/proc.rb +2 -2
  218. data/smoke/proc2.rb +1 -1
  219. data/smoke/proc3.rb +1 -1
  220. data/smoke/proc4.rb +1 -1
  221. data/smoke/proc5.rb +19 -0
  222. data/smoke/public.rb +38 -0
  223. data/smoke/range.rb +1 -1
  224. data/smoke/rbs-alias.rb +1 -1
  225. data/smoke/rbs-attr.rb +5 -5
  226. data/smoke/rbs-attr2.rb +1 -1
  227. data/smoke/rbs-extend.rb +1 -1
  228. data/smoke/rbs-interface.rb +4 -4
  229. data/smoke/rbs-module.rb +26 -0
  230. data/smoke/rbs-module.rbs +4 -0
  231. data/smoke/rbs-opt-and-rest.rb +10 -0
  232. data/smoke/rbs-opt-and-rest.rbs +3 -0
  233. data/smoke/rbs-proc1.rb +1 -1
  234. data/smoke/rbs-proc2.rb +2 -2
  235. data/smoke/rbs-proc3.rb +1 -1
  236. data/smoke/rbs-record.rb +2 -2
  237. data/smoke/rbs-tyvar.rb +2 -2
  238. data/smoke/rbs-tyvar2.rb +2 -2
  239. data/smoke/rbs-tyvar3.rb +2 -2
  240. data/smoke/rbs-tyvar4.rb +4 -3
  241. data/smoke/rbs-tyvar5.rb +1 -1
  242. data/smoke/rbs-tyvar6.rb +3 -3
  243. data/smoke/rbs-tyvar7.rb +1 -1
  244. data/smoke/rbs-vars.rb +6 -6
  245. data/smoke/redo1.rb +2 -2
  246. data/smoke/redo2.rb +2 -2
  247. data/smoke/req-keyword.rb +1 -1
  248. data/smoke/rescue1.rb +2 -2
  249. data/smoke/rescue2.rb +2 -2
  250. data/smoke/rescue3.rb +20 -0
  251. data/smoke/rescue4.rb +17 -0
  252. data/smoke/respond_to.rb +1 -1
  253. data/smoke/rest-farg.rb +1 -1
  254. data/smoke/rest1.rb +2 -2
  255. data/smoke/rest2.rb +1 -1
  256. data/smoke/rest3.rb +6 -6
  257. data/smoke/rest4.rb +2 -2
  258. data/smoke/rest5.rb +1 -1
  259. data/smoke/rest6.rb +1 -1
  260. data/smoke/retry1.rb +2 -2
  261. data/smoke/return.rb +1 -1
  262. data/smoke/simple.rb +12 -0
  263. data/smoke/singleton_method.rb +1 -1
  264. data/smoke/step.rb +3 -3
  265. data/smoke/string-split.rb +1 -1
  266. data/smoke/struct-keyword_init.rb +10 -0
  267. data/smoke/struct.rb +1 -1
  268. data/smoke/struct2.rb +4 -4
  269. data/smoke/struct3.rb +2 -2
  270. data/smoke/struct4.rb +7 -0
  271. data/smoke/struct5.rb +16 -0
  272. data/smoke/struct6.rb +15 -0
  273. data/smoke/struct7.rb +17 -0
  274. data/smoke/stub-keyword.rb +10 -0
  275. data/smoke/super1.rb +4 -4
  276. data/smoke/super2.rb +1 -1
  277. data/smoke/super3.rb +4 -3
  278. data/smoke/super4.rb +7 -5
  279. data/smoke/super5.rb +6 -4
  280. data/smoke/svar1.rb +1 -1
  281. data/smoke/symbol-proc-attr.rb +22 -0
  282. data/smoke/symbol-proc-attr2.rb +15 -0
  283. data/smoke/symbol-proc-bot.rb +13 -0
  284. data/smoke/symbol-proc.rb +3 -3
  285. data/smoke/tap1.rb +2 -2
  286. data/smoke/toplevel.rb +1 -1
  287. data/smoke/two-map.rb +2 -2
  288. data/smoke/type_var.rb +3 -3
  289. data/smoke/typed_method.rb +1 -1
  290. data/smoke/uninitialize-var.rb +1 -1
  291. data/smoke/union-recv.rb +2 -2
  292. data/smoke/user-demo.rb +3 -3
  293. data/smoke/wrong-extend.rb +3 -2
  294. data/smoke/wrong-include.rb +3 -2
  295. data/smoke/wrong-include2.rb +17 -0
  296. data/typeprof.gemspec +1 -1
  297. metadata +59 -6
  298. data/tools/stackprof-wrapper.rb +0 -10
@@ -3,6 +3,7 @@ module TypeProf
3
3
  class ActualArguments
4
4
  def initialize(lead_tys, rest_ty, kw_tys, blk_ty)
5
5
  @lead_tys = lead_tys
6
+ raise unless lead_tys
6
7
  @rest_ty = rest_ty
7
8
  @kw_tys = kw_tys # kw_tys should be {:key1 => Type, :key2 => Type, ...} or {nil => Type}
8
9
  raise if !kw_tys.is_a?(::Hash)
@@ -58,6 +59,7 @@ module TypeProf
58
59
  subst = Type.merge_substitution(subst, subst2)
59
60
  end
60
61
  msig.opt_tys.each do |farg|
62
+ break if aargs.empty?
61
63
  aarg = aargs.shift
62
64
  return nil unless subst2 = Type.match?(aarg, farg)
63
65
  subst = Type.merge_substitution(subst, subst2)
@@ -29,7 +29,10 @@ module TypeProf
29
29
 
30
30
  def do_call(aargs, caller_ep, caller_env, scratch, replace_recv_ty:, &ctn)
31
31
  blk_env = scratch.return_envs[@outer_ep]
32
- blk_env = blk_env.replace_recv_ty(replace_recv_ty) if replace_recv_ty
32
+ if replace_recv_ty
33
+ replace_recv_ty = scratch.globalize_type(replace_recv_ty, caller_env, caller_ep)
34
+ blk_env = blk_env.replace_recv_ty(replace_recv_ty)
35
+ end
33
36
  aargs = scratch.globalize_type(aargs, caller_env, caller_ep)
34
37
 
35
38
  scratch.add_block_signature!(self, aargs.to_block_signature)
@@ -119,11 +122,12 @@ module TypeProf
119
122
  def do_call(aargs, caller_ep, caller_env, scratch, replace_recv_ty:, &ctn)
120
123
  if aargs.lead_tys.size >= 1
121
124
  recv = aargs.lead_tys[0]
125
+ recv = Type.any if recv == Type.bot
122
126
  aargs = ActualArguments.new(aargs.lead_tys[1..], aargs.rest_ty, aargs.kw_tys, aargs.blk_ty)
123
127
  elsif aargs.rest_ty
124
128
  recv = aargs.rest_ty.elems.squash_or_any # XXX: need to shift
125
129
  else
126
- raise
130
+ recv = Type.any
127
131
  end
128
132
 
129
133
  scratch.add_block_signature!(self, aargs.to_block_signature)
@@ -133,4 +137,38 @@ module TypeProf
133
137
  end
134
138
  end
135
139
  end
140
+
141
+ class CustomBlock < Block
142
+ def initialize(caller_ep, mid, &blk)
143
+ @caller_ep = caller_ep
144
+ @mid = mid
145
+ @blk = blk
146
+ end
147
+
148
+ def inspect
149
+ "#<CustomBlock>"
150
+ end
151
+
152
+ def consistent?(other)
153
+ true # XXX
154
+ end
155
+
156
+ def substitute(_subst, _depth)
157
+ self
158
+ end
159
+
160
+ def do_call(aargs, caller_ep, caller_env, scratch, replace_recv_ty:, &ctn)
161
+ aargs = scratch.globalize_type(aargs, caller_env, caller_ep)
162
+
163
+ dummy_ctx = TypedContext.new(@caller_ep, @mid)
164
+
165
+ scratch.add_block_signature!(self, aargs.to_block_signature)
166
+ scratch.add_block_to_ctx!(self, dummy_ctx)
167
+
168
+ @blk.call(aargs, caller_ep, caller_env, scratch, replace_recv_ty: replace_recv_ty) do |ret_ty, ep, env|
169
+ scratch.add_return_value!(dummy_ctx, ret_ty)
170
+ ctn[ret_ty, ep, env]
171
+ end
172
+ end
173
+ end
136
174
  end
@@ -19,7 +19,7 @@ module TypeProf
19
19
  klass, new_mid, old_mid = aargs.lead_tys
20
20
  new_sym = get_sym("alias", new_mid, ep, scratch) or return
21
21
  old_sym = get_sym("alias", old_mid, ep, scratch) or return
22
- scratch.alias_method(klass, ep.ctx.cref.singleton, new_sym, old_sym)
22
+ scratch.alias_method(klass, ep.ctx.cref.singleton, new_sym, old_sym, ep)
23
23
  ctn[Type.nil, ep, env]
24
24
  end
25
25
 
@@ -82,14 +82,17 @@ module TypeProf
82
82
  end
83
83
 
84
84
  def object_is_a?(recv, mid, aargs, ep, env, scratch, &ctn)
85
- raise unless aargs.lead_tys.size != 0
86
- if recv.is_a?(Type::Instance)
87
- if recv.klass == aargs.lead_tys[0] # XXX: inheritance
88
- true_val = Type::Instance.new(Type::Builtin[:true])
89
- ctn[true_val, ep, env]
85
+ if aargs.lead_tys.size == 1
86
+ if recv.is_a?(Type::Instance)
87
+ if recv.klass == aargs.lead_tys[0] # XXX: inheritance
88
+ true_val = Type::Instance.new(Type::Builtin[:true])
89
+ ctn[true_val, ep, env]
90
+ else
91
+ false_val = Type::Instance.new(Type::Builtin[:false])
92
+ ctn[false_val, ep, env]
93
+ end
90
94
  else
91
- false_val = Type::Instance.new(Type::Builtin[:false])
92
- ctn[false_val, ep, env]
95
+ ctn[Type.bool, ep, env]
93
96
  end
94
97
  else
95
98
  ctn[Type.bool, ep, env]
@@ -97,16 +100,19 @@ module TypeProf
97
100
  end
98
101
 
99
102
  def object_respond_to?(recv, mid, aargs, ep, env, scratch, &ctn)
100
- raise unless aargs.lead_tys.size != 0
101
- sym = get_sym("respond_to?", aargs.lead_tys[0], ep, scratch)
102
- if sym
103
- klass, singleton = recv.method_dispatch_info
104
- if scratch.get_method(klass, singleton, sym)
105
- true_val = Type::Instance.new(Type::Builtin[:true])
106
- ctn[true_val, ep, env]
103
+ if aargs.lead_tys.size == 1
104
+ sym = get_sym("respond_to?", aargs.lead_tys[0], ep, scratch)
105
+ if sym
106
+ klass, singleton = recv.method_dispatch_info
107
+ if scratch.get_method(klass, singleton, sym)
108
+ true_val = Type::Instance.new(Type::Builtin[:true])
109
+ ctn[true_val, ep, env]
110
+ else
111
+ false_val = Type::Instance.new(Type::Builtin[:false])
112
+ ctn[false_val, ep, env]
113
+ end
107
114
  else
108
- false_val = Type::Instance.new(Type::Builtin[:false])
109
- ctn[false_val, ep, env]
115
+ ctn[Type.bool, ep, env]
110
116
  end
111
117
  else
112
118
  ctn[Type.bool, ep, env]
@@ -124,10 +130,12 @@ module TypeProf
124
130
  def object_send(recv, mid, aargs, ep, env, scratch, &ctn)
125
131
  if aargs.lead_tys.size >= 1
126
132
  mid_ty, = aargs.lead_tys
127
- else
133
+ elsif aargs.rest_ty
128
134
  mid_ty = aargs.rest_ty
135
+ else
136
+ return ctn[Type.any, ep, env]
129
137
  end
130
- aargs = ActualArguments.new(aargs.lead_tys[1..-1], aargs.rest_ty, aargs.kw_tys, aargs.blk_ty)
138
+ aargs = ActualArguments.new(aargs.lead_tys[1..] || [], aargs.rest_ty, aargs.kw_tys, aargs.blk_ty)
131
139
  found = false
132
140
  mid_ty.each_child do |mid|
133
141
  if mid.is_a?(Type::Symbol)
@@ -148,8 +156,70 @@ module TypeProf
148
156
  return
149
157
  end
150
158
  naargs = ActualArguments.new([recv], nil, {}, Type.nil)
151
- scratch.do_invoke_block(aargs.blk_ty, naargs, ep, env, replace_recv_ty: recv) do |_ret_ty, ep|
152
- ctn[recv, ep, scratch.return_envs[ep]]
159
+ nrecv = recv
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 |_ret_ty, ep|
162
+ ctn[recv, ep, env]
163
+ end
164
+ end
165
+
166
+ def object_enum_for(recv, mid, aargs, ep, env, scratch, &ctn)
167
+ if aargs.lead_tys.size >= 1
168
+ mid_ty, = aargs.lead_tys
169
+ naargs = ActualArguments.new(aargs.lead_tys[1..], aargs.rest_ty, aargs.kw_tys, aargs.blk_ty)
170
+ elsif aargs.rest_ty
171
+ mid_ty = aargs.rest_ty
172
+ naargs = aargs
173
+ else
174
+ mid_ty = Type::Symbol.new(:each, Type::Instance.new(Type::Builtin[:sym]))
175
+ naargs = aargs
176
+ end
177
+
178
+ elem_ty = Type.bot
179
+ enum_for_blk = CustomBlock.new(ep, mid) do |aargs, caller_ep, caller_env, scratch, replace_recv_ty:, &blk_ctn|
180
+ if aargs.lead_tys.size >= 1
181
+ elem_ty = elem_ty.union(aargs.lead_tys[0])
182
+ else
183
+ elem_ty = elem_ty.union(Type.any)
184
+ end
185
+ ctn[Type::Cell.new(Type::Cell::Elements.new([elem_ty, Type.any]), Type::Instance.new(Type::Builtin[:enumerator])), ep, env]
186
+ blk_ctn[Type.any, caller_ep, caller_env]
187
+ end
188
+ enum_for_blk_ty = Type::Proc.new(enum_for_blk, Type::Instance.new(Type::Builtin[:proc]))
189
+
190
+ naargs = ActualArguments.new(naargs.lead_tys, naargs.rest_ty, naargs.kw_tys, enum_for_blk_ty)
191
+ mid_ty.each_child do |mid|
192
+ if mid.is_a?(Type::Symbol)
193
+ mid = mid.sym
194
+ scratch.do_send(recv, mid, naargs, ep, env) do |_ret_ty, _ep|
195
+ ctn[Type::Cell.new(Type::Cell::Elements.new([elem_ty, Type.any]), Type::Instance.new(Type::Builtin[:enumerator])), ep, env]
196
+ end
197
+ end
198
+ end
199
+ end
200
+
201
+ def object_privitive_method(recv, mid, aargs, ep, env, scratch, &ctn)
202
+ ctn[Type::Symbol.new(ep.ctx.mid, Type::Instance.new(Type::Builtin[:sym])), ep, env]
203
+ end
204
+
205
+ def object_block_given?(recv, mid, aargs, ep, env, scratch, &ctn)
206
+ procs = Type.bot
207
+ no_proc = false
208
+ env.static_env.blk_ty.each_child do |blk_ty|
209
+ case blk_ty
210
+ when Type::Proc
211
+ procs = procs.union(blk_ty)
212
+ when Type.nil
213
+ no_proc = true
214
+ else
215
+ ctn[Type.bool, ep, env]
216
+ end
217
+ end
218
+ if procs != Type.bot
219
+ ctn[Type::Instance.new(Type::Builtin[:true]), ep, env.replace_blk_ty(procs)]
220
+ end
221
+ if no_proc
222
+ ctn[Type::Instance.new(Type::Builtin[:false]), ep, env.replace_blk_ty(Type.nil)]
153
223
  end
154
224
  end
155
225
 
@@ -159,10 +229,16 @@ module TypeProf
159
229
  ctn[Type.any, ep, env]
160
230
  return
161
231
  end
232
+
233
+ unless recv.is_a?(Type::Class)
234
+ # XXX: warn?
235
+ return ctn[Type.any, ep, env]
236
+ end
237
+
162
238
  arg = aargs.lead_tys[0]
163
239
  arg.each_child do |arg|
164
240
  if arg.is_a?(Type::Class)
165
- scratch.include_module(recv, arg, nil, false, ep.ctx.iseq.absolute_path)
241
+ scratch.mix_module(:after, recv, arg, nil, ep.ctx.cref.singleton, ep)
166
242
  end
167
243
  end
168
244
  ctn[recv, ep, env]
@@ -174,10 +250,38 @@ module TypeProf
174
250
  ctn[Type.any, ep, env]
175
251
  return
176
252
  end
253
+
254
+ unless recv.is_a?(Type::Class)
255
+ # XXX: warn?
256
+ return ctn[Type.any, ep, env]
257
+ end
258
+
259
+ arg = aargs.lead_tys[0]
260
+ arg.each_child do |arg|
261
+ if arg.is_a?(Type::Class)
262
+ # if ep.ctx.cref.singleton is true, the meta-meta level is ignored. Should we warn?
263
+ scratch.mix_module(:after, recv, arg, nil, true, ep)
264
+ end
265
+ end
266
+ ctn[recv, ep, env]
267
+ end
268
+
269
+ def module_prepend(recv, mid, aargs, ep, env, scratch, &ctn)
270
+ if aargs.lead_tys.size != 1
271
+ scratch.warn(ep, "Module#prepend without an argument is ignored")
272
+ ctn[Type.any, ep, env]
273
+ return
274
+ end
275
+
276
+ unless recv.is_a?(Type::Class)
277
+ # XXX: warn?
278
+ return ctn[Type.any, ep, env]
279
+ end
280
+
177
281
  arg = aargs.lead_tys[0]
178
282
  arg.each_child do |arg|
179
283
  if arg.is_a?(Type::Class)
180
- scratch.include_module(recv, arg, nil, true, ep.ctx.iseq.absolute_path)
284
+ scratch.mix_module(:before, recv, arg, nil, ep.ctx.cref.singleton, ep)
181
285
  end
182
286
  end
183
287
  ctn[recv, ep, env]
@@ -202,13 +306,17 @@ module TypeProf
202
306
  if aargs.lead_tys.empty?
203
307
  ctn[recv, ep, env.method_public_set(true)]
204
308
  else
205
- aargs.lead_tys.each do |aarg|
206
- sym = get_sym("public", aarg, ep, scratch) or next
207
- meths = scratch.get_method(recv, false, sym)
208
- next unless meths
209
- meths.each do |mdef|
210
- mdef.pub_meth = true
309
+ if recv.is_a?(Type::Class)
310
+ aargs.lead_tys.each do |aarg|
311
+ sym = get_sym("public", aarg, ep, scratch) or next
312
+ meths = scratch.get_method(recv, false, sym)
313
+ next unless meths
314
+ meths.each do |mdef|
315
+ mdef.pub_meth = true if mdef.respond_to?(:pub_meth=)
316
+ end
211
317
  end
318
+ else
319
+ # XXX: warn?
212
320
  end
213
321
  ctn[recv, ep, env]
214
322
  end
@@ -218,13 +326,17 @@ module TypeProf
218
326
  if aargs.lead_tys.empty?
219
327
  ctn[recv, ep, env.method_public_set(false)]
220
328
  else
221
- aargs.lead_tys.each do |aarg|
222
- sym = get_sym("private", aarg, ep, scratch) or next
223
- meths = scratch.get_method(recv, false, sym)
224
- next unless meths
225
- meths.each do |mdef|
226
- mdef.pub_meth = false
329
+ if recv.is_a?(Type::Class)
330
+ aargs.lead_tys.each do |aarg|
331
+ sym = get_sym("private", aarg, ep, scratch) or next
332
+ meths = scratch.get_method(recv, false, sym)
333
+ next unless meths
334
+ meths.each do |mdef|
335
+ mdef.pub_meth = false if mdef.respond_to?(:pub_meth=)
336
+ end
227
337
  end
338
+ else
339
+ # XXX: warn?
228
340
  end
229
341
  ctn[recv, ep, env]
230
342
  end
@@ -238,23 +350,25 @@ module TypeProf
238
350
  end
239
351
 
240
352
  mid, = aargs.lead_tys
241
- if mid.is_a?(Type::Symbol)
242
- mid = mid.sym
243
- aargs.blk_ty.each_child do |blk_ty|
244
- if blk_ty.is_a?(Type::Proc)
245
- blk = blk_ty.block_body
246
- case blk
247
- when ISeqBlock
248
- scratch.do_define_iseq_method(ep, env, mid, blk.iseq, ep)
353
+ mid.each_child do |mid|
354
+ if mid.is_a?(Type::Symbol)
355
+ mid = mid.sym
356
+ aargs.blk_ty.each_child do |blk_ty|
357
+ if blk_ty.is_a?(Type::Proc)
358
+ blk = blk_ty.block_body
359
+ case blk
360
+ when ISeqBlock
361
+ scratch.do_define_iseq_method(ep, env, mid, blk.iseq, blk.outer_ep)
362
+ else
363
+ # XXX: what to do?
364
+ end
249
365
  else
250
366
  # XXX: what to do?
251
367
  end
252
- else
253
- # XXX: what to do?
254
368
  end
369
+ else
370
+ # XXX: what to do?
255
371
  end
256
- else
257
- # XXX: what to do?
258
372
  end
259
373
  ctn[Type.any, ep, env]
260
374
  end
@@ -263,7 +377,7 @@ module TypeProf
263
377
  aargs.lead_tys.each do |aarg|
264
378
  sym = get_sym("attr_accessor", aarg, ep, scratch) or next
265
379
  cref = ep.ctx.cref
266
- scratch.add_attr_method(cref.klass, ep.ctx.iseq.absolute_path, sym, :"@#{ sym }", :accessor)
380
+ scratch.add_attr_method(cref.klass, sym, :"@#{ sym }", :accessor, env.static_env.pub_meth, ep)
267
381
  end
268
382
  ctn[Type.nil, ep, env]
269
383
  end
@@ -272,7 +386,7 @@ module TypeProf
272
386
  aargs.lead_tys.each do |aarg|
273
387
  sym = get_sym("attr_reader", aarg, ep, scratch) or next
274
388
  cref = ep.ctx.cref
275
- scratch.add_attr_method(cref.klass, ep.ctx.iseq.absolute_path, sym, :"@#{ sym }", :reader)
389
+ scratch.add_attr_method(cref.klass, sym, :"@#{ sym }", :reader, env.static_env.pub_meth, ep)
276
390
  end
277
391
  ctn[Type.nil, ep, env]
278
392
  end
@@ -281,7 +395,7 @@ module TypeProf
281
395
  aargs.lead_tys.each do |aarg|
282
396
  sym = get_sym("attr_writer", aarg, ep, scratch) or next
283
397
  cref = ep.ctx.cref
284
- scratch.add_attr_method(cref.klass, ep.ctx.iseq.absolute_path, sym, :"@#{ sym }", :writer)
398
+ scratch.add_attr_method(cref.klass, sym, :"@#{ sym }", :writer, env.static_env.pub_meth, ep)
285
399
  end
286
400
  ctn[Type.nil, ep, env]
287
401
  end
@@ -323,14 +437,19 @@ module TypeProf
323
437
  return ctn[Type.any, ep, env] unless recv.is_a?(Type::Local) && recv.kind == Type::Array
324
438
 
325
439
  if aargs.lead_tys.size != 2
440
+ # XXX: Support `ary[idx, len] = val`
326
441
  #raise NotImplementedError # XXX
327
- ctn[Type.any, ep, env]
442
+ return ctn[Type.any, ep, env]
328
443
  end
329
444
 
330
445
  idx = aargs.lead_tys.first
331
446
  if idx.is_a?(Type::Literal)
332
447
  idx = idx.lit
333
- raise NotImplementedError if !idx.is_a?(Integer)
448
+ if !idx.is_a?(Integer)
449
+ # XXX: Support `ary[idx..end] = val`
450
+ #raise NotImplementedError # XXX
451
+ return ctn[Type.any, ep, env]
452
+ end
334
453
  else
335
454
  idx = nil
336
455
  end
@@ -367,6 +486,7 @@ module TypeProf
367
486
  recv.each_child do |recv|
368
487
  if recv.is_a?(Type::Local) && recv.kind == Type::Hash
369
488
  ty = scratch.get_hash_elem_type(env, ep, recv.id, idx)
489
+ ty = Type.nil if ty == Type.bot
370
490
  else
371
491
  ty = Type.any
372
492
  end
@@ -377,7 +497,11 @@ module TypeProf
377
497
  def hash_aset(recv, mid, aargs, ep, env, scratch, &ctn)
378
498
  return ctn[Type.any, ep, env] unless recv.is_a?(Type::Local) && recv.kind == Type::Hash
379
499
 
380
- raise NotImplementedError if aargs.lead_tys.size != 2
500
+ if aargs.lead_tys.size != 2
501
+ # XXX: error?
502
+ ctn[Type.any, ep, env]
503
+ return
504
+ end
381
505
 
382
506
  idx = aargs.lead_tys.first
383
507
  idx = scratch.globalize_type(idx, env, ep)
@@ -396,18 +520,7 @@ module TypeProf
396
520
  end
397
521
 
398
522
  def struct_initialize(recv, mid, aargs, ep, env, scratch, &ctn)
399
- recv = Type::Instance.new(recv)
400
- scratch.add_ivar_read!(recv, :_members, ep) do |member_ary_ty, ep|
401
- member_ary_ty.elems.lead_tys.zip(aargs.lead_tys) do |sym, ty|
402
- ty ||= Type.nil
403
- scratch.set_instance_variable(recv, sym.sym, ty, ep, env)
404
- end
405
- end
406
- ctn[recv, ep, env]
407
- end
408
-
409
- def struct_i_new(recv, mid, aargs, ep, env, scratch, &ctn)
410
- struct_klass = recv
523
+ struct_klass = recv.klass
411
524
  while struct_klass.superclass != Type::Builtin[:struct]
412
525
  struct_klass = struct_klass.superclass
413
526
  end
@@ -415,34 +528,57 @@ module TypeProf
415
528
  ctn[Type.any, ep, env]
416
529
  return
417
530
  end
418
- if struct_klass != recv
419
- scratch.add_ivar_read!(Type::Instance.new(struct_klass), :_members, ep) do |ty, ep|
420
- scratch.add_ivar_write!(Type::Instance.new(recv), :_members, ty, ep)
421
- end
422
- end
423
- meths = scratch.get_method(recv, false, :initialize)
424
- meths.flat_map do |meth|
425
- meth.do_send(recv, :initialize, aargs, ep, env, scratch) do |ret_ty, ep, env|
426
- ctn[Type::Instance.new(recv), ep, env]
531
+ scratch.add_ivar_read!(Type::Instance.new(struct_klass), :_keyword_init, ep) do |keyword_init, ep|
532
+ scratch.add_ivar_read!(Type::Instance.new(struct_klass), :_members, ep) do |member_ary_ty, ep|
533
+ next if member_ary_ty == Type.nil
534
+ if keyword_init == Type::Instance.new(Type::Builtin[:true])
535
+ # TODO: support kw_rest_ty
536
+ aargs.kw_tys.each do |key, val_ty|
537
+ found = false
538
+ member_ary_ty.elems.lead_tys.each do |sym|
539
+ if sym.sym == key
540
+ found = true
541
+ scratch.set_instance_variable(recv, sym.sym, val_ty, ep, env)
542
+ end
543
+ end
544
+ unless found
545
+ # TODO: what to do when not found?
546
+ end
547
+ end
548
+ else
549
+ member_ary_ty.elems.lead_tys.zip(aargs.lead_tys) do |sym, ty|
550
+ ty ||= Type.nil
551
+ scratch.set_instance_variable(recv, sym.sym, ty, ep, env)
552
+ end
553
+ end
427
554
  end
428
555
  end
556
+ ctn[recv, ep, env]
429
557
  end
430
558
 
431
559
  def struct_s_new(recv, mid, aargs, ep, env, scratch, &ctn)
432
560
  # TODO: keyword_init
433
561
 
562
+ keyword_init = false
563
+ if aargs.kw_tys && aargs.kw_tys[:keyword_init] # XXX: more canonical way to extract keyword...
564
+ if aargs.kw_tys[:keyword_init] == Type::Instance.new(Type::Builtin[:true])
565
+ keyword_init = true
566
+ end
567
+ end
568
+
434
569
  fields = aargs.lead_tys.map {|ty| get_sym("Struct.new", ty, ep, scratch) }.compact
435
570
  struct_klass = scratch.new_struct(ep)
436
571
 
437
- scratch.set_singleton_custom_method(struct_klass, :new, Builtin.method(:struct_i_new))
438
- scratch.set_singleton_custom_method(struct_klass, :[], Builtin.method(:struct_i_new))
572
+ scratch.set_singleton_custom_method(struct_klass, :new, Builtin.method(:object_s_new))
573
+ scratch.set_singleton_custom_method(struct_klass, :[], Builtin.method(:object_s_new))
439
574
  fields.each do |field|
440
- scratch.add_attr_method(struct_klass, ep.ctx.iseq.absolute_path, field, field, :accessor)
575
+ scratch.add_attr_method(struct_klass, field, field, :accessor, true, ep)
441
576
  end
442
577
  fields = fields.map {|field| Type::Symbol.new(field, Type::Instance.new(Type::Builtin[:sym])) }
443
578
  base_ty = Type::Instance.new(Type::Builtin[:ary])
444
579
  fields = Type::Array.new(Type::Array::Elements.new(fields), base_ty)
445
580
  scratch.add_ivar_write!(Type::Instance.new(struct_klass), :_members, fields, ep)
581
+ scratch.add_ivar_write!(Type::Instance.new(struct_klass), :_keyword_init, Type::Instance.new(Type::Builtin[:true]), ep) if keyword_init
446
582
  #set_singleton_custom_method(struct_klass, :members, Builtin.method(:...))
447
583
 
448
584
  ctn[struct_klass, ep, env]
@@ -491,11 +627,20 @@ module TypeProf
491
627
  end
492
628
 
493
629
  def kernel_require(recv, mid, aargs, ep, env, scratch, &ctn)
494
- raise NotImplementedError if aargs.lead_tys.size != 1
630
+ if aargs.lead_tys.size != 1
631
+ # XXX: handle correctly
632
+ ctn[Type.any, ep, env]
633
+ return
634
+ end
635
+
495
636
  feature = aargs.lead_tys.first
496
637
  if feature.is_a?(Type::Literal)
497
638
  feature = feature.lit
498
639
 
640
+ unless feature.is_a?(String)
641
+ return ctn[Type.any, ep, env]
642
+ end
643
+
499
644
  action, arg = Builtin.file_require(feature, scratch)
500
645
  case action
501
646
  when :do
@@ -505,22 +650,31 @@ module TypeProf
505
650
  ctn[result, ep, env]
506
651
  when :error
507
652
  scratch.warn(ep, arg)
508
- result = Type::Instance.new(Type.bool)
653
+ result = Type.bool
509
654
  ctn[result, ep, env]
510
655
  end
511
656
  else
512
657
  scratch.warn(ep, "require target cannot be identified statically")
513
- result = Type::Instance.new(Type.bool)
658
+ result = Type.bool
514
659
  ctn[result, ep, env]
515
660
  end
516
661
  end
517
662
 
518
663
  def kernel_require_relative(recv, mid, aargs, ep, env, scratch, &ctn)
519
- raise NotImplementedError if aargs.lead_tys.size != 1
664
+ if aargs.lead_tys.size != 1
665
+ # XXX: handle correctly
666
+ ctn[Type.any, ep, env]
667
+ return
668
+ end
669
+
520
670
  feature = aargs.lead_tys.first
521
671
  if feature.is_a?(Type::Literal)
522
672
  feature = feature.lit
523
673
 
674
+ unless feature.is_a?(String)
675
+ return ctn[Type.any, ep, env]
676
+ end
677
+
524
678
  if scratch.loaded_features[feature]
525
679
  result = Type::Instance.new(Type::Builtin[:false])
526
680
  return ctn[result, ep, env]
@@ -541,7 +695,12 @@ module TypeProf
541
695
  end
542
696
 
543
697
  def kernel_autoload(recv, mid, aargs, ep, env, scratch, &ctn)
544
- raise NotImplementedError if aargs.lead_tys.size != 2
698
+ if aargs.lead_tys.size != 2
699
+ # XXX: handle correctly
700
+ ctn[Type.any, ep, env]
701
+ return
702
+ end
703
+
545
704
  feature = aargs.lead_tys[1]
546
705
  if feature.is_a?(Type::Literal)
547
706
  feature = feature.lit
@@ -593,23 +752,26 @@ module TypeProf
593
752
 
594
753
  Import.import_builtin(scratch)
595
754
 
596
- Type::Builtin[:vmcore] = scratch.new_class(klass_obj, :VMCore, [], klass_obj, nil)
597
- Type::Builtin[:int] = scratch.get_constant(klass_obj, :Integer)
598
- Type::Builtin[:float] = scratch.get_constant(klass_obj, :Float)
599
- Type::Builtin[:rational] = scratch.get_constant(klass_obj, :Rational)
600
- Type::Builtin[:sym] = scratch.get_constant(klass_obj, :Symbol)
601
- Type::Builtin[:str] = scratch.get_constant(klass_obj, :String)
602
- Type::Builtin[:struct] = scratch.get_constant(klass_obj, :Struct)
603
- Type::Builtin[:ary] = scratch.get_constant(klass_obj, :Array)
604
- Type::Builtin[:hash] = scratch.get_constant(klass_obj, :Hash)
605
- Type::Builtin[:io] = scratch.get_constant(klass_obj, :IO)
606
- Type::Builtin[:proc] = scratch.get_constant(klass_obj, :Proc)
607
- Type::Builtin[:range] = scratch.get_constant(klass_obj, :Range)
608
- Type::Builtin[:regexp] = scratch.get_constant(klass_obj, :Regexp)
609
- Type::Builtin[:matchdata] = scratch.get_constant(klass_obj, :MatchData)
610
- Type::Builtin[:class] = scratch.get_constant(klass_obj, :Class)
611
- Type::Builtin[:module] = scratch.get_constant(klass_obj, :Module)
612
- Type::Builtin[:exc] = scratch.get_constant(klass_obj, :Exception)
755
+ Type::Builtin[:vmcore] = scratch.new_class(klass_obj, :VMCore, [], klass_obj, nil)
756
+ Type::Builtin[:int] = scratch.get_constant(klass_obj, :Integer)
757
+ Type::Builtin[:float] = scratch.get_constant(klass_obj, :Float)
758
+ Type::Builtin[:rational] = scratch.get_constant(klass_obj, :Rational)
759
+ Type::Builtin[:complex] = scratch.get_constant(klass_obj, :Complex)
760
+ Type::Builtin[:sym] = scratch.get_constant(klass_obj, :Symbol)
761
+ Type::Builtin[:str] = scratch.get_constant(klass_obj, :String)
762
+ Type::Builtin[:struct] = scratch.get_constant(klass_obj, :Struct)
763
+ Type::Builtin[:ary] = scratch.get_constant(klass_obj, :Array)
764
+ Type::Builtin[:hash] = scratch.get_constant(klass_obj, :Hash)
765
+ Type::Builtin[:io] = scratch.get_constant(klass_obj, :IO)
766
+ Type::Builtin[:proc] = scratch.get_constant(klass_obj, :Proc)
767
+ Type::Builtin[:range] = scratch.get_constant(klass_obj, :Range)
768
+ Type::Builtin[:regexp] = scratch.get_constant(klass_obj, :Regexp)
769
+ Type::Builtin[:matchdata] = scratch.get_constant(klass_obj, :MatchData)
770
+ Type::Builtin[:class] = scratch.get_constant(klass_obj, :Class)
771
+ Type::Builtin[:module] = scratch.get_constant(klass_obj, :Module)
772
+ Type::Builtin[:exc] = scratch.get_constant(klass_obj, :Exception)
773
+ Type::Builtin[:encoding] = scratch.get_constant(klass_obj, :Encoding)
774
+ Type::Builtin[:enumerator] = scratch.get_constant(klass_obj, :Enumerator)
613
775
 
614
776
  klass_vmcore = Type::Builtin[:vmcore]
615
777
  klass_ary = Type::Builtin[:ary]
@@ -624,23 +786,29 @@ module TypeProf
624
786
  scratch.set_custom_method(klass_vmcore, :"core#raise", Builtin.method(:vmcore_raise))
625
787
  scratch.set_custom_method(klass_vmcore, :lambda, Builtin.method(:lambda))
626
788
  scratch.set_singleton_custom_method(klass_obj, :"new", Builtin.method(:object_s_new))
627
- scratch.set_singleton_custom_method(klass_obj, :"attr_accessor", Builtin.method(:module_attr_accessor))
628
- scratch.set_singleton_custom_method(klass_obj, :"attr_reader", Builtin.method(:module_attr_reader))
629
- scratch.set_singleton_custom_method(klass_obj, :"attr_writer", Builtin.method(:module_attr_writer))
630
- scratch.set_custom_method(klass_obj, :p, Builtin.method(:kernel_p))
789
+ scratch.set_custom_method(klass_obj, :p, Builtin.method(:kernel_p), false)
631
790
  scratch.set_custom_method(klass_obj, :is_a?, Builtin.method(:object_is_a?))
632
791
  scratch.set_custom_method(klass_obj, :respond_to?, Builtin.method(:object_respond_to?))
633
792
  scratch.set_custom_method(klass_obj, :class, Builtin.method(:object_class))
634
793
  scratch.set_custom_method(klass_obj, :send, Builtin.method(:object_send))
635
794
  scratch.set_custom_method(klass_obj, :instance_eval, Builtin.method(:object_instance_eval))
636
- scratch.set_custom_method(klass_obj, :proc, Builtin.method(:lambda))
795
+ scratch.set_custom_method(klass_obj, :proc, Builtin.method(:lambda), false)
796
+ scratch.set_custom_method(klass_obj, :__method__, Builtin.method(:object_privitive_method), false)
797
+ scratch.set_custom_method(klass_obj, :block_given?, Builtin.method(:object_block_given?), false)
798
+
799
+ scratch.set_custom_method(klass_obj, :enum_for, Builtin.method(:object_enum_for))
800
+ scratch.set_custom_method(klass_obj, :to_enum, Builtin.method(:object_enum_for))
637
801
 
638
802
  scratch.set_custom_method(klass_module, :include, Builtin.method(:module_include))
639
803
  scratch.set_custom_method(klass_module, :extend, Builtin.method(:module_extend))
640
- scratch.set_custom_method(klass_module, :module_function, Builtin.method(:module_module_function))
641
- scratch.set_custom_method(klass_module, :public, Builtin.method(:module_public))
642
- scratch.set_custom_method(klass_module, :private, Builtin.method(:module_private))
804
+ scratch.set_custom_method(klass_module, :prepend, Builtin.method(:module_prepend))
805
+ scratch.set_custom_method(klass_module, :module_function, Builtin.method(:module_module_function), false)
806
+ scratch.set_custom_method(klass_module, :public, Builtin.method(:module_public), false)
807
+ scratch.set_custom_method(klass_module, :private, Builtin.method(:module_private), false)
643
808
  scratch.set_custom_method(klass_module, :define_method, Builtin.method(:module_define_method))
809
+ scratch.set_custom_method(klass_module, :"attr_accessor", Builtin.method(:module_attr_accessor))
810
+ scratch.set_custom_method(klass_module, :"attr_reader", Builtin.method(:module_attr_reader))
811
+ scratch.set_custom_method(klass_module, :"attr_writer", Builtin.method(:module_attr_writer))
644
812
 
645
813
  scratch.set_custom_method(klass_proc, :[], Builtin.method(:proc_call))
646
814
  scratch.set_custom_method(klass_proc, :call, Builtin.method(:proc_call))
@@ -655,10 +823,10 @@ module TypeProf
655
823
  scratch.set_custom_method(klass_struct, :initialize, Builtin.method(:struct_initialize))
656
824
  scratch.set_singleton_custom_method(klass_struct, :new, Builtin.method(:struct_s_new))
657
825
 
658
- scratch.set_custom_method(klass_obj, :require, Builtin.method(:kernel_require))
659
- scratch.set_custom_method(klass_obj, :require_relative, Builtin.method(:kernel_require_relative))
660
- scratch.set_custom_method(klass_obj, :Array, Builtin.method(:kernel_Array))
661
- scratch.set_custom_method(klass_obj, :autoload, Builtin.method(:kernel_autoload))
826
+ scratch.set_custom_method(klass_obj, :require, Builtin.method(:kernel_require), false)
827
+ scratch.set_custom_method(klass_obj, :require_relative, Builtin.method(:kernel_require_relative), false)
828
+ scratch.set_custom_method(klass_obj, :Array, Builtin.method(:kernel_Array), false)
829
+ scratch.set_custom_method(klass_obj, :autoload, Builtin.method(:kernel_autoload), false)
662
830
  scratch.set_custom_method(klass_module, :autoload, Builtin.method(:module_autoload))
663
831
 
664
832
  # remove BasicObject#method_missing