rubybreaker 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/README.md +6 -6
  2. data/TUTORIAL.md +64 -34
  3. data/VERSION +1 -1
  4. data/lib/rubybreaker/debug/error.rb +7 -1
  5. data/lib/rubybreaker/runtime/monitor.rb +2 -2
  6. data/lib/rubybreaker/runtime/object_wrapper.rb +32 -1
  7. data/lib/rubybreaker/runtime/overrides.rb +31 -1
  8. data/lib/rubybreaker/runtime/type_system.rb +67 -11
  9. data/test/integrated/tc_checking.rb +35 -5
  10. data/test/integrated/tc_class_methods.rb +4 -1
  11. data/test/integrated/tc_original_behavior.rb +68 -0
  12. data/test/runtime/tc_obj_wrapper.rb +50 -4
  13. data/test/testtask/tc_testtask.rb +1 -1
  14. data/test/ts_integrated.rb +3 -1
  15. data/webpage/images/title.png +0 -0
  16. data/webpage/index.html +6 -6
  17. data/webpage/rdoc/Object.html +5 -1
  18. data/webpage/rdoc/Rake.html +5 -1
  19. data/webpage/rdoc/Rake/RubyBreakerTestTask.html +5 -1
  20. data/webpage/rdoc/RubyBreaker.html +5 -1
  21. data/webpage/rdoc/RubyBreaker/Breakable.html +5 -1
  22. data/webpage/rdoc/RubyBreaker/Broken.html +5 -1
  23. data/webpage/rdoc/RubyBreaker/Context.html +5 -1
  24. data/webpage/rdoc/RubyBreaker/Errors.html +5 -1
  25. data/webpage/rdoc/RubyBreaker/Errors/ArgumentTypeError.html +216 -0
  26. data/webpage/rdoc/RubyBreaker/Errors/{SubtypeFailure.html → ArityError.html} +7 -3
  27. data/webpage/rdoc/RubyBreaker/Errors/InternalError.html +5 -1
  28. data/webpage/rdoc/RubyBreaker/Errors/InvalidSubtypeCheck.html +5 -1
  29. data/webpage/rdoc/RubyBreaker/Errors/InvalidTypeConstruction.html +5 -1
  30. data/webpage/rdoc/RubyBreaker/Errors/ReturnTypeError.html +216 -0
  31. data/webpage/rdoc/RubyBreaker/Errors/TypeError.html +5 -1
  32. data/webpage/rdoc/RubyBreaker/Errors/UserError.html +5 -1
  33. data/webpage/rdoc/RubyBreaker/ObjectPosition.html +5 -1
  34. data/webpage/rdoc/RubyBreaker/Position.html +5 -1
  35. data/webpage/rdoc/RubyBreaker/RDocSupport.html +5 -1
  36. data/webpage/rdoc/RubyBreaker/RubyTypeUtils.html +5 -1
  37. data/webpage/rdoc/RubyBreaker/Runtime.html +10 -1
  38. data/webpage/rdoc/RubyBreaker/Runtime/Inspector.html +5 -1
  39. data/webpage/rdoc/RubyBreaker/Runtime/MethodInfo.html +5 -1
  40. data/webpage/rdoc/RubyBreaker/Runtime/Monitor.html +7 -3
  41. data/webpage/rdoc/RubyBreaker/Runtime/MonitorInstaller.html +5 -1
  42. data/webpage/rdoc/RubyBreaker/Runtime/MonitorSwitch.html +5 -1
  43. data/webpage/rdoc/RubyBreaker/Runtime/ObjectWrapper.html +37 -2
  44. data/webpage/rdoc/RubyBreaker/Runtime/Pluggable.html +5 -1
  45. data/webpage/rdoc/RubyBreaker/Runtime/TypeSigParser.html +5 -1
  46. data/webpage/rdoc/RubyBreaker/Runtime/TypeSigUnparser.html +5 -1
  47. data/webpage/rdoc/RubyBreaker/Runtime/TypeSystem.html +103 -16
  48. data/webpage/rdoc/RubyBreaker/TypeComparer.html +5 -1
  49. data/webpage/rdoc/RubyBreaker/TypeDefs.html +5 -1
  50. data/webpage/rdoc/RubyBreaker/TypeDefs/AnyType.html +5 -1
  51. data/webpage/rdoc/RubyBreaker/TypeDefs/BlockType.html +5 -1
  52. data/webpage/rdoc/RubyBreaker/TypeDefs/DuckType.html +5 -1
  53. data/webpage/rdoc/RubyBreaker/TypeDefs/FusionType.html +5 -1
  54. data/webpage/rdoc/RubyBreaker/TypeDefs/MethodListType.html +5 -1
  55. data/webpage/rdoc/RubyBreaker/TypeDefs/MethodType.html +5 -1
  56. data/webpage/rdoc/RubyBreaker/TypeDefs/NilType.html +5 -1
  57. data/webpage/rdoc/RubyBreaker/TypeDefs/NominalType.html +5 -1
  58. data/webpage/rdoc/RubyBreaker/TypeDefs/OptionalType.html +5 -1
  59. data/webpage/rdoc/RubyBreaker/TypeDefs/OrType.html +5 -1
  60. data/webpage/rdoc/RubyBreaker/TypeDefs/SelfType.html +5 -1
  61. data/webpage/rdoc/RubyBreaker/TypeDefs/Type.html +5 -1
  62. data/webpage/rdoc/RubyBreaker/TypeDefs/VarLengthType.html +5 -1
  63. data/webpage/rdoc/RubyBreaker/TypeUnparser.html +5 -1
  64. data/webpage/rdoc/RubyBreaker/Typing.html +5 -1
  65. data/webpage/rdoc/RubyBreaker/Util.html +5 -1
  66. data/webpage/rdoc/Test.html +5 -1
  67. data/webpage/rdoc/Test/Unit.html +5 -1
  68. data/webpage/rdoc/created.rid +8 -8
  69. data/webpage/rdoc/index.html +5 -1
  70. data/webpage/rdoc/js/search_index.js +1 -1
  71. data/webpage/rdoc/table_of_contents.html +39 -31
  72. data/webpage/tutorial.html +69 -39
  73. metadata +8 -5
