sorbet-runtime 0.5.6295 → 0.5.6483

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1203 @@
1
+ # frozen_string_literal: true
2
+ # typed: false
3
+
4
+ # DO NOT EDIT. This file is autogenerated. To regenerate, run:
5
+ #
6
+ # bazel test //gems/sorbet-runtime:update_call_validation
7
+
8
+ module T::Private::Methods::CallValidation
9
+ def self.create_validator_method_fast(mod, original_method, method_sig)
10
+ if method_sig.return_type.is_a?(T::Private::Types::Void)
11
+ raise 'Should have used create_validator_procedure_fast'
12
+ end
13
+ # trampoline to reduce stack frame size
14
+ if method_sig.arg_types.empty?
15
+ create_validator_method_fast0(mod, original_method, method_sig, method_sig.return_type.raw_type)
16
+ elsif method_sig.arg_types.length == 1
17
+ create_validator_method_fast1(mod, original_method, method_sig, method_sig.return_type.raw_type,
18
+ method_sig.arg_types[0][1].raw_type)
19
+ elsif method_sig.arg_types.length == 2
20
+ create_validator_method_fast2(mod, original_method, method_sig, method_sig.return_type.raw_type,
21
+ method_sig.arg_types[0][1].raw_type,
22
+ method_sig.arg_types[1][1].raw_type)
23
+ elsif method_sig.arg_types.length == 3
24
+ create_validator_method_fast3(mod, original_method, method_sig, method_sig.return_type.raw_type,
25
+ method_sig.arg_types[0][1].raw_type,
26
+ method_sig.arg_types[1][1].raw_type,
27
+ method_sig.arg_types[2][1].raw_type)
28
+ elsif method_sig.arg_types.length == 4
29
+ create_validator_method_fast4(mod, original_method, method_sig, method_sig.return_type.raw_type,
30
+ method_sig.arg_types[0][1].raw_type,
31
+ method_sig.arg_types[1][1].raw_type,
32
+ method_sig.arg_types[2][1].raw_type,
33
+ method_sig.arg_types[3][1].raw_type)
34
+ else
35
+ raise 'should not happen'
36
+ end
37
+ end
38
+
39
+ def self.create_validator_method_fast0(mod, original_method, method_sig, return_type)
40
+ mod.send(:define_method, method_sig.method_name) do |&blk|
41
+ # This method is a manually sped-up version of more general code in `validate_call`
42
+ # The following line breaks are intentional to show nice pry message
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+ # PRY note:
54
+ # this code is sig validation code.
55
+ # Please issue `finish` to step out of it
56
+
57
+ return_value = original_method.bind(self).call(&blk)
58
+ unless return_value.is_a?(return_type)
59
+ message = method_sig.return_type.error_message_for_obj(return_value)
60
+ if message
61
+ CallValidation.report_error(
62
+ method_sig,
63
+ message,
64
+ 'Return value',
65
+ nil,
66
+ method_sig.return_type,
67
+ return_value,
68
+ caller_offset: -1
69
+ )
70
+ end
71
+ end
72
+ return_value
73
+ end
74
+ end
75
+
76
+ def self.create_validator_method_fast1(mod, original_method, method_sig, return_type, arg0_type)
77
+ mod.send(:define_method, method_sig.method_name) do |arg0, &blk|
78
+ # This method is a manually sped-up version of more general code in `validate_call`
79
+ unless arg0.is_a?(arg0_type)
80
+ CallValidation.report_error(
81
+ method_sig,
82
+ method_sig.arg_types[0][1].error_message_for_obj(arg0),
83
+ 'Parameter',
84
+ method_sig.arg_types[0][0],
85
+ arg0_type,
86
+ arg0,
87
+ caller_offset: -1
88
+ )
89
+ end
90
+
91
+ # The following line breaks are intentional to show nice pry message
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+ # PRY note:
103
+ # this code is sig validation code.
104
+ # Please issue `finish` to step out of it
105
+
106
+ return_value = original_method.bind(self).call(arg0, &blk)
107
+ unless return_value.is_a?(return_type)
108
+ message = method_sig.return_type.error_message_for_obj(return_value)
109
+ if message
110
+ CallValidation.report_error(
111
+ method_sig,
112
+ message,
113
+ 'Return value',
114
+ nil,
115
+ method_sig.return_type,
116
+ return_value,
117
+ caller_offset: -1
118
+ )
119
+ end
120
+ end
121
+ return_value
122
+ end
123
+ end
124
+
125
+ def self.create_validator_method_fast2(mod, original_method, method_sig, return_type, arg0_type, arg1_type)
126
+ mod.send(:define_method, method_sig.method_name) do |arg0, arg1, &blk|
127
+ # This method is a manually sped-up version of more general code in `validate_call`
128
+ unless arg0.is_a?(arg0_type)
129
+ CallValidation.report_error(
130
+ method_sig,
131
+ method_sig.arg_types[0][1].error_message_for_obj(arg0),
132
+ 'Parameter',
133
+ method_sig.arg_types[0][0],
134
+ arg0_type,
135
+ arg0,
136
+ caller_offset: -1
137
+ )
138
+ end
139
+
140
+ unless arg1.is_a?(arg1_type)
141
+ CallValidation.report_error(
142
+ method_sig,
143
+ method_sig.arg_types[1][1].error_message_for_obj(arg1),
144
+ 'Parameter',
145
+ method_sig.arg_types[1][0],
146
+ arg1_type,
147
+ arg1,
148
+ caller_offset: -1
149
+ )
150
+ end
151
+
152
+ # The following line breaks are intentional to show nice pry message
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+ # PRY note:
164
+ # this code is sig validation code.
165
+ # Please issue `finish` to step out of it
166
+
167
+ return_value = original_method.bind(self).call(arg0, arg1, &blk)
168
+ unless return_value.is_a?(return_type)
169
+ message = method_sig.return_type.error_message_for_obj(return_value)
170
+ if message
171
+ CallValidation.report_error(
172
+ method_sig,
173
+ message,
174
+ 'Return value',
175
+ nil,
176
+ method_sig.return_type,
177
+ return_value,
178
+ caller_offset: -1
179
+ )
180
+ end
181
+ end
182
+ return_value
183
+ end
184
+ end
185
+
186
+ def self.create_validator_method_fast3(mod, original_method, method_sig, return_type, arg0_type, arg1_type, arg2_type)
187
+ mod.send(:define_method, method_sig.method_name) do |arg0, arg1, arg2, &blk|
188
+ # This method is a manually sped-up version of more general code in `validate_call`
189
+ unless arg0.is_a?(arg0_type)
190
+ CallValidation.report_error(
191
+ method_sig,
192
+ method_sig.arg_types[0][1].error_message_for_obj(arg0),
193
+ 'Parameter',
194
+ method_sig.arg_types[0][0],
195
+ arg0_type,
196
+ arg0,
197
+ caller_offset: -1
198
+ )
199
+ end
200
+
201
+ unless arg1.is_a?(arg1_type)
202
+ CallValidation.report_error(
203
+ method_sig,
204
+ method_sig.arg_types[1][1].error_message_for_obj(arg1),
205
+ 'Parameter',
206
+ method_sig.arg_types[1][0],
207
+ arg1_type,
208
+ arg1,
209
+ caller_offset: -1
210
+ )
211
+ end
212
+
213
+ unless arg2.is_a?(arg2_type)
214
+ CallValidation.report_error(
215
+ method_sig,
216
+ method_sig.arg_types[2][1].error_message_for_obj(arg2),
217
+ 'Parameter',
218
+ method_sig.arg_types[2][0],
219
+ arg2_type,
220
+ arg2,
221
+ caller_offset: -1
222
+ )
223
+ end
224
+
225
+ # The following line breaks are intentional to show nice pry message
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+
236
+ # PRY note:
237
+ # this code is sig validation code.
238
+ # Please issue `finish` to step out of it
239
+
240
+ return_value = original_method.bind(self).call(arg0, arg1, arg2, &blk)
241
+ unless return_value.is_a?(return_type)
242
+ message = method_sig.return_type.error_message_for_obj(return_value)
243
+ if message
244
+ CallValidation.report_error(
245
+ method_sig,
246
+ message,
247
+ 'Return value',
248
+ nil,
249
+ method_sig.return_type,
250
+ return_value,
251
+ caller_offset: -1
252
+ )
253
+ end
254
+ end
255
+ return_value
256
+ end
257
+ end
258
+
259
+ def self.create_validator_method_fast4(mod, original_method, method_sig, return_type, arg0_type, arg1_type, arg2_type, arg3_type)
260
+ mod.send(:define_method, method_sig.method_name) do |arg0, arg1, arg2, arg3, &blk|
261
+ # This method is a manually sped-up version of more general code in `validate_call`
262
+ unless arg0.is_a?(arg0_type)
263
+ CallValidation.report_error(
264
+ method_sig,
265
+ method_sig.arg_types[0][1].error_message_for_obj(arg0),
266
+ 'Parameter',
267
+ method_sig.arg_types[0][0],
268
+ arg0_type,
269
+ arg0,
270
+ caller_offset: -1
271
+ )
272
+ end
273
+
274
+ unless arg1.is_a?(arg1_type)
275
+ CallValidation.report_error(
276
+ method_sig,
277
+ method_sig.arg_types[1][1].error_message_for_obj(arg1),
278
+ 'Parameter',
279
+ method_sig.arg_types[1][0],
280
+ arg1_type,
281
+ arg1,
282
+ caller_offset: -1
283
+ )
284
+ end
285
+
286
+ unless arg2.is_a?(arg2_type)
287
+ CallValidation.report_error(
288
+ method_sig,
289
+ method_sig.arg_types[2][1].error_message_for_obj(arg2),
290
+ 'Parameter',
291
+ method_sig.arg_types[2][0],
292
+ arg2_type,
293
+ arg2,
294
+ caller_offset: -1
295
+ )
296
+ end
297
+
298
+ unless arg3.is_a?(arg3_type)
299
+ CallValidation.report_error(
300
+ method_sig,
301
+ method_sig.arg_types[3][1].error_message_for_obj(arg3),
302
+ 'Parameter',
303
+ method_sig.arg_types[3][0],
304
+ arg3_type,
305
+ arg3,
306
+ caller_offset: -1
307
+ )
308
+ end
309
+
310
+ # The following line breaks are intentional to show nice pry message
311
+
312
+
313
+
314
+
315
+
316
+
317
+
318
+
319
+
320
+
321
+ # PRY note:
322
+ # this code is sig validation code.
323
+ # Please issue `finish` to step out of it
324
+
325
+ return_value = original_method.bind(self).call(arg0, arg1, arg2, arg3, &blk)
326
+ unless return_value.is_a?(return_type)
327
+ message = method_sig.return_type.error_message_for_obj(return_value)
328
+ if message
329
+ CallValidation.report_error(
330
+ method_sig,
331
+ message,
332
+ 'Return value',
333
+ nil,
334
+ method_sig.return_type,
335
+ return_value,
336
+ caller_offset: -1
337
+ )
338
+ end
339
+ end
340
+ return_value
341
+ end
342
+ end
343
+
344
+ def self.create_validator_procedure_fast(mod, original_method, method_sig)
345
+ # trampoline to reduce stack frame size
346
+ if method_sig.arg_types.empty?
347
+ create_validator_procedure_fast0(mod, original_method, method_sig)
348
+ elsif method_sig.arg_types.length == 1
349
+ create_validator_procedure_fast1(mod, original_method, method_sig,
350
+ method_sig.arg_types[0][1].raw_type)
351
+ elsif method_sig.arg_types.length == 2
352
+ create_validator_procedure_fast2(mod, original_method, method_sig,
353
+ method_sig.arg_types[0][1].raw_type,
354
+ method_sig.arg_types[1][1].raw_type)
355
+ elsif method_sig.arg_types.length == 3
356
+ create_validator_procedure_fast3(mod, original_method, method_sig,
357
+ method_sig.arg_types[0][1].raw_type,
358
+ method_sig.arg_types[1][1].raw_type,
359
+ method_sig.arg_types[2][1].raw_type)
360
+ elsif method_sig.arg_types.length == 4
361
+ create_validator_procedure_fast4(mod, original_method, method_sig,
362
+ method_sig.arg_types[0][1].raw_type,
363
+ method_sig.arg_types[1][1].raw_type,
364
+ method_sig.arg_types[2][1].raw_type,
365
+ method_sig.arg_types[3][1].raw_type)
366
+ else
367
+ raise 'should not happen'
368
+ end
369
+ end
370
+
371
+ def self.create_validator_procedure_fast0(mod, original_method, method_sig)
372
+ mod.send(:define_method, method_sig.method_name) do |&blk|
373
+ # This method is a manually sped-up version of more general code in `validate_call`
374
+ # The following line breaks are intentional to show nice pry message
375
+
376
+
377
+
378
+
379
+
380
+
381
+
382
+
383
+
384
+
385
+ # PRY note:
386
+ # this code is sig validation code.
387
+ # Please issue `finish` to step out of it
388
+
389
+ original_method.bind(self).call(&blk)
390
+ T::Private::Types::Void::VOID
391
+ end
392
+ end
393
+
394
+ def self.create_validator_procedure_fast1(mod, original_method, method_sig, arg0_type)
395
+ mod.send(:define_method, method_sig.method_name) do |arg0, &blk|
396
+ # This method is a manually sped-up version of more general code in `validate_call`
397
+ unless arg0.is_a?(arg0_type)
398
+ CallValidation.report_error(
399
+ method_sig,
400
+ method_sig.arg_types[0][1].error_message_for_obj(arg0),
401
+ 'Parameter',
402
+ method_sig.arg_types[0][0],
403
+ arg0_type,
404
+ arg0,
405
+ caller_offset: -1
406
+ )
407
+ end
408
+
409
+ # The following line breaks are intentional to show nice pry message
410
+
411
+
412
+
413
+
414
+
415
+
416
+
417
+
418
+
419
+
420
+ # PRY note:
421
+ # this code is sig validation code.
422
+ # Please issue `finish` to step out of it
423
+
424
+ original_method.bind(self).call(arg0, &blk)
425
+ T::Private::Types::Void::VOID
426
+ end
427
+ end
428
+
429
+ def self.create_validator_procedure_fast2(mod, original_method, method_sig, arg0_type, arg1_type)
430
+ mod.send(:define_method, method_sig.method_name) do |arg0, arg1, &blk|
431
+ # This method is a manually sped-up version of more general code in `validate_call`
432
+ unless arg0.is_a?(arg0_type)
433
+ CallValidation.report_error(
434
+ method_sig,
435
+ method_sig.arg_types[0][1].error_message_for_obj(arg0),
436
+ 'Parameter',
437
+ method_sig.arg_types[0][0],
438
+ arg0_type,
439
+ arg0,
440
+ caller_offset: -1
441
+ )
442
+ end
443
+
444
+ unless arg1.is_a?(arg1_type)
445
+ CallValidation.report_error(
446
+ method_sig,
447
+ method_sig.arg_types[1][1].error_message_for_obj(arg1),
448
+ 'Parameter',
449
+ method_sig.arg_types[1][0],
450
+ arg1_type,
451
+ arg1,
452
+ caller_offset: -1
453
+ )
454
+ end
455
+
456
+ # The following line breaks are intentional to show nice pry message
457
+
458
+
459
+
460
+
461
+
462
+
463
+
464
+
465
+
466
+
467
+ # PRY note:
468
+ # this code is sig validation code.
469
+ # Please issue `finish` to step out of it
470
+
471
+ original_method.bind(self).call(arg0, arg1, &blk)
472
+ T::Private::Types::Void::VOID
473
+ end
474
+ end
475
+
476
+ def self.create_validator_procedure_fast3(mod, original_method, method_sig, arg0_type, arg1_type, arg2_type)
477
+ mod.send(:define_method, method_sig.method_name) do |arg0, arg1, arg2, &blk|
478
+ # This method is a manually sped-up version of more general code in `validate_call`
479
+ unless arg0.is_a?(arg0_type)
480
+ CallValidation.report_error(
481
+ method_sig,
482
+ method_sig.arg_types[0][1].error_message_for_obj(arg0),
483
+ 'Parameter',
484
+ method_sig.arg_types[0][0],
485
+ arg0_type,
486
+ arg0,
487
+ caller_offset: -1
488
+ )
489
+ end
490
+
491
+ unless arg1.is_a?(arg1_type)
492
+ CallValidation.report_error(
493
+ method_sig,
494
+ method_sig.arg_types[1][1].error_message_for_obj(arg1),
495
+ 'Parameter',
496
+ method_sig.arg_types[1][0],
497
+ arg1_type,
498
+ arg1,
499
+ caller_offset: -1
500
+ )
501
+ end
502
+
503
+ unless arg2.is_a?(arg2_type)
504
+ CallValidation.report_error(
505
+ method_sig,
506
+ method_sig.arg_types[2][1].error_message_for_obj(arg2),
507
+ 'Parameter',
508
+ method_sig.arg_types[2][0],
509
+ arg2_type,
510
+ arg2,
511
+ caller_offset: -1
512
+ )
513
+ end
514
+
515
+ # The following line breaks are intentional to show nice pry message
516
+
517
+
518
+
519
+
520
+
521
+
522
+
523
+
524
+
525
+
526
+ # PRY note:
527
+ # this code is sig validation code.
528
+ # Please issue `finish` to step out of it
529
+
530
+ original_method.bind(self).call(arg0, arg1, arg2, &blk)
531
+ T::Private::Types::Void::VOID
532
+ end
533
+ end
534
+
535
+ def self.create_validator_procedure_fast4(mod, original_method, method_sig, arg0_type, arg1_type, arg2_type, arg3_type)
536
+ mod.send(:define_method, method_sig.method_name) do |arg0, arg1, arg2, arg3, &blk|
537
+ # This method is a manually sped-up version of more general code in `validate_call`
538
+ unless arg0.is_a?(arg0_type)
539
+ CallValidation.report_error(
540
+ method_sig,
541
+ method_sig.arg_types[0][1].error_message_for_obj(arg0),
542
+ 'Parameter',
543
+ method_sig.arg_types[0][0],
544
+ arg0_type,
545
+ arg0,
546
+ caller_offset: -1
547
+ )
548
+ end
549
+
550
+ unless arg1.is_a?(arg1_type)
551
+ CallValidation.report_error(
552
+ method_sig,
553
+ method_sig.arg_types[1][1].error_message_for_obj(arg1),
554
+ 'Parameter',
555
+ method_sig.arg_types[1][0],
556
+ arg1_type,
557
+ arg1,
558
+ caller_offset: -1
559
+ )
560
+ end
561
+
562
+ unless arg2.is_a?(arg2_type)
563
+ CallValidation.report_error(
564
+ method_sig,
565
+ method_sig.arg_types[2][1].error_message_for_obj(arg2),
566
+ 'Parameter',
567
+ method_sig.arg_types[2][0],
568
+ arg2_type,
569
+ arg2,
570
+ caller_offset: -1
571
+ )
572
+ end
573
+
574
+ unless arg3.is_a?(arg3_type)
575
+ CallValidation.report_error(
576
+ method_sig,
577
+ method_sig.arg_types[3][1].error_message_for_obj(arg3),
578
+ 'Parameter',
579
+ method_sig.arg_types[3][0],
580
+ arg3_type,
581
+ arg3,
582
+ caller_offset: -1
583
+ )
584
+ end
585
+
586
+ # The following line breaks are intentional to show nice pry message
587
+
588
+
589
+
590
+
591
+
592
+
593
+
594
+
595
+
596
+
597
+ # PRY note:
598
+ # this code is sig validation code.
599
+ # Please issue `finish` to step out of it
600
+
601
+ original_method.bind(self).call(arg0, arg1, arg2, arg3, &blk)
602
+ T::Private::Types::Void::VOID
603
+ end
604
+ end
605
+
606
+ def self.create_validator_method_medium(mod, original_method, method_sig)
607
+ if method_sig.return_type.is_a?(T::Private::Types::Void)
608
+ raise 'Should have used create_validator_procedure_medium'
609
+ end
610
+ # trampoline to reduce stack frame size
611
+ if method_sig.arg_types.empty?
612
+ create_validator_method_medium0(mod, original_method, method_sig, method_sig.return_type)
613
+ elsif method_sig.arg_types.length == 1
614
+ create_validator_method_medium1(mod, original_method, method_sig, method_sig.return_type,
615
+ method_sig.arg_types[0][1])
616
+ elsif method_sig.arg_types.length == 2
617
+ create_validator_method_medium2(mod, original_method, method_sig, method_sig.return_type,
618
+ method_sig.arg_types[0][1],
619
+ method_sig.arg_types[1][1])
620
+ elsif method_sig.arg_types.length == 3
621
+ create_validator_method_medium3(mod, original_method, method_sig, method_sig.return_type,
622
+ method_sig.arg_types[0][1],
623
+ method_sig.arg_types[1][1],
624
+ method_sig.arg_types[2][1])
625
+ elsif method_sig.arg_types.length == 4
626
+ create_validator_method_medium4(mod, original_method, method_sig, method_sig.return_type,
627
+ method_sig.arg_types[0][1],
628
+ method_sig.arg_types[1][1],
629
+ method_sig.arg_types[2][1],
630
+ method_sig.arg_types[3][1])
631
+ else
632
+ raise 'should not happen'
633
+ end
634
+ end
635
+
636
+ def self.create_validator_method_medium0(mod, original_method, method_sig, return_type)
637
+ mod.send(:define_method, method_sig.method_name) do |&blk|
638
+ # This method is a manually sped-up version of more general code in `validate_call`
639
+ # The following line breaks are intentional to show nice pry message
640
+
641
+
642
+
643
+
644
+
645
+
646
+
647
+
648
+
649
+
650
+ # PRY note:
651
+ # this code is sig validation code.
652
+ # Please issue `finish` to step out of it
653
+
654
+ return_value = original_method.bind(self).call(&blk)
655
+ unless return_type.valid?(return_value)
656
+ message = method_sig.return_type.error_message_for_obj(return_value)
657
+ if message
658
+ CallValidation.report_error(
659
+ method_sig,
660
+ message,
661
+ 'Return value',
662
+ nil,
663
+ method_sig.return_type,
664
+ return_value,
665
+ caller_offset: -1
666
+ )
667
+ end
668
+ end
669
+ return_value
670
+ end
671
+ end
672
+
673
+ def self.create_validator_method_medium1(mod, original_method, method_sig, return_type, arg0_type)
674
+ mod.send(:define_method, method_sig.method_name) do |arg0, &blk|
675
+ # This method is a manually sped-up version of more general code in `validate_call`
676
+ unless arg0_type.valid?(arg0)
677
+ CallValidation.report_error(
678
+ method_sig,
679
+ method_sig.arg_types[0][1].error_message_for_obj(arg0),
680
+ 'Parameter',
681
+ method_sig.arg_types[0][0],
682
+ arg0_type,
683
+ arg0,
684
+ caller_offset: -1
685
+ )
686
+ end
687
+
688
+ # The following line breaks are intentional to show nice pry message
689
+
690
+
691
+
692
+
693
+
694
+
695
+
696
+
697
+
698
+
699
+ # PRY note:
700
+ # this code is sig validation code.
701
+ # Please issue `finish` to step out of it
702
+
703
+ return_value = original_method.bind(self).call(arg0, &blk)
704
+ unless return_type.valid?(return_value)
705
+ message = method_sig.return_type.error_message_for_obj(return_value)
706
+ if message
707
+ CallValidation.report_error(
708
+ method_sig,
709
+ message,
710
+ 'Return value',
711
+ nil,
712
+ method_sig.return_type,
713
+ return_value,
714
+ caller_offset: -1
715
+ )
716
+ end
717
+ end
718
+ return_value
719
+ end
720
+ end
721
+
722
+ def self.create_validator_method_medium2(mod, original_method, method_sig, return_type, arg0_type, arg1_type)
723
+ mod.send(:define_method, method_sig.method_name) do |arg0, arg1, &blk|
724
+ # This method is a manually sped-up version of more general code in `validate_call`
725
+ unless arg0_type.valid?(arg0)
726
+ CallValidation.report_error(
727
+ method_sig,
728
+ method_sig.arg_types[0][1].error_message_for_obj(arg0),
729
+ 'Parameter',
730
+ method_sig.arg_types[0][0],
731
+ arg0_type,
732
+ arg0,
733
+ caller_offset: -1
734
+ )
735
+ end
736
+
737
+ unless arg1_type.valid?(arg1)
738
+ CallValidation.report_error(
739
+ method_sig,
740
+ method_sig.arg_types[1][1].error_message_for_obj(arg1),
741
+ 'Parameter',
742
+ method_sig.arg_types[1][0],
743
+ arg1_type,
744
+ arg1,
745
+ caller_offset: -1
746
+ )
747
+ end
748
+
749
+ # The following line breaks are intentional to show nice pry message
750
+
751
+
752
+
753
+
754
+
755
+
756
+
757
+
758
+
759
+
760
+ # PRY note:
761
+ # this code is sig validation code.
762
+ # Please issue `finish` to step out of it
763
+
764
+ return_value = original_method.bind(self).call(arg0, arg1, &blk)
765
+ unless return_type.valid?(return_value)
766
+ message = method_sig.return_type.error_message_for_obj(return_value)
767
+ if message
768
+ CallValidation.report_error(
769
+ method_sig,
770
+ message,
771
+ 'Return value',
772
+ nil,
773
+ method_sig.return_type,
774
+ return_value,
775
+ caller_offset: -1
776
+ )
777
+ end
778
+ end
779
+ return_value
780
+ end
781
+ end
782
+
783
+ def self.create_validator_method_medium3(mod, original_method, method_sig, return_type, arg0_type, arg1_type, arg2_type)
784
+ mod.send(:define_method, method_sig.method_name) do |arg0, arg1, arg2, &blk|
785
+ # This method is a manually sped-up version of more general code in `validate_call`
786
+ unless arg0_type.valid?(arg0)
787
+ CallValidation.report_error(
788
+ method_sig,
789
+ method_sig.arg_types[0][1].error_message_for_obj(arg0),
790
+ 'Parameter',
791
+ method_sig.arg_types[0][0],
792
+ arg0_type,
793
+ arg0,
794
+ caller_offset: -1
795
+ )
796
+ end
797
+
798
+ unless arg1_type.valid?(arg1)
799
+ CallValidation.report_error(
800
+ method_sig,
801
+ method_sig.arg_types[1][1].error_message_for_obj(arg1),
802
+ 'Parameter',
803
+ method_sig.arg_types[1][0],
804
+ arg1_type,
805
+ arg1,
806
+ caller_offset: -1
807
+ )
808
+ end
809
+
810
+ unless arg2_type.valid?(arg2)
811
+ CallValidation.report_error(
812
+ method_sig,
813
+ method_sig.arg_types[2][1].error_message_for_obj(arg2),
814
+ 'Parameter',
815
+ method_sig.arg_types[2][0],
816
+ arg2_type,
817
+ arg2,
818
+ caller_offset: -1
819
+ )
820
+ end
821
+
822
+ # The following line breaks are intentional to show nice pry message
823
+
824
+
825
+
826
+
827
+
828
+
829
+
830
+
831
+
832
+
833
+ # PRY note:
834
+ # this code is sig validation code.
835
+ # Please issue `finish` to step out of it
836
+
837
+ return_value = original_method.bind(self).call(arg0, arg1, arg2, &blk)
838
+ unless return_type.valid?(return_value)
839
+ message = method_sig.return_type.error_message_for_obj(return_value)
840
+ if message
841
+ CallValidation.report_error(
842
+ method_sig,
843
+ message,
844
+ 'Return value',
845
+ nil,
846
+ method_sig.return_type,
847
+ return_value,
848
+ caller_offset: -1
849
+ )
850
+ end
851
+ end
852
+ return_value
853
+ end
854
+ end
855
+
856
+ def self.create_validator_method_medium4(mod, original_method, method_sig, return_type, arg0_type, arg1_type, arg2_type, arg3_type)
857
+ mod.send(:define_method, method_sig.method_name) do |arg0, arg1, arg2, arg3, &blk|
858
+ # This method is a manually sped-up version of more general code in `validate_call`
859
+ unless arg0_type.valid?(arg0)
860
+ CallValidation.report_error(
861
+ method_sig,
862
+ method_sig.arg_types[0][1].error_message_for_obj(arg0),
863
+ 'Parameter',
864
+ method_sig.arg_types[0][0],
865
+ arg0_type,
866
+ arg0,
867
+ caller_offset: -1
868
+ )
869
+ end
870
+
871
+ unless arg1_type.valid?(arg1)
872
+ CallValidation.report_error(
873
+ method_sig,
874
+ method_sig.arg_types[1][1].error_message_for_obj(arg1),
875
+ 'Parameter',
876
+ method_sig.arg_types[1][0],
877
+ arg1_type,
878
+ arg1,
879
+ caller_offset: -1
880
+ )
881
+ end
882
+
883
+ unless arg2_type.valid?(arg2)
884
+ CallValidation.report_error(
885
+ method_sig,
886
+ method_sig.arg_types[2][1].error_message_for_obj(arg2),
887
+ 'Parameter',
888
+ method_sig.arg_types[2][0],
889
+ arg2_type,
890
+ arg2,
891
+ caller_offset: -1
892
+ )
893
+ end
894
+
895
+ unless arg3_type.valid?(arg3)
896
+ CallValidation.report_error(
897
+ method_sig,
898
+ method_sig.arg_types[3][1].error_message_for_obj(arg3),
899
+ 'Parameter',
900
+ method_sig.arg_types[3][0],
901
+ arg3_type,
902
+ arg3,
903
+ caller_offset: -1
904
+ )
905
+ end
906
+
907
+ # The following line breaks are intentional to show nice pry message
908
+
909
+
910
+
911
+
912
+
913
+
914
+
915
+
916
+
917
+
918
+ # PRY note:
919
+ # this code is sig validation code.
920
+ # Please issue `finish` to step out of it
921
+
922
+ return_value = original_method.bind(self).call(arg0, arg1, arg2, arg3, &blk)
923
+ unless return_type.valid?(return_value)
924
+ message = method_sig.return_type.error_message_for_obj(return_value)
925
+ if message
926
+ CallValidation.report_error(
927
+ method_sig,
928
+ message,
929
+ 'Return value',
930
+ nil,
931
+ method_sig.return_type,
932
+ return_value,
933
+ caller_offset: -1
934
+ )
935
+ end
936
+ end
937
+ return_value
938
+ end
939
+ end
940
+
941
+ def self.create_validator_procedure_medium(mod, original_method, method_sig)
942
+ # trampoline to reduce stack frame size
943
+ if method_sig.arg_types.empty?
944
+ create_validator_procedure_medium0(mod, original_method, method_sig)
945
+ elsif method_sig.arg_types.length == 1
946
+ create_validator_procedure_medium1(mod, original_method, method_sig,
947
+ method_sig.arg_types[0][1])
948
+ elsif method_sig.arg_types.length == 2
949
+ create_validator_procedure_medium2(mod, original_method, method_sig,
950
+ method_sig.arg_types[0][1],
951
+ method_sig.arg_types[1][1])
952
+ elsif method_sig.arg_types.length == 3
953
+ create_validator_procedure_medium3(mod, original_method, method_sig,
954
+ method_sig.arg_types[0][1],
955
+ method_sig.arg_types[1][1],
956
+ method_sig.arg_types[2][1])
957
+ elsif method_sig.arg_types.length == 4
958
+ create_validator_procedure_medium4(mod, original_method, method_sig,
959
+ method_sig.arg_types[0][1],
960
+ method_sig.arg_types[1][1],
961
+ method_sig.arg_types[2][1],
962
+ method_sig.arg_types[3][1])
963
+ else
964
+ raise 'should not happen'
965
+ end
966
+ end
967
+
968
+ def self.create_validator_procedure_medium0(mod, original_method, method_sig)
969
+ mod.send(:define_method, method_sig.method_name) do |&blk|
970
+ # This method is a manually sped-up version of more general code in `validate_call`
971
+ # The following line breaks are intentional to show nice pry message
972
+
973
+
974
+
975
+
976
+
977
+
978
+
979
+
980
+
981
+
982
+ # PRY note:
983
+ # this code is sig validation code.
984
+ # Please issue `finish` to step out of it
985
+
986
+ original_method.bind(self).call(&blk)
987
+ T::Private::Types::Void::VOID
988
+ end
989
+ end
990
+
991
+ def self.create_validator_procedure_medium1(mod, original_method, method_sig, arg0_type)
992
+ mod.send(:define_method, method_sig.method_name) do |arg0, &blk|
993
+ # This method is a manually sped-up version of more general code in `validate_call`
994
+ unless arg0_type.valid?(arg0)
995
+ CallValidation.report_error(
996
+ method_sig,
997
+ method_sig.arg_types[0][1].error_message_for_obj(arg0),
998
+ 'Parameter',
999
+ method_sig.arg_types[0][0],
1000
+ arg0_type,
1001
+ arg0,
1002
+ caller_offset: -1
1003
+ )
1004
+ end
1005
+
1006
+ # The following line breaks are intentional to show nice pry message
1007
+
1008
+
1009
+
1010
+
1011
+
1012
+
1013
+
1014
+
1015
+
1016
+
1017
+ # PRY note:
1018
+ # this code is sig validation code.
1019
+ # Please issue `finish` to step out of it
1020
+
1021
+ original_method.bind(self).call(arg0, &blk)
1022
+ T::Private::Types::Void::VOID
1023
+ end
1024
+ end
1025
+
1026
+ def self.create_validator_procedure_medium2(mod, original_method, method_sig, arg0_type, arg1_type)
1027
+ mod.send(:define_method, method_sig.method_name) do |arg0, arg1, &blk|
1028
+ # This method is a manually sped-up version of more general code in `validate_call`
1029
+ unless arg0_type.valid?(arg0)
1030
+ CallValidation.report_error(
1031
+ method_sig,
1032
+ method_sig.arg_types[0][1].error_message_for_obj(arg0),
1033
+ 'Parameter',
1034
+ method_sig.arg_types[0][0],
1035
+ arg0_type,
1036
+ arg0,
1037
+ caller_offset: -1
1038
+ )
1039
+ end
1040
+
1041
+ unless arg1_type.valid?(arg1)
1042
+ CallValidation.report_error(
1043
+ method_sig,
1044
+ method_sig.arg_types[1][1].error_message_for_obj(arg1),
1045
+ 'Parameter',
1046
+ method_sig.arg_types[1][0],
1047
+ arg1_type,
1048
+ arg1,
1049
+ caller_offset: -1
1050
+ )
1051
+ end
1052
+
1053
+ # The following line breaks are intentional to show nice pry message
1054
+
1055
+
1056
+
1057
+
1058
+
1059
+
1060
+
1061
+
1062
+
1063
+
1064
+ # PRY note:
1065
+ # this code is sig validation code.
1066
+ # Please issue `finish` to step out of it
1067
+
1068
+ original_method.bind(self).call(arg0, arg1, &blk)
1069
+ T::Private::Types::Void::VOID
1070
+ end
1071
+ end
1072
+
1073
+ def self.create_validator_procedure_medium3(mod, original_method, method_sig, arg0_type, arg1_type, arg2_type)
1074
+ mod.send(:define_method, method_sig.method_name) do |arg0, arg1, arg2, &blk|
1075
+ # This method is a manually sped-up version of more general code in `validate_call`
1076
+ unless arg0_type.valid?(arg0)
1077
+ CallValidation.report_error(
1078
+ method_sig,
1079
+ method_sig.arg_types[0][1].error_message_for_obj(arg0),
1080
+ 'Parameter',
1081
+ method_sig.arg_types[0][0],
1082
+ arg0_type,
1083
+ arg0,
1084
+ caller_offset: -1
1085
+ )
1086
+ end
1087
+
1088
+ unless arg1_type.valid?(arg1)
1089
+ CallValidation.report_error(
1090
+ method_sig,
1091
+ method_sig.arg_types[1][1].error_message_for_obj(arg1),
1092
+ 'Parameter',
1093
+ method_sig.arg_types[1][0],
1094
+ arg1_type,
1095
+ arg1,
1096
+ caller_offset: -1
1097
+ )
1098
+ end
1099
+
1100
+ unless arg2_type.valid?(arg2)
1101
+ CallValidation.report_error(
1102
+ method_sig,
1103
+ method_sig.arg_types[2][1].error_message_for_obj(arg2),
1104
+ 'Parameter',
1105
+ method_sig.arg_types[2][0],
1106
+ arg2_type,
1107
+ arg2,
1108
+ caller_offset: -1
1109
+ )
1110
+ end
1111
+
1112
+ # The following line breaks are intentional to show nice pry message
1113
+
1114
+
1115
+
1116
+
1117
+
1118
+
1119
+
1120
+
1121
+
1122
+
1123
+ # PRY note:
1124
+ # this code is sig validation code.
1125
+ # Please issue `finish` to step out of it
1126
+
1127
+ original_method.bind(self).call(arg0, arg1, arg2, &blk)
1128
+ T::Private::Types::Void::VOID
1129
+ end
1130
+ end
1131
+
1132
+ def self.create_validator_procedure_medium4(mod, original_method, method_sig, arg0_type, arg1_type, arg2_type, arg3_type)
1133
+ mod.send(:define_method, method_sig.method_name) do |arg0, arg1, arg2, arg3, &blk|
1134
+ # This method is a manually sped-up version of more general code in `validate_call`
1135
+ unless arg0_type.valid?(arg0)
1136
+ CallValidation.report_error(
1137
+ method_sig,
1138
+ method_sig.arg_types[0][1].error_message_for_obj(arg0),
1139
+ 'Parameter',
1140
+ method_sig.arg_types[0][0],
1141
+ arg0_type,
1142
+ arg0,
1143
+ caller_offset: -1
1144
+ )
1145
+ end
1146
+
1147
+ unless arg1_type.valid?(arg1)
1148
+ CallValidation.report_error(
1149
+ method_sig,
1150
+ method_sig.arg_types[1][1].error_message_for_obj(arg1),
1151
+ 'Parameter',
1152
+ method_sig.arg_types[1][0],
1153
+ arg1_type,
1154
+ arg1,
1155
+ caller_offset: -1
1156
+ )
1157
+ end
1158
+
1159
+ unless arg2_type.valid?(arg2)
1160
+ CallValidation.report_error(
1161
+ method_sig,
1162
+ method_sig.arg_types[2][1].error_message_for_obj(arg2),
1163
+ 'Parameter',
1164
+ method_sig.arg_types[2][0],
1165
+ arg2_type,
1166
+ arg2,
1167
+ caller_offset: -1
1168
+ )
1169
+ end
1170
+
1171
+ unless arg3_type.valid?(arg3)
1172
+ CallValidation.report_error(
1173
+ method_sig,
1174
+ method_sig.arg_types[3][1].error_message_for_obj(arg3),
1175
+ 'Parameter',
1176
+ method_sig.arg_types[3][0],
1177
+ arg3_type,
1178
+ arg3,
1179
+ caller_offset: -1
1180
+ )
1181
+ end
1182
+
1183
+ # The following line breaks are intentional to show nice pry message
1184
+
1185
+
1186
+
1187
+
1188
+
1189
+
1190
+
1191
+
1192
+
1193
+
1194
+ # PRY note:
1195
+ # this code is sig validation code.
1196
+ # Please issue `finish` to step out of it
1197
+
1198
+ original_method.bind(self).call(arg0, arg1, arg2, arg3, &blk)
1199
+ T::Private::Types::Void::VOID
1200
+ end
1201
+ end
1202
+
1203
+ end