rubybreaker 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/NEWS +6 -0
  2. data/VERSION +1 -1
  3. data/bin/rubybreaker +3 -3
  4. data/lib/rubybreaker.rb +15 -11
  5. data/lib/rubybreaker/doc/rdoc.rb +1 -1
  6. data/lib/rubybreaker/runtime/monitor.rb +8 -6
  7. data/lib/rubybreaker/runtime/object_wrapper.rb +38 -16
  8. data/lib/rubybreaker/runtime/overrides.rb +42 -30
  9. data/lib/rubybreaker/runtime/type_system.rb +45 -14
  10. data/lib/rubybreaker/type/type_unparser.rb +4 -8
  11. data/lib/rubybreaker/typing/subtyping.rb +1 -0
  12. data/test/integrated/tc_original_behavior.rb +38 -0
  13. data/test/integrated/tc_simple1.rb +20 -0
  14. data/test/integrated/tc_simple_algorithms.rb +135 -0
  15. data/test/runtime/tc_obj_wrapper.rb +3 -3
  16. data/test/ts_integrated.rb +1 -0
  17. data/test/type/tc_parser.rb +24 -0
  18. data/webpage/rdoc/Object.html +0 -2
  19. data/webpage/rdoc/Rake.html +0 -2
  20. data/webpage/rdoc/Rake/RubyBreakerTestTask.html +0 -2
  21. data/webpage/rdoc/RubyBreaker.html +1 -3
  22. data/webpage/rdoc/RubyBreaker/Breakable.html +0 -2
  23. data/webpage/rdoc/RubyBreaker/Broken.html +0 -2
  24. data/webpage/rdoc/RubyBreaker/Context.html +0 -2
  25. data/webpage/rdoc/RubyBreaker/Errors.html +0 -2
  26. data/webpage/rdoc/RubyBreaker/Errors/ArgumentTypeError.html +0 -2
  27. data/webpage/rdoc/RubyBreaker/Errors/ArityError.html +0 -2
  28. data/webpage/rdoc/RubyBreaker/Errors/InternalError.html +0 -2
  29. data/webpage/rdoc/RubyBreaker/Errors/InvalidSubtypeCheck.html +0 -2
  30. data/webpage/rdoc/RubyBreaker/Errors/InvalidTypeConstruction.html +0 -2
  31. data/webpage/rdoc/RubyBreaker/Errors/ReturnTypeError.html +0 -2
  32. data/webpage/rdoc/RubyBreaker/Errors/TypeError.html +0 -2
  33. data/webpage/rdoc/RubyBreaker/Errors/UserError.html +0 -2
  34. data/webpage/rdoc/RubyBreaker/ObjectPosition.html +0 -2
  35. data/webpage/rdoc/RubyBreaker/Position.html +0 -2
  36. data/webpage/rdoc/RubyBreaker/RubyTypeUtils.html +0 -2
  37. data/webpage/rdoc/RubyBreaker/Runtime.html +7 -3
  38. data/webpage/rdoc/RubyBreaker/Runtime/Inspector.html +0 -2
  39. data/webpage/rdoc/RubyBreaker/Runtime/MethodInfo.html +0 -2
  40. data/webpage/rdoc/RubyBreaker/Runtime/Monitor.html +12 -13
  41. data/webpage/rdoc/RubyBreaker/Runtime/MonitorInstaller.html +6 -7
  42. data/webpage/rdoc/RubyBreaker/Runtime/MonitorSwitch.html +4 -6
  43. data/webpage/rdoc/RubyBreaker/Runtime/ObjectWrapper.html +21 -19
  44. data/webpage/rdoc/RubyBreaker/Runtime/Pluggable.html +0 -2
  45. data/webpage/rdoc/RubyBreaker/Runtime/TypeSigParser.html +0 -2
  46. data/webpage/rdoc/RubyBreaker/Runtime/TypeSigUnparser.html +0 -2
  47. data/webpage/rdoc/RubyBreaker/Runtime/TypeSystem.html +52 -23
  48. data/webpage/rdoc/RubyBreaker/TypeComparer.html +0 -2
  49. data/webpage/rdoc/RubyBreaker/TypeDefs.html +0 -2
  50. data/webpage/rdoc/RubyBreaker/TypeDefs/AnyType.html +0 -2
  51. data/webpage/rdoc/RubyBreaker/TypeDefs/BlockType.html +0 -2
  52. data/webpage/rdoc/RubyBreaker/TypeDefs/DuckType.html +0 -2
  53. data/webpage/rdoc/RubyBreaker/TypeDefs/FusionType.html +0 -2
  54. data/webpage/rdoc/RubyBreaker/TypeDefs/MethodListType.html +0 -2
  55. data/webpage/rdoc/RubyBreaker/TypeDefs/MethodType.html +0 -2
  56. data/webpage/rdoc/RubyBreaker/TypeDefs/NilType.html +0 -2
  57. data/webpage/rdoc/RubyBreaker/TypeDefs/NominalType.html +0 -2
  58. data/webpage/rdoc/RubyBreaker/TypeDefs/OptionalType.html +0 -2
  59. data/webpage/rdoc/RubyBreaker/TypeDefs/OrType.html +0 -2
  60. data/webpage/rdoc/RubyBreaker/TypeDefs/SelfType.html +0 -2
  61. data/webpage/rdoc/RubyBreaker/TypeDefs/Type.html +2 -4
  62. data/webpage/rdoc/RubyBreaker/TypeDefs/VarLengthType.html +0 -2
  63. data/webpage/rdoc/RubyBreaker/TypeUnparser.html +1 -3
  64. data/webpage/rdoc/RubyBreaker/Typing.html +1 -3
  65. data/webpage/rdoc/RubyBreaker/Util.html +0 -2
  66. data/webpage/rdoc/Test.html +0 -2
  67. data/webpage/rdoc/Test/Unit.html +0 -2
  68. data/webpage/rdoc/created.rid +10 -10
  69. data/webpage/rdoc/index.html +0 -2
  70. data/webpage/rdoc/js/search_index.js +1 -1
  71. data/webpage/rdoc/table_of_contents.html +31 -38
  72. metadata +3 -3
  73. data/webpage/rdoc/RubyBreaker/RDocSupport.html +0 -328