@@ -94,13 +94,17 @@
94
94
 
95
95
  <li><a href="../../RubyBreaker/Errors.html">RubyBreaker::Errors</a>
96
96
 
97
+ <li><a href="../../RubyBreaker/Errors/ArgumentTypeError.html">RubyBreaker::Errors::ArgumentTypeError</a>
98
+
99
+ <li><a href="../../RubyBreaker/Errors/ArityError.html">RubyBreaker::Errors::ArityError</a>
100
+
97
101
  <li><a href="../../RubyBreaker/Errors/InternalError.html">RubyBreaker::Errors::InternalError</a>
98
102
 
99
103
  <li><a href="../../RubyBreaker/Errors/InvalidSubtypeCheck.html">RubyBreaker::Errors::InvalidSubtypeCheck</a>
100
104
 
101
105
  <li><a href="../../RubyBreaker/Errors/InvalidTypeConstruction.html">RubyBreaker::Errors::InvalidTypeConstruction</a>
102
106
 
103
- <li><a href="../../RubyBreaker/Errors/SubtypeFailure.html">RubyBreaker::Errors::SubtypeFailure</a>
107
+ <li><a href="../../RubyBreaker/Errors/ReturnTypeError.html">RubyBreaker::Errors::ReturnTypeError</a>
104
108
 
105
109
  <li><a href="../../RubyBreaker/Errors/TypeError.html">RubyBreaker::Errors::TypeError</a>
106
110
 
@@ -94,13 +94,17 @@
94
94
 
95
95
  <li><a href="../../RubyBreaker/Errors.html">RubyBreaker::Errors</a>
96
96
 
97
+ <li><a href="../../RubyBreaker/Errors/ArgumentTypeError.html">RubyBreaker::Errors::ArgumentTypeError</a>
98
+
99
+ <li><a href="../../RubyBreaker/Errors/ArityError.html">RubyBreaker::Errors::ArityError</a>
100
+
97
101
  <li><a href="../../RubyBreaker/Errors/InternalError.html">RubyBreaker::Errors::InternalError</a>
98
102
 
99
103
  <li><a href="../../RubyBreaker/Errors/InvalidSubtypeCheck.html">RubyBreaker::Errors::InvalidSubtypeCheck</a>
100
104
 
101
105
  <li><a href="../../RubyBreaker/Errors/InvalidTypeConstruction.html">RubyBreaker::Errors::InvalidTypeConstruction</a>
102
106
 
103
- <li><a href="../../RubyBreaker/Errors/SubtypeFailure.html">RubyBreaker::Errors::SubtypeFailure</a>
107
+ <li><a href="../../RubyBreaker/Errors/ReturnTypeError.html">RubyBreaker::Errors::ReturnTypeError</a>
104
108
 
105
109
  <li><a href="../../RubyBreaker/Errors/TypeError.html">RubyBreaker::Errors::TypeError</a>
106
110
 
@@ -108,13 +108,17 @@
108
108
 
109
109
  <li><a href="../../RubyBreaker/Errors.html">RubyBreaker::Errors</a>
110
110
 
111
+ <li><a href="../../RubyBreaker/Errors/ArgumentTypeError.html">RubyBreaker::Errors::ArgumentTypeError</a>
112
+
113
+ <li><a href="../../RubyBreaker/Errors/ArityError.html">RubyBreaker::Errors::ArityError</a>
114
+
111
115
  <li><a href="../../RubyBreaker/Errors/InternalError.html">RubyBreaker::Errors::InternalError</a>
112
116
 
113
117
  <li><a href="../../RubyBreaker/Errors/InvalidSubtypeCheck.html">RubyBreaker::Errors::InvalidSubtypeCheck</a>
114
118
 
115
119
  <li><a href="../../RubyBreaker/Errors/InvalidTypeConstruction.html">RubyBreaker::Errors::InvalidTypeConstruction</a>
116
120
 
117
- <li><a href="../../RubyBreaker/Errors/SubtypeFailure.html">RubyBreaker::Errors::SubtypeFailure</a>
121
+ <li><a href="../../RubyBreaker/Errors/ReturnTypeError.html">RubyBreaker::Errors::ReturnTypeError</a>
118
122
 
119
123
  <li><a href="../../RubyBreaker/Errors/TypeError.html">RubyBreaker::Errors::TypeError</a>
120
124
 
@@ -425,7 +429,7 @@ call.</p>
425
429
  <span class="ruby-keyword">when</span> <span class="ruby-value">:check</span>
426
430
  <span class="ruby-identifier">mm</span>.<span class="ruby-identifier">check_before_method</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-identifier">meth_info</span>)
427
431
  <span class="ruby-keyword">end</span>
428
- <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">TypeError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
432
+ <span class="ruby-keyword">rescue</span> <span class="ruby-operator">::</span><span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
429
433
  <span class="ruby-comment"># Trap it, turn on the global monitor and then re-raise the</span>
430
434
  <span class="ruby-comment"># exception</span>
431
435
  <span class="ruby-constant">GLOBAL_MONITOR_SWITCH</span>.<span class="ruby-identifier">turn_on</span>()
@@ -453,7 +457,7 @@ call.</p>
453
457
  <span class="ruby-keyword">when</span> <span class="ruby-value">:check</span>
454
458
  <span class="ruby-identifier">mm</span>.<span class="ruby-identifier">check_after_method</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-identifier">meth_info</span>)
455
459
  <span class="ruby-keyword">end</span>
456
- <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">TypeError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
460
+ <span class="ruby-keyword">rescue</span> <span class="ruby-operator">::</span><span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
457
461
  <span class="ruby-comment"># Trap it, turn on the global monitor and then re-raise the</span>
458
462
  <span class="ruby-comment"># exception</span>
459
463
  <span class="ruby-constant">GLOBAL_MONITOR_SWITCH</span>.<span class="ruby-identifier">turn_on</span>()
@@ -92,13 +92,17 @@
92
92
 
93
93
  <li><a href="../../RubyBreaker/Errors.html">RubyBreaker::Errors</a>
94
94
 
95
+ <li><a href="../../RubyBreaker/Errors/ArgumentTypeError.html">RubyBreaker::Errors::ArgumentTypeError</a>
96
+
97
+ <li><a href="../../RubyBreaker/Errors/ArityError.html">RubyBreaker::Errors::ArityError</a>
98
+
95
99
  <li><a href="../../RubyBreaker/Errors/InternalError.html">RubyBreaker::Errors::InternalError</a>
96
100
 
97
101
  <li><a href="../../RubyBreaker/Errors/InvalidSubtypeCheck.html">RubyBreaker::Errors::InvalidSubtypeCheck</a>
98
102
 
99
103
  <li><a href="../../RubyBreaker/Errors/InvalidTypeConstruction.html">RubyBreaker::Errors::InvalidTypeConstruction</a>
100
104
 
101
- <li><a href="../../RubyBreaker/Errors/SubtypeFailure.html">RubyBreaker::Errors::SubtypeFailure</a>
105
+ <li><a href="../../RubyBreaker/Errors/ReturnTypeError.html">RubyBreaker::Errors::ReturnTypeError</a>
102
106
 
103
107
  <li><a href="../../RubyBreaker/Errors/TypeError.html">RubyBreaker::Errors::TypeError</a>
104
108
 
@@ -100,13 +100,17 @@
100
100
 
101
101
  <li><a href="../../RubyBreaker/Errors.html">RubyBreaker::Errors</a>
102
102
 
103
+ <li><a href="../../RubyBreaker/Errors/ArgumentTypeError.html">RubyBreaker::Errors::ArgumentTypeError</a>
104
+
105
+ <li><a href="../../RubyBreaker/Errors/ArityError.html">RubyBreaker::Errors::ArityError</a>
106
+
103
107
  <li><a href="../../RubyBreaker/Errors/InternalError.html">RubyBreaker::Errors::InternalError</a>
104
108
 
105
109
  <li><a href="../../RubyBreaker/Errors/InvalidSubtypeCheck.html">RubyBreaker::Errors::InvalidSubtypeCheck</a>
106
110
 
107
111
  <li><a href="../../RubyBreaker/Errors/InvalidTypeConstruction.html">RubyBreaker::Errors::InvalidTypeConstruction</a>
108
112
 
109
- <li><a href="../../RubyBreaker/Errors/SubtypeFailure.html">RubyBreaker::Errors::SubtypeFailure</a>
113
+ <li><a href="../../RubyBreaker/Errors/ReturnTypeError.html">RubyBreaker::Errors::ReturnTypeError</a>
110
114
 
111
115
  <li><a href="../../RubyBreaker/Errors/TypeError.html">RubyBreaker::Errors::TypeError</a>
112
116
 
@@ -102,13 +102,17 @@
102
102
 
103
103
  <li><a href="../../RubyBreaker/Errors.html">RubyBreaker::Errors</a>
104
104
 