@@ -146,8 +146,6 @@
146
146
 
147
147
  <li><a href="../../RubyBreaker/Position.html">RubyBreaker::Position</a>
148
148
 
149
- <li><a href="../../RubyBreaker/RDocSupport.html">RubyBreaker::RDocSupport</a>
150
-
151
149
  <li><a href="../../RubyBreaker/RubyTypeUtils.html">RubyBreaker::RubyTypeUtils</a>
152
150
 
153
151
  <li><a href="../../RubyBreaker/Runtime.html">RubyBreaker::Runtime</a>
@@ -271,22 +269,22 @@ module/class specified for “breaking”. It updates the type information.</p>
271
269
 
272
270
 
273
271
  <div class="method-source-code" id="break_after_method-source">
274
- <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/type_system.rb, line 357</span>
272
+ <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/type_system.rb, line 386</span>
275
273
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">break_after_method</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-identifier">meth_info</span>)
276
274
 
277
275
  <span class="ruby-identifier">is_obj_mod</span> = (<span class="ruby-identifier">obj</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Class</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Module</span>)
278
276
  <span class="ruby-identifier">mod</span> = <span class="ruby-identifier">is_obj_mod</span> <span class="ruby-operator">?</span> <span class="ruby-constant">Runtime</span>.<span class="ruby-identifier">eigen_class</span>(<span class="ruby-identifier">obj</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">class</span>
279
277
 
280
- <span class="ruby-comment"># Take things out</span>
278
+ <span class="ruby-comment"># Take things out of the method info object</span>
281
279
  <span class="ruby-identifier">meth_name</span> = <span class="ruby-identifier">meth_info</span>.<span class="ruby-identifier">meth_name</span>
282
280
  <span class="ruby-identifier">retval</span> = <span class="ruby-identifier">meth_info</span>.<span class="ruby-identifier">ret</span>
283
281
  <span class="ruby-identifier">args</span> = <span class="ruby-identifier">meth_info</span>.<span class="ruby-identifier">args</span>
284
282
  <span class="ruby-identifier">blk</span> = <span class="ruby-identifier">meth_info</span>.<span class="ruby-identifier">blk</span>
285
283
 
286
- <span class="ruby-constant">RubyBreaker</span>.<span class="ruby-identifier">log</span>(<span class="ruby-node">&quot;In module monitor_after #{meth_name}&quot;</span>)
284
+ <span class="ruby-constant">RubyBreaker</span>.<span class="ruby-identifier">log</span>(<span class="ruby-node">&quot;break_after_method #{mod}##{meth_name} started&quot;</span>)
287
285
 
288
286
  <span class="ruby-comment"># Compute the least upper bound</span>
289
- <span class="ruby-identifier">lub</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-constant">TYPE_MAP</span>[<span class="ruby-identifier">mod</span>],<span class="ruby-identifier">meth_name</span>,<span class="ruby-identifier">retval</span>,*<span class="ruby-identifier">args</span>,&amp;<span class="ruby-identifier">blk</span>)
287
+ <span class="ruby-identifier">lub</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-constant">TYPE_MAP</span>[<span class="ruby-identifier">mod</span>], <span class="ruby-identifier">meth_name</span>, <span class="ruby-identifier">retval</span>, *<span class="ruby-identifier">args</span>, &amp;<span class="ruby-identifier">blk</span>)
290
288
 
291
289
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">obj</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">retval</span>
292
290
  <span class="ruby-comment"># It is possible that the method receiver is a wrapped object if</span>
@@ -296,6 +294,8 @@ module/class specified for “breaking”. It updates the type information.</p>
296
294
  <span class="ruby-identifier">meth_info</span>.<span class="ruby-identifier">ret</span> = <span class="ruby-identifier">obj</span>
297
295
  <span class="ruby-keyword">end</span>
298
296
 
297
+ <span class="ruby-constant">RubyBreaker</span>.<span class="ruby-identifier">log</span>(<span class="ruby-node">&quot;break_after_method #{mod}##{meth_name} ended&quot;</span>)
298
+
299
299
  <span class="ruby-keyword">end</span></pre>
300
300
  </div><!-- break_after_method-source -->
301
301
 
@@ -325,7 +325,7 @@ wrapper so it can be tracked of the method calls.</p>
325
325
 
326
326
 
327
327
  <div class="method-source-code" id="break_before_method-source">
328
- <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/type_system.rb, line 294</span>
328
+ <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/type_system.rb, line 314</span>
329
329
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">break_before_method</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-identifier">meth_info</span>)
330
330
 
331
331
  <span class="ruby-comment"># Use the eigen class if the object is a module/class and use the</span>
@@ -333,30 +333,37 @@ wrapper so it can be tracked of the method calls.</p>
333
333
  <span class="ruby-identifier">is_obj_mod</span> = (<span class="ruby-identifier">obj</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Class</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Module</span>)
334
334
  <span class="ruby-identifier">mod</span> = <span class="ruby-identifier">is_obj_mod</span> <span class="ruby-operator">?</span> <span class="ruby-constant">Runtime</span>.<span class="ruby-identifier">eigen_class</span>(<span class="ruby-identifier">obj</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">class</span>
335
335
 
336
- <span class="ruby-identifier">meth_type_map</span> = <span class="ruby-constant">TYPE_MAP</span>[<span class="ruby-identifier">mod</span>]
337
-
338
336
  <span class="ruby-comment"># Let's take things out of the MethodInfo object</span>
339
337
  <span class="ruby-identifier">meth_name</span> = <span class="ruby-identifier">meth_info</span>.<span class="ruby-identifier">meth_name</span>
340
338
  <span class="ruby-identifier">args</span> = <span class="ruby-identifier">meth_info</span>.<span class="ruby-identifier">args</span>
341
339
  <span class="ruby-identifier">blk</span> = <span class="ruby-identifier">meth_info</span>.<span class="ruby-identifier">blk</span>
342
340
  <span class="ruby-identifier">ret</span> = <span class="ruby-identifier">meth_info</span>.<span class="ruby-identifier">ret</span>
343
341
 
342
+ <span class="ruby-constant">RubyBreaker</span>.<span class="ruby-identifier">log</span>(<span class="ruby-node">&quot;break_before_method #{mod}##{meth_name} started&quot;</span>)
343
+
344
344
  <span class="ruby-identifier">args</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">arg</span><span class="ruby-operator">|</span>
345
345
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">arg</span> <span class="ruby-operator">==</span> <span class="ruby-keyword">nil</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">TrueClass</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">FalseClass</span>)
346
346
  <span class="ruby-comment"># XXX: would overrides resolve this issue?</span>
347
347
  <span class="ruby-identifier">arg</span>
348
+ <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-constant">WRAPPED_INDICATOR</span>)
349
+ <span class="ruby-comment"># Don't need to wrap an object that is already wrapped</span>
350
+ <span class="ruby-identifier">arg</span>
348
351
  <span class="ruby-keyword">else</span>
349
352
  <span class="ruby-constant">ObjectWrapper</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">arg</span>)
350
353
  <span class="ruby-keyword">end</span>
351
354
  <span class="ruby-keyword">end</span>
352
355
 
353
- <span class="ruby-constant">RubyBreaker</span>.<span class="ruby-identifier">log</span>(<span class="ruby-node">&quot;In module monitor_before #{meth_name}&quot;</span>)
354
-
356
+ <span class="ruby-comment"># Using this module object, retrieve the method type map which</span>
357
+ <span class="ruby-comment"># maps method names to method types.</span>
358
+ <span class="ruby-identifier">meth_type_map</span> = <span class="ruby-constant">TYPE_MAP</span>[<span class="ruby-identifier">mod</span>]
359
+
360
+ <span class="ruby-comment"># Using the method name, get the type of this method from the map.</span>
355
361
  <span class="ruby-identifier">meth_type</span> = <span class="ruby-identifier">meth_type_map</span>[<span class="ruby-identifier">meth_name</span>]
356
362
 
357
363
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">meth_type</span>
358
364
  <span class="ruby-comment"># This means the method type has been created previously.</span>
359
- <span class="ruby-keyword">unless</span> (<span class="ruby-identifier">blk</span> <span class="ruby-operator">==</span> <span class="ruby-keyword">nil</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">meth_type</span>.<span class="ruby-identifier">blk_type</span> <span class="ruby-operator">==</span> <span class="ruby-keyword">nil</span>) <span class="ruby-operator">&amp;&amp;</span>
365
+ <span class="ruby-keyword">unless</span> <span class="ruby-operator">!</span><span class="ruby-identifier">meth_type</span>.<span class="ruby-identifier">instance_of?</span>(<span class="ruby-constant">MethodType</span>) <span class="ruby-operator">||</span>
366
+ (<span class="ruby-identifier">blk</span> <span class="ruby-operator">==</span> <span class="ruby-keyword">nil</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">meth_type</span>.<span class="ruby-identifier">blk_type</span> <span class="ruby-operator">==</span> <span class="ruby-keyword">nil</span>) <span class="ruby-operator">&amp;&amp;</span>
360
367
  (<span class="ruby-operator">!</span><span class="ruby-identifier">blk</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">blk</span>.<span class="ruby-identifier">arity</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">meth_type</span>.<span class="ruby-identifier">blk_type</span>.<span class="ruby-identifier">arg_types</span>.<span class="ruby-identifier">length</span>)
361
368
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">TypeError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&quot;Block usage is inconsistent&quot;</span>)
362
369
  <span class="ruby-keyword">end</span>
@@ -384,6 +391,8 @@ wrapper so it can be tracked of the method calls.</p>
384
391
 
385
392
  <span class="ruby-identifier">meth_info</span>.<span class="ruby-identifier">args</span> = <span class="ruby-identifier">args</span>
386
393
 
394
+ <span class="ruby-constant">RubyBreaker</span>.<span class="ruby-identifier">log</span>(<span class="ruby-node">&quot;break_before_method #{mod}##{meth_name} ended&quot;</span>)
395
+
387
396
  <span class="ruby-keyword">end</span></pre>
388
397
  </div><!-- break_before_method-source -->
389
398
 
@@ -411,18 +420,21 @@ wrapper so it can be tracked of the method calls.</p>
411
420
 
412
421
 
413
422
  <div class="method-source-code" id="check_after_method-source">
414
- <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/type_system.rb, line 269</span>
423
+ <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/type_system.rb, line 284</span>
415
424
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">check_after_method</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-identifier">meth_info</span>)
416
425
  <span class="ruby-identifier">is_obj_mod</span> = (<span class="ruby-identifier">obj</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Class</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Module</span>)
417
426
  <span class="ruby-identifier">mod</span> = <span class="ruby-identifier">is_obj_mod</span> <span class="ruby-operator">?</span> <span class="ruby-constant">Runtime</span>.<span class="ruby-identifier">eigen_class</span>(<span class="ruby-identifier">obj</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">class</span>
418
427
 
428
+ <span class="ruby-comment"># Get the method type map for the module/class from the global map.</span>
419
429
  <span class="ruby-identifier">meth_type_map</span> = <span class="ruby-constant">TYPE_MAP</span>[<span class="ruby-identifier">mod</span>]
420
- <span class="ruby-keyword">return</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">meth_type_map</span>
430
+ <span class="ruby-keyword">return</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">meth_type_map</span>
421
431
 
422
432
  <span class="ruby-comment"># Let's take things out of the MethodInfo object</span>
423
433
  <span class="ruby-identifier">meth_name</span> = <span class="ruby-identifier">meth_info</span>.<span class="ruby-identifier">meth_name</span>
424
434
  <span class="ruby-identifier">ret</span> = <span class="ruby-identifier">meth_info</span>.<span class="ruby-identifier">ret</span>
425
435
 
436
+ <span class="ruby-constant">RubyBreaker</span>.<span class="ruby-identifier">log</span>(<span class="ruby-node">&quot;check_after_method #{mod}##{meth_name} started&quot;</span>)
437
+
426
438
  <span class="ruby-comment"># Get the registered method type for this method</span>
427
439
  <span class="ruby-identifier">meth_type</span> = <span class="ruby-identifier">meth_type_map</span>[<span class="ruby-identifier">meth_name</span>]
428
440
 
@@ -432,6 +444,8 @@ wrapper so it can be tracked of the method calls.</p>
432
444
  <span class="ruby-node">&quot; return value does not have type #{ret_type.unparse()}.&quot;</span>
433
445
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">ReturnTypeError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">msg</span>)
434
446
  <span class="ruby-keyword">end</span>
447
+
448
+ <span class="ruby-constant">RubyBreaker</span>.<span class="ruby-identifier">log</span>(<span class="ruby-node">&quot;check_after_method #{mod}##{meth_name} started&quot;</span>)
435
449
  <span class="ruby-keyword">end</span></pre>
436
450
  </div><!-- check_after_method-source -->
437
451
 
@@ -459,7 +473,7 @@ wrapper so it can be tracked of the method calls.</p>
459
473
 
460
474
 
461
475
  <div class="method-source-code" id="check_before_method-source">
462
- <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/type_system.rb, line 204</span>
476
+ <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/type_system.rb, line 216</span>
463
477
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">check_before_method</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-identifier">meth_info</span>)
464
478
  <span class="ruby-identifier">is_obj_mod</span> = (<span class="ruby-identifier">obj</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Class</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Module</span>)
465
479
  <span class="ruby-identifier">mod</span> = <span class="ruby-identifier">is_obj_mod</span> <span class="ruby-operator">?</span> <span class="ruby-constant">Runtime</span>.<span class="ruby-identifier">eigen_class</span>(<span class="ruby-identifier">obj</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">class</span>
@@ -472,6 +486,8 @@ wrapper so it can be tracked of the method calls.</p>
472
486
  <span class="ruby-identifier">args</span> = <span class="ruby-identifier">meth_info</span>.<span class="ruby-identifier">args</span>
473
487
  <span class="ruby-comment"># blk = meth_info.blk</span>
474
488
 
489
+ <span class="ruby-constant">RubyBreaker</span>.<span class="ruby-identifier">log</span>(<span class="ruby-node">&quot;check_before_method #{mod}##{meth_name} started&quot;</span>)
490
+
475
491
  <span class="ruby-comment"># Get the registered method type for this method</span>
476
492
  <span class="ruby-identifier">meth_type</span> = <span class="ruby-identifier">meth_type_map</span>[<span class="ruby-identifier">meth_name</span>]
477
493
 
@@ -522,6 +538,7 @@ wrapper so it can be tracked of the method calls.</p>
522
538
  <span class="ruby-keyword">end</span>
523
539
  <span class="ruby-keyword">end</span>
524
540
 
541
+ <span class="ruby-constant">RubyBreaker</span>.<span class="ruby-identifier">log</span>(<span class="ruby-node">&quot;check_before_method #{mod}##{meth_name} ended&quot;</span>)
525
542
  <span class="ruby-keyword">end</span></pre>
526
543
  </div><!-- check_before_method-source -->
527
544
 
@@ -555,7 +572,7 @@ wrapper so it can be tracked of the method calls.</p>
555
572
 
556
573
 
557
574
  <div class="method-source-code" id="arity_check-source">
558
- <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/type_system.rb, line 182</span>
575
+ <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/type_system.rb, line 194</span>
559
576
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">arity_check</span>(<span class="ruby-identifier">num_of_args</span>, <span class="ruby-identifier">meth_type</span>)
560
577
  <span class="ruby-identifier">arg_types</span> = <span class="ruby-identifier">meth_type</span>.<span class="ruby-identifier">arg_types</span>
561
578
 
@@ -673,7 +690,7 @@ method list type.</p>
673
690
 
674
691
 
675
692
  <div class="method-source-code" id="lub-source">
676
- <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/type_system.rb, line 116</span>
693
+ <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/type_system.rb, line 128</span>
677
694
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">lub</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-identifier">meth_type_map</span>, <span class="ruby-identifier">meth_name</span>, <span class="ruby-identifier">retval</span>, *<span class="ruby-identifier">args</span>, &amp;<span class="ruby-identifier">blk</span>)
678
695
 
679
696
  <span class="ruby-identifier">exist_meth_type</span> = <span class="ruby-identifier">meth_type_map</span>[<span class="ruby-identifier">meth_name</span>.<span class="ruby-identifier">to_sym</span>]
@@ -764,21 +781,31 @@ false.</p>
764
781
  <span class="ruby-comment"># most restrictive for the given test cases. </span>
765
782
  <span class="ruby-identifier">arg_types</span> = []
766
783
 
784
+ <span class="ruby-comment"># Resolve the argument types first.</span>
767
785
  <span class="ruby-identifier">exist_meth_type</span>.<span class="ruby-identifier">arg_types</span>.<span class="ruby-identifier">each_with_index</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">exist_arg_type</span>, <span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
768
786
  <span class="ruby-identifier">arg_type</span> = <span class="ruby-keyword">nil</span>
769
787
  <span class="ruby-identifier">new_arg_type</span> = <span class="ruby-identifier">new_meth_type</span>.<span class="ruby-identifier">arg_types</span>[<span class="ruby-identifier">i</span>]
770
788
  <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">exist_arg_type</span>
771
- <span class="ruby-comment"># nil means there hasn't been any type observed</span>
789
+ <span class="ruby-comment"># nil means there hasn't been any type observed so use the new</span>
790
+ <span class="ruby-comment"># argument type as &quot;resolved&quot;.</span>
772
791
  <span class="ruby-identifier">arg_type</span> = <span class="ruby-identifier">new_arg_type</span>
773
792
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">new_arg_type</span>.<span class="ruby-identifier">subtype_of?</span>(<span class="ruby-identifier">exist_arg_type</span>)
793
+ <span class="ruby-comment"># Pick the subtype argument since we are resolving in</span>
794
+ <span class="ruby-comment"># contra-variance</span>
795
+ <span class="ruby-identifier">arg_type</span> = <span class="ruby-identifier">new_arg_type</span>
796
+ <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">exist_arg_type</span>.<span class="ruby-identifier">subtype_of?</span>(<span class="ruby-identifier">new_arg_type</span>)
797
+ <span class="ruby-comment"># Pick the subtype argument since we are resolving in</span>
798
+ <span class="ruby-comment"># contra-variance</span>
774
799
  <span class="ruby-identifier">arg_type</span> = <span class="ruby-identifier">exist_arg_type</span>
775
- <span class="ruby-keyword">elsif</span> <span class="ruby-operator">!</span><span class="ruby-identifier">exist_arg_type</span>.<span class="ruby-identifier">subtype_of?</span>(<span class="ruby-identifier">new_arg_type</span>)
776
- <span class="ruby-comment"># No subtype relation between them, so OR them</span>
800
+ <span class="ruby-keyword">else</span>
801
+ <span class="ruby-comment"># No subtype relation between them, so OR them.</span>
777
802
  <span class="ruby-identifier">arg_type</span> = <span class="ruby-constant">OrType</span>.<span class="ruby-identifier">new</span>([<span class="ruby-identifier">new_arg_type</span>, <span class="ruby-identifier">exist_arg_type</span>])
778
803
  <span class="ruby-keyword">end</span>
779
804
  <span class="ruby-identifier">arg_types</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">arg_type</span>
780
805
  <span class="ruby-keyword">end</span>
781
806
 
807
+ <span class="ruby-comment"># Now, resolve the return type</span>
808
+
782
809
  <span class="ruby-identifier">new_ret_type</span> = <span class="ruby-identifier">new_meth_type</span>.<span class="ruby-identifier">ret_type</span>
783
810
  <span class="ruby-identifier">exist_ret_type</span> = <span class="ruby-identifier">exist_meth_type</span>.<span class="ruby-identifier">ret_type</span>
784
811
 
@@ -786,10 +813,12 @@ false.</p>
786
813
  <span class="ruby-identifier">ret_type</span> = <span class="ruby-identifier">new_ret_type</span>
787
814
  <span class="ruby-identifier">resolved</span> = <span class="ruby-keyword">true</span>
788
815
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">exist_ret_type</span>.<span class="ruby-identifier">subtype_of?</span>(<span class="ruby-identifier">new_ret_type</span>)
789
- <span class="ruby-identifier">ret_type</span> = <span class="ruby-identifier">exist_ret_type</span>
816
+ <span class="ruby-comment"># Co-variance</span>
817
+ <span class="ruby-identifier">ret_type</span> = <span class="ruby-identifier">new_ret_type</span>
790
818
  <span class="ruby-identifier">resolved</span> = <span class="ruby-keyword">true</span>
791
819
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">new_ret_type</span>.<span class="ruby-identifier">subtype_of?</span>(<span class="ruby-identifier">exist_ret_type</span>)
792
- <span class="ruby-identifier">ret_type</span> = <span class="ruby-identifier">new_ret_type</span>
820
+ <span class="ruby-comment"># Co-variance</span>
821
+ <span class="ruby-identifier">ret_type</span> = <span class="ruby-identifier">exist_ret_type</span>
793
822
  <span class="ruby-identifier">resolved</span> = <span class="ruby-keyword">true</span>
794
823
  <span class="ruby-keyword">else</span>
795
824
  <span class="ruby-identifier">resolved</span> = <span class="ruby-keyword">false</span>
@@ -828,7 +857,7 @@ false.</p>
828
857
 
829
858
 
830
859
  <div class="method-source-code" id="type_error_msg_prefix-source">
831
- <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/type_system.rb, line 173</span>
860
+ <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/type_system.rb, line 185</span>
832
861
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">type_error_msg_prefix</span>(<span class="ruby-identifier">mod</span>, <span class="ruby-identifier">meth_name</span>)
833
862
  <span class="ruby-comment"># Match eigen class and returns a prefix that is a class method</span>
834
863
  <span class="ruby-comment"># using dot (.) instead of double colons (::).</span>
@@ -120,8 +120,6 @@
120
120
 
121
121
  <li><a href="../RubyBreaker/Position.html">RubyBreaker::Position</a>
122
122
 
123
- <li><a href="../RubyBreaker/RDocSupport.html">RubyBreaker::RDocSupport</a>
124
-
125
123
  <li><a href="../RubyBreaker/RubyTypeUtils.html">RubyBreaker::RubyTypeUtils</a>
126
124
 
127
125
  <li><a href="../RubyBreaker/Runtime.html">RubyBreaker::Runtime</a>
@@ -98,8 +98,6 @@
98
98
 
99
99
  <li><a href="../RubyBreaker/Position.html">RubyBreaker::Position</a>
100
100
 
101
- <li><a href="../RubyBreaker/RDocSupport.html">RubyBreaker::RDocSupport</a>
102
-
103
101
  <li><a href="../RubyBreaker/RubyTypeUtils.html">RubyBreaker::RubyTypeUtils</a>
104
102
 
105
103
  <li><a href="../RubyBreaker/Runtime.html">RubyBreaker::Runtime</a>
@@ -114,8 +114,6 @@
114
114
 
115
115
  <li><a href="../../RubyBreaker/Position.html">RubyBreaker::Position</a>
116
116
 
117
- <li><a href="../../RubyBreaker/RDocSupport.html">RubyBreaker::RDocSupport</a>
118
-
119
117
  <li><a href="../../RubyBreaker/RubyTypeUtils.html">RubyBreaker::RubyTypeUtils</a>
120
118
 
121
119
  <li><a href="../../RubyBreaker/Runtime.html">RubyBreaker::Runtime</a>
@@ -114,8 +114,6 @@
114
114
 
115
115
  <li><a href="../../RubyBreaker/Position.html">RubyBreaker::Position</a>
116
116
 
117
- <li><a href="../../RubyBreaker/RDocSupport.html">RubyBreaker::RDocSupport</a>
118
-
119
117
  <li><a href="../../RubyBreaker/RubyTypeUtils.html">RubyBreaker::RubyTypeUtils</a>
120
118
 
121
119
  <li><a href="../../RubyBreaker/Runtime.html">RubyBreaker::Runtime</a>
@@ -116,8 +116,6 @@
116
116
 
117
117
  <li><a href="../../RubyBreaker/Position.html">RubyBreaker::Position</a>
118
118
 
119
- <li><a href="../../RubyBreaker/RDocSupport.html">RubyBreaker::RDocSupport</a>
120
-
121
119
  <li><a href="../../RubyBreaker/RubyTypeUtils.html">RubyBreaker::RubyTypeUtils</a>
122
120
 
123
121
  <li><a href="../../RubyBreaker/Runtime.html">RubyBreaker::Runtime</a>
@@ -116,8 +116,6 @@
116
116
 
117
117
  <li><a href="../../RubyBreaker/Position.html">RubyBreaker::Position</a>
118
118
 
119
- <li><a href="../../RubyBreaker/RDocSupport.html">RubyBreaker::RDocSupport</a>
120
-
121
119
  <li><a href="../../RubyBreaker/RubyTypeUtils.html">RubyBreaker::RubyTypeUtils</a>
122
120
 
123
121
  <li><a href="../../RubyBreaker/Runtime.html">RubyBreaker::Runtime</a>
@@ -114,8 +114,6 @@
114
114
 
115
115
  <li><a href="../../RubyBreaker/Position.html">RubyBreaker::Position</a>
116
116
 
117
- <li><a href="../../RubyBreaker/RDocSupport.html">RubyBreaker::RDocSupport</a>
118
-
119
117
  <li><a href="../../RubyBreaker/RubyTypeUtils.html">RubyBreaker::RubyTypeUtils</a>
120
118
 
121
119
  <li><a href="../../RubyBreaker/Runtime.html">RubyBreaker::Runtime</a>
@@ -114,8 +114,6 @@
114
114
 
115
115
  <li><a href="../../RubyBreaker/Position.html">RubyBreaker::Position</a>
116
116
 
117
- <li><a href="../../RubyBreaker/RDocSupport.html">RubyBreaker::RDocSupport</a>
118
-
119
117
  <li><a href="../../RubyBreaker/RubyTypeUtils.html">RubyBreaker::RubyTypeUtils</a>
120
118
 
121
119
  <li><a href="../../RubyBreaker/Runtime.html">RubyBreaker::Runtime</a>
@@ -114,8 +114,6 @@
114
114
 
115
115
  <li><a href="../../RubyBreaker/Position.html">RubyBreaker::Position</a>
116
116
 
117
- <li><a href="../../RubyBreaker/RDocSupport.html">RubyBreaker::RDocSupport</a>
118
-
119
117
  <li><a href="../../RubyBreaker/RubyTypeUtils.html">RubyBreaker::RubyTypeUtils</a>
120
118
 
121
119
  <li><a href="../../RubyBreaker/Runtime.html">RubyBreaker::Runtime</a>
@@ -114,8 +114,6 @@
114
114
 
115
115
  <li><a href="../../RubyBreaker/Position.html">RubyBreaker::Position</a>
116
116
 
117
- <li><a href="../../RubyBreaker/RDocSupport.html">RubyBreaker::RDocSupport</a>
118
-
119
117
  <li><a href="../../RubyBreaker/RubyTypeUtils.html">RubyBreaker::RubyTypeUtils</a>
120
118
 
121
119
  <li><a href="../../RubyBreaker/Runtime.html">RubyBreaker::Runtime</a>
@@ -114,8 +114,6 @@
114
114
 
115
115
  <li><a href="../../RubyBreaker/Position.html">RubyBreaker::Position</a>
116
116
 
117
- <li><a href="../../RubyBreaker/RDocSupport.html">RubyBreaker::RDocSupport</a>
118
-
119
117
  <li><a href="../../RubyBreaker/RubyTypeUtils.html">RubyBreaker::RubyTypeUtils</a>
120
118
 
121
119
  <li><a href="../../RubyBreaker/Runtime.html">RubyBreaker::Runtime</a>
@@ -114,8 +114,6 @@
114
114
 
115
115
  <li><a href="../../RubyBreaker/Position.html">RubyBreaker::Position</a>
116
116
 
117
- <li><a href="../../RubyBreaker/RDocSupport.html">RubyBreaker::RDocSupport</a>
118
-
119
117
  <li><a href="../../RubyBreaker/RubyTypeUtils.html">RubyBreaker::RubyTypeUtils</a>
120
118
 
121
119
  <li><a href="../../RubyBreaker/Runtime.html">RubyBreaker::Runtime</a>
@@ -118,8 +118,6 @@
118
118
 
119
119
  <li><a href="../../RubyBreaker/Position.html">RubyBreaker::Position</a>
120
120
 
121
- <li><a href="../../RubyBreaker/RDocSupport.html">RubyBreaker::RDocSupport</a>
122
-
123
121
  <li><a href="../../RubyBreaker/RubyTypeUtils.html">RubyBreaker::RubyTypeUtils</a>
124
122
 
125
123
  <li><a href="../../RubyBreaker/Runtime.html">RubyBreaker::Runtime</a>
@@ -123,8 +123,6 @@
123
123
 
124
124
  <li><a href="../../RubyBreaker/Position.html">RubyBreaker::Position</a>
125
125
 
126
- <li><a href="../../RubyBreaker/RDocSupport.html">RubyBreaker::RDocSupport</a>
127
-
128
126
  <li><a href="../../RubyBreaker/RubyTypeUtils.html">RubyBreaker::RubyTypeUtils</a>
129
127
 
130
128
  <li><a href="../../RubyBreaker/Runtime.html">RubyBreaker::Runtime</a>
@@ -354,7 +352,7 @@ href="../Typing.html#method-c-subtype_rel-3F">RubyBreaker::Typing.subtype_rel?</
354
352
 
355
353
 
356
354
  <div class="method-source-code" id="subtype_of-3F-source">
357
- <pre><span class="ruby-comment"># File lib/rubybreaker/typing/subtyping.rb, line 479</span>
355
+ <pre><span class="ruby-comment"># File lib/rubybreaker/typing/subtyping.rb, line 480</span>
358
356
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">subtype_of?</span>(<span class="ruby-identifier">rhs</span>)
359
357
  <span class="ruby-keyword">return</span> <span class="ruby-constant">Typing</span>.<span class="ruby-identifier">subtype_rel?</span>(<span class="ruby-keyword">self</span>,<span class="ruby-identifier">rhs</span>)
360
358
  <span class="ruby-keyword">end</span></pre>
@@ -385,7 +383,7 @@ href="../TypeUnparser.html#method-c-unparse">RubyBreaker::TypeUnparser.unparse</
385
383
 
386
384
 
387
385
  <div class="method-source-code" id="unparse-source">
388
- <pre><span class="ruby-comment"># File lib/rubybreaker/type/type_unparser.rb, line 180</span>
386
+ <pre><span class="ruby-comment"># File lib/rubybreaker/type/type_unparser.rb, line 176</span>
389
387
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">unparse</span>(<span class="ruby-identifier">opts</span>={})
390
388
  <span class="ruby-constant">TypeUnparser</span>.<span class="ruby-identifier">unparse</span>(<span class="ruby-keyword">self</span>, <span class="ruby-identifier">opts</span>)
391
389
  <span class="ruby-keyword">end</span></pre>
@@ -114,8 +114,6 @@
114
114
 
115
115
  <li><a href="../../RubyBreaker/Position.html">RubyBreaker::Position</a>
116
116
 
117
- <li><a href="../../RubyBreaker/RDocSupport.html">RubyBreaker::RDocSupport</a>
118
-
119
117
  <li><a href="../../RubyBreaker/RubyTypeUtils.html">RubyBreaker::RubyTypeUtils</a>
120
118
 
121
119
  <li><a href="../../RubyBreaker/Runtime.html">RubyBreaker::Runtime</a>
@@ -120,8 +120,6 @@
120
120
 
121
121
  <li><a href="../RubyBreaker/Position.html">RubyBreaker::Position</a>
122
122
 
123
- <li><a href="../RubyBreaker/RDocSupport.html">RubyBreaker::RDocSupport</a>
124
-
125
123
  <li><a href="../RubyBreaker/RubyTypeUtils.html">RubyBreaker::RubyTypeUtils</a>
126
124
 
127
125
  <li><a href="../RubyBreaker/Runtime.html">RubyBreaker::Runtime</a>
@@ -248,7 +246,7 @@ according to the specified options.</p>
248
246
 
249
247
 
250
248
  <div class="method-source-code" id="unparse-source">
251
- <pre><span class="ruby-comment"># File lib/rubybreaker/type/type_unparser.rb, line 168</span>
249
+ <pre><span class="ruby-comment"># File lib/rubybreaker/type/type_unparser.rb, line 164</span>
252
250
  <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">unparse</span>(<span class="ruby-identifier">t</span>, <span class="ruby-identifier">opts</span>={})
253
251
  <span class="ruby-identifier">str</span> = <span class="ruby-string">&quot;&quot;</span>
254
252
  <span class="ruby-identifier">pp</span> = <span class="ruby-constant">PrettyPrint</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">str</span>)
@@ -120,8 +120,6 @@
120
120
 
121
121
  <li><a href="../RubyBreaker/Position.html">RubyBreaker::Position</a>
122
122
 
123
- <li><a href="../RubyBreaker/RDocSupport.html">RubyBreaker::RDocSupport</a>
124
-
125
123
  <li><a href="../RubyBreaker/RubyTypeUtils.html">RubyBreaker::RubyTypeUtils</a>
126
124
 
127
125
  <li><a href="../RubyBreaker/Runtime.html">RubyBreaker::Runtime</a>
@@ -252,7 +250,7 @@ href="TypeDefs.html">TypeDefs</a></em> module for more detail.</p>
252
250
 
253
251
 
254
252
  <div class="method-source-code" id="subtype_rel-3F-source">
255
- <pre><span class="ruby-comment"># File lib/rubybreaker/typing/subtyping.rb, line 440</span>
253
+ <pre><span class="ruby-comment"># File lib/rubybreaker/typing/subtyping.rb, line 441</span>
256
254
  <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">subtype_rel?</span>(<span class="ruby-identifier">lhs</span>, <span class="ruby-identifier">rhs</span>)
257
255
 
258
256
  <span class="ruby-comment"># Don't even bother if they are same object or syntactically</span>
@@ -114,8 +114,6 @@
114
114
 
115
115
  <li><a href="../RubyBreaker/Position.html">RubyBreaker::Position</a>
116
116
 
117
- <li><a href="../RubyBreaker/RDocSupport.html">RubyBreaker::RDocSupport</a>
118
-
119
117
  <li><a href="../RubyBreaker/RubyTypeUtils.html">RubyBreaker::RubyTypeUtils</a>
120
118
 
121
119
  <li><a href="../RubyBreaker/Runtime.html">RubyBreaker::Runtime</a>
@@ -97,8 +97,6 @@
97
97
 
98
98
  <li><a href="./RubyBreaker/Position.html">RubyBreaker::Position</a>
99
99
 
100
- <li><a href="./RubyBreaker/RDocSupport.html">RubyBreaker::RDocSupport</a>
101
-
102
100
  <li><a href="./RubyBreaker/RubyTypeUtils.html">RubyBreaker::RubyTypeUtils</a>
103
101
 
104
102
  <li><a href="./RubyBreaker/Runtime.html">RubyBreaker::Runtime</a>