105
+ <li><a href="../../RubyBreaker/Errors/ArgumentTypeError.html">RubyBreaker::Errors::ArgumentTypeError</a>
106
+
107
+ <li><a href="../../RubyBreaker/Errors/ArityError.html">RubyBreaker::Errors::ArityError</a>
108
+
105
109
  <li><a href="../../RubyBreaker/Errors/InternalError.html">RubyBreaker::Errors::InternalError</a>
106
110
 
107
111
  <li><a href="../../RubyBreaker/Errors/InvalidSubtypeCheck.html">RubyBreaker::Errors::InvalidSubtypeCheck</a>
108
112
 
109
113
  <li><a href="../../RubyBreaker/Errors/InvalidTypeConstruction.html">RubyBreaker::Errors::InvalidTypeConstruction</a>
110
114
 
111
- <li><a href="../../RubyBreaker/Errors/SubtypeFailure.html">RubyBreaker::Errors::SubtypeFailure</a>
115
+ <li><a href="../../RubyBreaker/Errors/ReturnTypeError.html">RubyBreaker::Errors::ReturnTypeError</a>
112
116
 
113
117
  <li><a href="../../RubyBreaker/Errors/TypeError.html">RubyBreaker::Errors::TypeError</a>
114
118
 
@@ -346,14 +350,45 @@ instance_exec</p>
346
350
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">method_missing</span>(<span class="ruby-identifier">mname</span>,*<span class="ruby-identifier">args</span>,&amp;<span class="ruby-identifier">blk</span>)
347
351
  <span class="ruby-operator">::</span><span class="ruby-constant">RubyBreaker</span>.<span class="ruby-identifier">log</span>(<span class="ruby-node">&quot;Method_missing for #{mname}&quot;</span>)
348
352
  <span class="ruby-keyword">if</span> <span class="ruby-constant">GLOBAL_MONITOR_SWITCH</span>.<span class="ruby-identifier">switch</span>
353
+
354
+ <span class="ruby-comment"># Be safe and turn the switch off</span>
355
+ <span class="ruby-constant">GLOBAL_MONITOR_SWITCH</span>.<span class="ruby-identifier">turn_off</span>
356
+
349
357
  <span class="ruby-comment"># Must handle send method specially (do not track them)</span>
350
358
  <span class="ruby-keyword">if</span> [<span class="ruby-value">:&quot;__send__&quot;</span>, <span class="ruby-value">:send</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">mname</span>)
351
359
  <span class="ruby-identifier">mname</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>]
352
360
  <span class="ruby-identifier">args</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>]
353
361
  <span class="ruby-keyword">end</span>
354
362
  <span class="ruby-ivar">@__rubybreaker_type</span>.<span class="ruby-identifier">add_meth</span>(<span class="ruby-identifier">mname</span>)
363
+
364
+ <span class="ruby-comment"># If self is not subject to breaking, then no need to send the</span>
365
+ <span class="ruby-comment"># wrapped arguments. This part is super IMPORTANT. Otherwise many</span>
366
+ <span class="ruby-comment"># native code stuff won't work including Numeric#+.</span>
367
+ <span class="ruby-identifier">obj</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">__rubybreaker_obj</span>
368
+ <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-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-operator">::</span><span class="ruby-constant">Module</span>)
369
+ <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>
370
+
371
+ <span class="ruby-comment"># Monitor map doesn't exist MEANS it's not being monitored.</span>
372
+ <span class="ruby-keyword">unless</span> <span class="ruby-constant">MONITOR_MAP</span>[<span class="ruby-identifier">mod</span>]
373
+ <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>
374
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-constant">WRAPPED_INDICATOR</span>)
375
+ <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">__rubybreaker_obj</span>
376
+ <span class="ruby-keyword">else</span>
377
+ <span class="ruby-identifier">arg</span>
378
+ <span class="ruby-keyword">end</span>
379
+ <span class="ruby-keyword">end</span>
380
+ <span class="ruby-keyword">end</span>
381
+
382
+ <span class="ruby-comment"># Turn on the global switch again</span>
383
+ <span class="ruby-constant">GLOBAL_MONITOR_SWITCH</span>.<span class="ruby-identifier">turn_on</span>
384
+
385
+ <span class="ruby-comment"># And call the original method </span>
355
386
  <span class="ruby-identifier">retval</span> = <span class="ruby-ivar">@__rubybreaker_obj</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">mname</span>, *<span class="ruby-identifier">args</span>, &amp;<span class="ruby-identifier">blk</span>)
356
- <span class="ruby-identifier">retval</span> = <span class="ruby-constant">ObjectWrapper</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">retval</span>)
387
+
388
+ <span class="ruby-comment"># No need to wrap the object again...if it's wrapped already</span>
389
+ <span class="ruby-keyword">unless</span> <span class="ruby-identifier">retval</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-constant">WRAPPED_INDICATOR</span>)
390
+ <span class="ruby-identifier">retval</span> = <span class="ruby-constant">ObjectWrapper</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">retval</span>)
391
+ <span class="ruby-keyword">end</span>
357
392
  <span class="ruby-keyword">else</span>
358
393
  <span class="ruby-identifier">retval</span> = <span class="ruby-ivar">@__rubybreaker_obj</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">mname</span>, *<span class="ruby-identifier">args</span>, &amp;<span class="ruby-identifier">blk</span>)
359
394
  <span class="ruby-keyword">end</span>
@@ -94,13 +94,17 @@
94
94
 
95
95
  <li><a href="../../RubyBreaker/Errors.html">RubyBreaker::Errors</a>
96
96
 
97
+ <li><a href="../../RubyBreaker/Errors/ArgumentTypeError.html">RubyBreaker::Errors::ArgumentTypeError</a>
98
+
99
+ <li><a href="../../RubyBreaker/Errors/ArityError.html">RubyBreaker::Errors::ArityError</a>
100
+
97
101
  <li><a href="../../RubyBreaker/Errors/InternalError.html">RubyBreaker::Errors::InternalError</a>
98
102
 
99
103
  <li><a href="../../RubyBreaker/Errors/InvalidSubtypeCheck.html">RubyBreaker::Errors::InvalidSubtypeCheck</a>
100
104
 
101
105
  <li><a href="../../RubyBreaker/Errors/InvalidTypeConstruction.html">RubyBreaker::Errors::InvalidTypeConstruction</a>
102
106
 
103
- <li><a href="../../RubyBreaker/Errors/SubtypeFailure.html">RubyBreaker::Errors::SubtypeFailure</a>
107
+ <li><a href="../../RubyBreaker/Errors/ReturnTypeError.html">RubyBreaker::Errors::ReturnTypeError</a>
104
108
 
105
109
  <li><a href="../../RubyBreaker/Errors/TypeError.html">RubyBreaker::Errors::TypeError</a>
106
110
 
@@ -88,13 +88,17 @@
88
88
 
89
89
  <li><a href="../../RubyBreaker/Errors.html">RubyBreaker::Errors</a>
90
90
 
91
+ <li><a href="../../RubyBreaker/Errors/ArgumentTypeError.html">RubyBreaker::Errors::ArgumentTypeError</a>
92
+
93
+ <li><a href="../../RubyBreaker/Errors/ArityError.html">RubyBreaker::Errors::ArityError</a>
94
+
91
95
  <li><a href="../../RubyBreaker/Errors/InternalError.html">RubyBreaker::Errors::InternalError</a>
92
96
 
93
97
  <li><a href="../../RubyBreaker/Errors/InvalidSubtypeCheck.html">RubyBreaker::Errors::InvalidSubtypeCheck</a>
94
98
 
95
99
  <li><a href="../../RubyBreaker/Errors/InvalidTypeConstruction.html">RubyBreaker::Errors::InvalidTypeConstruction</a>
96
100
 
97
- <li><a href="../../RubyBreaker/Errors/SubtypeFailure.html">RubyBreaker::Errors::SubtypeFailure</a>
101
+ <li><a href="../../RubyBreaker/Errors/ReturnTypeError.html">RubyBreaker::Errors::ReturnTypeError</a>
98
102
 
99
103
  <li><a href="../../RubyBreaker/Errors/TypeError.html">RubyBreaker::Errors::TypeError</a>
100
104
 
@@ -104,13 +104,17 @@
104
104
 
105
105
  <li><a href="../../RubyBreaker/Errors.html">RubyBreaker::Errors</a>
106
106
 
107
+ <li><a href="../../RubyBreaker/Errors/ArgumentTypeError.html">RubyBreaker::Errors::ArgumentTypeError</a>
108
+
109
+ <li><a href="../../RubyBreaker/Errors/ArityError.html">RubyBreaker::Errors::ArityError</a>
110
+
107
111
  <li><a href="../../RubyBreaker/Errors/InternalError.html">RubyBreaker::Errors::InternalError</a>
108
112
 
109
113
  <li><a href="../../RubyBreaker/Errors/InvalidSubtypeCheck.html">RubyBreaker::Errors::InvalidSubtypeCheck</a>
110
114
 
111
115
  <li><a href="../../RubyBreaker/Errors/InvalidTypeConstruction.html">RubyBreaker::Errors::InvalidTypeConstruction</a>
112
116
 
113
- <li><a href="../../RubyBreaker/Errors/SubtypeFailure.html">RubyBreaker::Errors::SubtypeFailure</a>
117
+ <li><a href="../../RubyBreaker/Errors/ReturnTypeError.html">RubyBreaker::Errors::ReturnTypeError</a>
114
118
 
115
119
  <li><a href="../../RubyBreaker/Errors/TypeError.html">RubyBreaker::Errors::TypeError</a>
116
120
 
@@ -86,6 +86,8 @@
86
86
 
87
87
  <ul class="link-list">
88
88
 
89
+ <li><a href="#method-i-arity_check">#arity_check</a>
90
+
89
91
  <li><a href="#method-i-break_after_method">#break_after_method</a>
90
92
 
91
93
  <li><a href="#method-i-break_before_method">#break_before_method</a>
@@ -124,13 +126,17 @@
124
126
 
125
127
  <li><a href="../../RubyBreaker/Errors.html">RubyBreaker::Errors</a>
126
128
 
129
+ <li><a href="../../RubyBreaker/Errors/ArgumentTypeError.html">RubyBreaker::Errors::ArgumentTypeError</a>
130
+
131
+ <li><a href="../../RubyBreaker/Errors/ArityError.html">RubyBreaker::Errors::ArityError</a>
132
+
127
133
  <li><a href="../../RubyBreaker/Errors/InternalError.html">RubyBreaker::Errors::InternalError</a>
128
134
 
129
135
  <li><a href="../../RubyBreaker/Errors/InvalidSubtypeCheck.html">RubyBreaker::Errors::InvalidSubtypeCheck</a>
130
136
 
131
137
  <li><a href="../../RubyBreaker/Errors/InvalidTypeConstruction.html">RubyBreaker::Errors::InvalidTypeConstruction</a>
132
138
 
133
- <li><a href="../../RubyBreaker/Errors/SubtypeFailure.html">RubyBreaker::Errors::SubtypeFailure</a>
139
+ <li><a href="../../RubyBreaker/Errors/ReturnTypeError.html">RubyBreaker::Errors::ReturnTypeError</a>
134
140
 
135
141
  <li><a href="../../RubyBreaker/Errors/TypeError.html">RubyBreaker::Errors::TypeError</a>
136
142
 
@@ -265,7 +271,7 @@ module/class specified for “breaking”. It updates the type information.</p>
265
271
 
266
272
 
267
273
  <div class="method-source-code" id="break_after_method-source">
268
- <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/type_system.rb, line 301</span>
274
+ <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/type_system.rb, line 357</span>
269
275
  <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>)
270
276
 
271
277
  <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>)
@@ -319,7 +325,7 @@ wrapper so it can be tracked of the method calls.</p>
319
325
 
320
326
 
321
327
  <div class="method-source-code" id="break_before_method-source">
322
- <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/type_system.rb, line 238</span>
328
+ <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/type_system.rb, line 294</span>
323
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>)
324
330
 
325
331
  <span class="ruby-comment"># Use the eigen class if the object is a module/class and use the</span>
@@ -336,7 +342,7 @@ wrapper so it can be tracked of the method calls.</p>
336
342
  <span class="ruby-identifier">ret</span> = <span class="ruby-identifier">meth_info</span>.<span class="ruby-identifier">ret</span>
337
343
 
338
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>
339
- <span class="ruby-keyword">if</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>)
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>)
340
346
  <span class="ruby-comment"># XXX: would overrides resolve this issue?</span>
341
347
  <span class="ruby-identifier">arg</span>
342
348
  <span class="ruby-keyword">else</span>
@@ -405,7 +411,7 @@ wrapper so it can be tracked of the method calls.</p>
405
411
 
406
412
 
407
413
  <div class="method-source-code" id="check_after_method-source">
408
- <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/type_system.rb, line 211</span>
414
+ <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/type_system.rb, line 269</span>
409
415
  <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>)
410
416
  <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>)
411
417
  <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>
@@ -415,8 +421,6 @@ wrapper so it can be tracked of the method calls.</p>
415
421
 
416
422
  <span class="ruby-comment"># Let's take things out of the MethodInfo object</span>
417
423
  <span class="ruby-identifier">meth_name</span> = <span class="ruby-identifier">meth_info</span>.<span class="ruby-identifier">meth_name</span>
418
- <span class="ruby-identifier">args</span> = <span class="ruby-identifier">meth_info</span>.<span class="ruby-identifier">args</span>
419
- <span class="ruby-identifier">blk</span> = <span class="ruby-identifier">meth_info</span>.<span class="ruby-identifier">blk</span>
420
424
  <span class="ruby-identifier">ret</span> = <span class="ruby-identifier">meth_info</span>.<span class="ruby-identifier">ret</span>
421
425
 
422
426
  <span class="ruby-comment"># Get the registered method type for this method</span>
@@ -426,7 +430,7 @@ wrapper so it can be tracked of the method calls.</p>
426
430
  <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">meth_type</span>.<span class="ruby-identifier">ret_type</span>.<span class="ruby-identifier">subtype_of?</span>(<span class="ruby-identifier">ret_type</span>)
427
431
  <span class="ruby-identifier">msg</span> = <span class="ruby-identifier">type_error_msg_prefix</span>(<span class="ruby-identifier">mod</span>, <span class="ruby-identifier">meth_name</span>) <span class="ruby-operator">+</span>
428
432
  <span class="ruby-node">&quot; return value does not have type #{ret_type.unparse()}.&quot;</span>
429
- <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-identifier">msg</span>)
433
+ <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>)
430
434
  <span class="ruby-keyword">end</span>
431
435
  <span class="ruby-keyword">end</span></pre>
432
436
  </div><!-- check_after_method-source -->
@@ -455,7 +459,7 @@ wrapper so it can be tracked of the method calls.</p>
455
459
 
456
460
 
457
461
  <div class="method-source-code" id="check_before_method-source">
458
- <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/type_system.rb, line 182</span>
462
+ <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/type_system.rb, line 204</span>
459
463
  <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>)
460
464
  <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>)
461
465
  <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>
@@ -466,19 +470,55 @@ wrapper so it can be tracked of the method calls.</p>
466
470
  <span class="ruby-comment"># Let's take things out of the MethodInfo object</span>
467
471
  <span class="ruby-identifier">meth_name</span> = <span class="ruby-identifier">meth_info</span>.<span class="ruby-identifier">meth_name</span>
468
472
  <span class="ruby-identifier">args</span> = <span class="ruby-identifier">meth_info</span>.<span class="ruby-identifier">args</span>
469
- <span class="ruby-identifier">blk</span> = <span class="ruby-identifier">meth_info</span>.<span class="ruby-identifier">blk</span>
470
- <span class="ruby-identifier">ret</span> = <span class="ruby-identifier">meth_info</span>.<span class="ruby-identifier">ret</span>
473
+ <span class="ruby-comment"># blk = meth_info.blk</span>
471
474
 
472
475
  <span class="ruby-comment"># Get the registered method type for this method</span>
473
476
  <span class="ruby-identifier">meth_type</span> = <span class="ruby-identifier">meth_type_map</span>[<span class="ruby-identifier">meth_name</span>]
474
477
 
475
- <span class="ruby-identifier">args</span>.<span class="ruby-identifier">each_with_index</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">arg</span>, <span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
476
- <span class="ruby-identifier">arg_type</span> = <span class="ruby-constant">NominalType</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">arg</span>.<span class="ruby-identifier">class</span>)
477
- <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">arg_type</span>.<span class="ruby-identifier">subtype_of?</span>(<span class="ruby-identifier">meth_type</span>.<span class="ruby-identifier">arg_types</span>[<span class="ruby-identifier">i</span>])
478
+ <span class="ruby-comment"># Do an arity check first. </span>
479
+ <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">arity_check</span>(<span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span>, <span class="ruby-identifier">meth_type</span>)
480
+ <span class="ruby-identifier">msg</span> = <span class="ruby-identifier">type_error_msg_prefix</span>(<span class="ruby-identifier">mod</span>, <span class="ruby-identifier">meth_name</span>) <span class="ruby-operator">+</span>
481
+ <span class="ruby-node">&quot; has an arity of #{meth_type.arg_types.size} &quot;</span> <span class="ruby-operator">+</span>
482
+ <span class="ruby-node">&quot;but #{args.size} arguments were passed in&quot;</span>
483
+ <span class="ruby-identifier">raise</span> <span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">ArityError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">msg</span>)
484
+ <span class="ruby-keyword">end</span>
485
+
486
+ <span class="ruby-comment"># Remember what the last formal argument type was so that, if it is</span>
487
+ <span class="ruby-comment"># a variable length argument type, we use to check the remaining</span>
488
+ <span class="ruby-comment"># arguments.</span>
489
+ <span class="ruby-identifier">last_supertype</span> = <span class="ruby-keyword">nil</span>
490
+
491
+ <span class="ruby-comment"># Check actual arguments up until the last position of the formal</span>
492
+ <span class="ruby-comment"># argument type. If the number of the formal arguments is less than</span>
493
+ <span class="ruby-comment"># actual arguments, it means the last formal argument is a variable</span>
494
+ <span class="ruby-comment"># length. If it's the other way around, there are optional</span>
495
+ <span class="ruby-comment"># arguments.</span>
496
+ <span class="ruby-identifier">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">supertype</span>, <span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
497
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">supertype</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">OptionalType</span>) <span class="ruby-operator">||</span>
498
+ <span class="ruby-identifier">supertype</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">VarLengthType</span>)
499
+ <span class="ruby-identifier">supertype</span> = <span class="ruby-identifier">supertype</span>.<span class="ruby-identifier">type</span>
500
+ <span class="ruby-keyword">end</span>
501
+ <span class="ruby-identifier">last_supertype</span> = <span class="ruby-identifier">supertype</span>
502
+ <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">i</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span>
503
+ <span class="ruby-identifier">subtype</span> = <span class="ruby-constant">NominalType</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">args</span>[<span class="ruby-identifier">i</span>].<span class="ruby-identifier">class</span>)
504
+ <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">subtype</span>.<span class="ruby-identifier">subtype_of?</span>(<span class="ruby-identifier">supertype</span>)
478
505
  <span class="ruby-identifier">msg</span> = <span class="ruby-identifier">type_error_msg_prefix</span>(<span class="ruby-identifier">mod</span>, <span class="ruby-identifier">meth_name</span>) <span class="ruby-operator">+</span>
479
506
  <span class="ruby-node">&quot;'s #{Util.ordinalize(i+1)} argument &quot;</span> <span class="ruby-operator">+</span>
480
- <span class="ruby-node">&quot;does not have type #{arg_type.unparse()}.&quot;</span>
481
- <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-identifier">msg</span>)
507
+ <span class="ruby-node">&quot;does not have type #{supertype.unparse()}.&quot;</span>
508
+ <span class="ruby-identifier">raise</span> <span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">ArgumentTypeError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">msg</span>)
509
+ <span class="ruby-keyword">end</span>
510
+ <span class="ruby-keyword">end</span>
511
+
512
+ <span class="ruby-comment"># Handle the remaining actual arguments</span>
513
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">meth_type</span>.<span class="ruby-identifier">arg_types</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span>
514
+ <span class="ruby-keyword">for</span> <span class="ruby-identifier">i</span> <span class="ruby-keyword">in</span> <span class="ruby-identifier">meth_type</span>.<span class="ruby-identifier">arg_types</span>.<span class="ruby-identifier">size</span><span class="ruby-operator">..</span><span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>
515
+ <span class="ruby-identifier">subtype</span> = <span class="ruby-constant">NominalType</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">args</span>[<span class="ruby-identifier">i</span>].<span class="ruby-identifier">class</span>)
516
+ <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">subtype</span>.<span class="ruby-identifier">subtype_of?</span>(<span class="ruby-identifier">last_supertype</span>)
517
+ <span class="ruby-identifier">msg</span> = <span class="ruby-identifier">type_error_msg_prefix</span>(<span class="ruby-identifier">mod</span>, <span class="ruby-identifier">meth_name</span>) <span class="ruby-operator">+</span>
518
+ <span class="ruby-node">&quot;'s #{Util.ordinalize(i+1)} argument &quot;</span> <span class="ruby-operator">+</span>
519
+ <span class="ruby-node">&quot;does not have type #{last_supertype.unparse()}.&quot;</span>
520
+ <span class="ruby-identifier">raise</span> <span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">ArgumentTypeError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">msg</span>)
521
+ <span class="ruby-keyword">end</span>
482
522
  <span class="ruby-keyword">end</span>
483
523
  <span class="ruby-keyword">end</span>
484
524
 
@@ -499,6 +539,51 @@ wrapper so it can be tracked of the method calls.</p>
499
539
  <h3 class="section-header">Protected Instance Methods</h3>
500
540
 
501
541
 
542
+ <div id="method-i-arity_check" class="method-detail ">
543
+
544
+ <div class="method-heading">
545
+ <span class="method-name">arity_check</span><span
546
+ class="method-args">(num_of_args, meth_type)</span>
547
+ <span class="method-click-advice">click to toggle source</span>
548
+ </div>
549
+
550
+
551
+ <div class="method-description">
552
+
553
+ <p>This method performs the arity check.</p>
554
+
555
+
556
+
557
+ <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>
559
+ <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
+ <span class="ruby-identifier">arg_types</span> = <span class="ruby-identifier">meth_type</span>.<span class="ruby-identifier">arg_types</span>
561
+
562
+ <span class="ruby-identifier">opt</span> = <span class="ruby-keyword">false</span>
563
+ <span class="ruby-identifier">varlen</span> = <span class="ruby-keyword">false</span>
564
+
565
+ <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">arg_type</span>, <span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
566
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">arg_type</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">OptionalType</span>)
567
+ <span class="ruby-identifier">opt</span> = <span class="ruby-keyword">true</span>
568
+ <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">arg_type</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">VarLengthType</span>)
569
+ <span class="ruby-identifier">varlen</span> = <span class="ruby-keyword">true</span>
570
+ <span class="ruby-keyword">end</span>
571
+ <span class="ruby-keyword">end</span>
572
+ <span class="ruby-identifier">check</span> = (<span class="ruby-identifier">opt</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">num_of_args</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-identifier">arg_types</span>.<span class="ruby-identifier">size</span>) <span class="ruby-operator">||</span>
573
+ (<span class="ruby-identifier">varlen</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">num_of_args</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-identifier">arg_types</span>.<span class="ruby-identifier">size</span>) <span class="ruby-operator">||</span>
574
+ <span class="ruby-identifier">num_of_args</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">arg_types</span>.<span class="ruby-identifier">size</span>
575
+ <span class="ruby-keyword">return</span> <span class="ruby-identifier">check</span>
576
+ <span class="ruby-keyword">end</span></pre>
577
+ </div><!-- arity_check-source -->
578
+
579
+ </div>
580
+
581
+
582
+
583
+
584
+ </div><!-- arity_check-method -->
585
+
586
+
502
587
  <div id="method-i-is_object_wrapped-3F" class="method-detail ">
503
588
 
504
589
  <div class="method-heading">
@@ -745,6 +830,8 @@ false.</p>
745
830
  <div class="method-source-code" id="type_error_msg_prefix-source">
746
831
  <pre><span class="ruby-comment"># File lib/rubybreaker/runtime/type_system.rb, line 173</span>
747
832
  <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
+ <span class="ruby-comment"># Match eigen class and returns a prefix that is a class method</span>
834
+ <span class="ruby-comment"># using dot (.) instead of double colons (::).</span>
748
835
  <span class="ruby-identifier">result</span> = <span class="ruby-node">%r#&lt;Class:(.+)&gt;/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-node">&quot;#{mod}&quot;</span>)
749
836
  <span class="ruby-identifier">prefix</span> = <span class="ruby-identifier">result</span> <span class="ruby-operator">?</span> <span class="ruby-node">&quot;#{result[1]}.&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-node">&quot;#{mod}#&quot;</span>
750
837
  <span class="ruby-keyword">return</span> <span class="ruby-node">&quot;#{prefix}#{meth_name}&quot;</span>