File: irbuild-classes.test

package info (click to toggle)
mypy 0.812-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 18,596 kB
  • sloc: python: 74,869; cpp: 11,212; ansic: 3,935; makefile: 238; sh: 13
file content (1063 lines) | stat: -rw-r--r-- 21,572 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
[case testGetAttribute]
class A:
    x: int

def f(a: A) -> int:
    return a.x
[out]
def f(a):
    a :: __main__.A
    r0 :: int
L0:
    r0 = a.x
    return r0

[case testSetAttribute]
class A:
    x: int

def f(a: A) -> None:
    a.x = 1
[out]
def f(a):
    a :: __main__.A
    r0 :: bool
L0:
    a.x = 2; r0 = is_error
    return 1

[case testUserClassInList]
class C:
    x: int

def f() -> int:
    c = C()
    c.x = 5
    a = [c]
    d = a[0]
    return d.x + 1
[out]
def f():
    r0, c :: __main__.C
    r1 :: bool
    r2 :: list
    r3, r4 :: ptr
    a :: list
    r5 :: object
    r6, d :: __main__.C
    r7, r8 :: int
L0:
    r0 = C()
    c = r0
    c.x = 10; r1 = is_error
    r2 = PyList_New(1)
    r3 = get_element_ptr r2 ob_item :: PyListObject
    r4 = load_mem r3, r2 :: ptr*
    set_mem r4, c, r2 :: builtins.object*
    a = r2
    r5 = CPyList_GetItemShort(a, 0)
    r6 = cast(__main__.C, r5)
    d = r6
    r7 = d.x
    r8 = CPyTagged_Add(r7, 2)
    return r8

[case testMethodCall]
class A:
    def f(self, x: int, y: str) -> int:
        return x + 10

def g(a: A) -> None:
    a.f(1, 'hi')
[out]
def A.f(self, x, y):
    self :: __main__.A
    x :: int
    y :: str
    r0 :: int
L0:
    r0 = CPyTagged_Add(x, 20)
    return r0
def g(a):
    a :: __main__.A
    r0 :: str
    r1 :: int
L0:
    r0 = load_global CPyStatic_unicode_4 :: static  ('hi')
    r1 = a.f(2, r0)
    return 1

[case testForwardUse]
def g(a: A) -> int:
    return a.n

class A:
    n : int

[out]
def g(a):
    a :: __main__.A
    r0 :: int
L0:
    r0 = a.n
    return r0

[case testOptionalMember]
from typing import Optional
class Node:
    next: Optional[Node]
    def length(self) -> int:
        if self.next is not None:
            return 1 + self.next.length()
        return 1
[out]
def Node.length(self):
    self :: __main__.Node
    r0 :: union[__main__.Node, None]
    r1 :: object
    r2, r3 :: bit
    r4 :: union[__main__.Node, None]
    r5 :: __main__.Node
    r6, r7 :: int
L0:
    r0 = self.next
    r1 = box(None, 1)
    r2 = r0 == r1
    r3 = r2 ^ 1
    if r3 goto L1 else goto L2 :: bool
L1:
    r4 = self.next
    r5 = cast(__main__.Node, r4)
    r6 = r5.length()
    r7 = CPyTagged_Add(2, r6)
    return r7
L2:
    return 2

[case testSubclass]
class A:
    def __init__(self) -> None:
        self.x = 10
class B(A):
    def __init__(self) -> None:
        self.x = 20
        self.y = 30
[out]
def A.__init__(self):
    self :: __main__.A
    r0 :: bool
L0:
    self.x = 20; r0 = is_error
    return 1
def B.__init__(self):
    self :: __main__.B
    r0, r1 :: bool
L0:
    self.x = 40; r0 = is_error
    self.y = 60; r1 = is_error
    return 1

[case testAttrLvalue]
class O(object):
    def __init__(self) -> None:
        self.x = 1

def increment(o: O) -> O:
    o.x += 1
    return o
[out]
def O.__init__(self):
    self :: __main__.O
    r0 :: bool
L0:
    self.x = 2; r0 = is_error
    return 1
def increment(o):
    o :: __main__.O
    r0, r1 :: int
    r2 :: bool
L0:
    r0 = o.x
    r1 = CPyTagged_Add(r0, 2)
    o.x = r1; r2 = is_error
    return o

[case testSubclassSpecialize2]
class A:
    def foo(self, x: int) -> object:
        return str(x)
class B(A):
    def foo(self, x: object) -> object:
        return x
class C(B):
    def foo(self, x: object) -> int:
        return id(x)

def use_a(x: A, y: int) -> object:
    return x.foo(y)

def use_b(x: B, y: object) -> object:
    return x.foo(y)

def use_c(x: C, y: object) -> int:
    return x.foo(y)
[out]
def A.foo(self, x):
    self :: __main__.A
    x :: int
    r0 :: str
L0:
    r0 = CPyTagged_Str(x)
    return r0
def B.foo(self, x):
    self :: __main__.B
    x :: object
L0:
    return x
def B.foo__A_glue(self, x):
    self :: __main__.B
    x :: int
    r0, r1 :: object
L0:
    r0 = box(int, x)
    r1 = B.foo(self, r0)
    return r1
def C.foo(self, x):
    self :: __main__.C
    x :: object
    r0 :: int
L0:
    r0 = CPyTagged_Id(x)
    return r0
def C.foo__B_glue(self, x):
    self :: __main__.C
    x :: object
    r0 :: int
    r1 :: object
L0:
    r0 = C.foo(self, x)
    r1 = box(int, r0)
    return r1
def C.foo__A_glue(self, x):
    self :: __main__.C
    x :: int
    r0 :: object
    r1 :: int
    r2 :: object
L0:
    r0 = box(int, x)
    r1 = C.foo(self, r0)
    r2 = box(int, r1)
    return r2
def use_a(x, y):
    x :: __main__.A
    y :: int
    r0 :: object
L0:
    r0 = x.foo(y)
    return r0
def use_b(x, y):
    x :: __main__.B
    y, r0 :: object
L0:
    r0 = x.foo(y)
    return r0
def use_c(x, y):
    x :: __main__.C
    y :: object
    r0 :: int
L0:
    r0 = x.foo(y)
    return r0

[case testSubclass_toplevel]
from typing import TypeVar, Generic
from mypy_extensions import trait
T = TypeVar('T')
class C:
    pass

@trait
class S:
    pass

class D(C, S, Generic[T]):
    pass

[out]
def __top_level__():
    r0, r1 :: object
    r2 :: bit
    r3 :: str
    r4, r5, r6 :: object
    r7 :: bit
    r8 :: str
    r9, r10 :: object
    r11 :: dict
    r12 :: str
    r13 :: object
    r14 :: str
    r15 :: int32
    r16 :: bit
    r17 :: str
    r18 :: object
    r19 :: str
    r20 :: int32
    r21 :: bit
    r22, r23 :: object
    r24 :: bit
    r25 :: str
    r26, r27 :: object
    r28 :: dict
    r29 :: str
    r30 :: object
    r31 :: str
    r32 :: int32
    r33 :: bit
    r34 :: str
    r35 :: dict
    r36 :: str
    r37, r38 :: object
    r39 :: dict
    r40 :: str
    r41 :: int32
    r42 :: bit
    r43 :: object
    r44 :: str
    r45, r46 :: object
    r47 :: bool
    r48 :: str
    r49 :: tuple
    r50 :: int32
    r51 :: bit
    r52 :: dict
    r53 :: str
    r54 :: int32
    r55 :: bit
    r56 :: object
    r57 :: str
    r58, r59 :: object
    r60 :: str
    r61 :: tuple
    r62 :: int32
    r63 :: bit
    r64 :: dict
    r65 :: str
    r66 :: int32
    r67 :: bit
    r68, r69 :: object
    r70 :: dict
    r71 :: str
    r72 :: object
    r73 :: dict
    r74 :: str
    r75, r76 :: object
    r77 :: tuple
    r78 :: str
    r79, r80 :: object
    r81 :: bool
    r82, r83 :: str
    r84 :: tuple
    r85 :: int32
    r86 :: bit
    r87 :: dict
    r88 :: str
    r89 :: int32
    r90 :: bit
L0:
    r0 = builtins :: module
    r1 = load_address _Py_NoneStruct
    r2 = r0 != r1
    if r2 goto L2 else goto L1 :: bool
L1:
    r3 = load_global CPyStatic_unicode_0 :: static  ('builtins')
    r4 = PyImport_Import(r3)
    builtins = r4 :: module
L2:
    r5 = typing :: module
    r6 = load_address _Py_NoneStruct
    r7 = r5 != r6
    if r7 goto L4 else goto L3 :: bool
L3:
    r8 = load_global CPyStatic_unicode_1 :: static  ('typing')
    r9 = PyImport_Import(r8)
    typing = r9 :: module
L4:
    r10 = typing :: module
    r11 = __main__.globals :: static
    r12 = load_global CPyStatic_unicode_2 :: static  ('TypeVar')
    r13 = CPyObject_GetAttr(r10, r12)
    r14 = load_global CPyStatic_unicode_2 :: static  ('TypeVar')
    r15 = CPyDict_SetItem(r11, r14, r13)
    r16 = r15 >= 0 :: signed
    r17 = load_global CPyStatic_unicode_3 :: static  ('Generic')
    r18 = CPyObject_GetAttr(r10, r17)
    r19 = load_global CPyStatic_unicode_3 :: static  ('Generic')
    r20 = CPyDict_SetItem(r11, r19, r18)
    r21 = r20 >= 0 :: signed
    r22 = mypy_extensions :: module
    r23 = load_address _Py_NoneStruct
    r24 = r22 != r23
    if r24 goto L6 else goto L5 :: bool
L5:
    r25 = load_global CPyStatic_unicode_4 :: static  ('mypy_extensions')
    r26 = PyImport_Import(r25)
    mypy_extensions = r26 :: module
L6:
    r27 = mypy_extensions :: module
    r28 = __main__.globals :: static
    r29 = load_global CPyStatic_unicode_5 :: static  ('trait')
    r30 = CPyObject_GetAttr(r27, r29)
    r31 = load_global CPyStatic_unicode_5 :: static  ('trait')
    r32 = CPyDict_SetItem(r28, r31, r30)
    r33 = r32 >= 0 :: signed
    r34 = load_global CPyStatic_unicode_6 :: static  ('T')
    r35 = __main__.globals :: static
    r36 = load_global CPyStatic_unicode_2 :: static  ('TypeVar')
    r37 = CPyDict_GetItem(r35, r36)
    r38 = PyObject_CallFunctionObjArgs(r37, r34, 0)
    r39 = __main__.globals :: static
    r40 = load_global CPyStatic_unicode_6 :: static  ('T')
    r41 = CPyDict_SetItem(r39, r40, r38)
    r42 = r41 >= 0 :: signed
    r43 = <error> :: object
    r44 = load_global CPyStatic_unicode_7 :: static  ('__main__')
    r45 = __main__.C_template :: type
    r46 = CPyType_FromTemplate(r45, r43, r44)
    r47 = C_trait_vtable_setup()
    r48 = load_global CPyStatic_unicode_8 :: static  ('__mypyc_attrs__')
    r49 = PyTuple_Pack(0)
    r50 = PyObject_SetAttr(r46, r48, r49)
    r51 = r50 >= 0 :: signed
    __main__.C = r46 :: type
    r52 = __main__.globals :: static
    r53 = load_global CPyStatic_unicode_9 :: static  ('C')
    r54 = CPyDict_SetItem(r52, r53, r46)
    r55 = r54 >= 0 :: signed
    r56 = <error> :: object
    r57 = load_global CPyStatic_unicode_7 :: static  ('__main__')
    r58 = __main__.S_template :: type
    r59 = CPyType_FromTemplate(r58, r56, r57)
    r60 = load_global CPyStatic_unicode_8 :: static  ('__mypyc_attrs__')
    r61 = PyTuple_Pack(0)
    r62 = PyObject_SetAttr(r59, r60, r61)
    r63 = r62 >= 0 :: signed
    __main__.S = r59 :: type
    r64 = __main__.globals :: static
    r65 = load_global CPyStatic_unicode_10 :: static  ('S')
    r66 = CPyDict_SetItem(r64, r65, r59)
    r67 = r66 >= 0 :: signed
    r68 = __main__.C :: type
    r69 = __main__.S :: type
    r70 = __main__.globals :: static
    r71 = load_global CPyStatic_unicode_3 :: static  ('Generic')
    r72 = CPyDict_GetItem(r70, r71)
    r73 = __main__.globals :: static
    r74 = load_global CPyStatic_unicode_6 :: static  ('T')
    r75 = CPyDict_GetItem(r73, r74)
    r76 = PyObject_GetItem(r72, r75)
    r77 = PyTuple_Pack(3, r68, r69, r76)
    r78 = load_global CPyStatic_unicode_7 :: static  ('__main__')
    r79 = __main__.D_template :: type
    r80 = CPyType_FromTemplate(r79, r77, r78)
    r81 = D_trait_vtable_setup()
    r82 = load_global CPyStatic_unicode_8 :: static  ('__mypyc_attrs__')
    r83 = load_global CPyStatic_unicode_11 :: static  ('__dict__')
    r84 = PyTuple_Pack(1, r83)
    r85 = PyObject_SetAttr(r80, r82, r84)
    r86 = r85 >= 0 :: signed
    __main__.D = r80 :: type
    r87 = __main__.globals :: static
    r88 = load_global CPyStatic_unicode_12 :: static  ('D')
    r89 = CPyDict_SetItem(r87, r88, r80)
    r90 = r89 >= 0 :: signed
    return 1

[case testIsInstance]
class A: pass
class B(A): pass

def f(x: A) -> B:
    if isinstance(x, B):
        return x
    return B()
[out]
def f(x):
    x :: __main__.A
    r0 :: object
    r1 :: ptr
    r2 :: object
    r3 :: bit
    r4, r5 :: __main__.B
L0:
    r0 = __main__.B :: type
    r1 = get_element_ptr x ob_type :: PyObject
    r2 = load_mem r1, x :: builtins.object*
    r3 = r2 == r0
    if r3 goto L1 else goto L2 :: bool
L1:
    r4 = cast(__main__.B, x)
    return r4
L2:
    r5 = B()
    return r5

[case testIsInstanceTuple]
from typing import Union
class R: pass
class A(R): pass
class B(R): pass
class C(R): pass

def f(x: R) -> Union[A, B]:
    if isinstance(x, (A, B)):
        return x
    return A()
[out]
def f(x):
    x :: __main__.R
    r0 :: object
    r1 :: ptr
    r2 :: object
    r3 :: bit
    r4 :: bool
    r5 :: object
    r6 :: ptr
    r7 :: object
    r8 :: bit
    r9 :: union[__main__.A, __main__.B]
    r10 :: __main__.A
L0:
    r0 = __main__.A :: type
    r1 = get_element_ptr x ob_type :: PyObject
    r2 = load_mem r1, x :: builtins.object*
    r3 = r2 == r0
    if r3 goto L1 else goto L2 :: bool
L1:
    r4 = r3
    goto L3
L2:
    r5 = __main__.B :: type
    r6 = get_element_ptr x ob_type :: PyObject
    r7 = load_mem r6, x :: builtins.object*
    r8 = r7 == r5
    r4 = r8
L3:
    if r4 goto L4 else goto L5 :: bool
L4:
    r9 = cast(union[__main__.A, __main__.B], x)
    return r9
L5:
    r10 = A()
    return r10

[case testIsInstanceFewSubclasses]
class R: pass
class A(R): pass

def f(x: object) -> R:
    if isinstance(x, R):
        return x
    return A()
[out]
def f(x):
    x, r0 :: object
    r1 :: ptr
    r2 :: object
    r3 :: bit
    r4 :: bool
    r5 :: object
    r6 :: ptr
    r7 :: object
    r8 :: bit
    r9 :: __main__.R
    r10 :: __main__.A
L0:
    r0 = __main__.A :: type
    r1 = get_element_ptr x ob_type :: PyObject
    r2 = load_mem r1, x :: builtins.object*
    r3 = r2 == r0
    if r3 goto L1 else goto L2 :: bool
L1:
    r4 = r3
    goto L3
L2:
    r5 = __main__.R :: type
    r6 = get_element_ptr x ob_type :: PyObject
    r7 = load_mem r6, x :: builtins.object*
    r8 = r7 == r5
    r4 = r8
L3:
    if r4 goto L4 else goto L5 :: bool
L4:
    r9 = cast(__main__.R, x)
    return r9
L5:
    r10 = A()
    return r10

[case testIsInstanceFewSubclassesTrait]
from mypy_extensions import trait
class B: pass
@trait
class R: pass
class A(B, R): pass
class C(B, R): pass

def f(x: object) -> R:
    if isinstance(x, R):
        return x
    return A()
[out]
def f(x):
    x, r0 :: object
    r1 :: ptr
    r2 :: object
    r3 :: bit
    r4 :: bool
    r5 :: object
    r6 :: ptr
    r7 :: object
    r8 :: bit
    r9 :: __main__.R
    r10 :: __main__.A
L0:
    r0 = __main__.A :: type
    r1 = get_element_ptr x ob_type :: PyObject
    r2 = load_mem r1, x :: builtins.object*
    r3 = r2 == r0
    if r3 goto L1 else goto L2 :: bool
L1:
    r4 = r3
    goto L3
L2:
    r5 = __main__.C :: type
    r6 = get_element_ptr x ob_type :: PyObject
    r7 = load_mem r6, x :: builtins.object*
    r8 = r7 == r5
    r4 = r8
L3:
    if r4 goto L4 else goto L5 :: bool
L4:
    r9 = cast(__main__.R, x)
    return r9
L5:
    r10 = A()
    return r10

[case testIsInstanceManySubclasses]
class R: pass
class A(R): pass
class B(R): pass
class C(R): pass

def f(x: object) -> R:
    if isinstance(x, R):
        return x
    return B()
[out]
def f(x):
    x, r0 :: object
    r1 :: bool
    r2 :: __main__.R
    r3 :: __main__.B
L0:
    r0 = __main__.R :: type
    r1 = CPy_TypeCheck(x, r0)
    if r1 goto L1 else goto L2 :: bool
L1:
    r2 = cast(__main__.R, x)
    return r2
L2:
    r3 = B()
    return r3

[case testFakeSuper]
class A:
    def __init__(self, x: int) -> None:
        self.x = x
class B(A):
    def __init__(self, x: int, y: int) -> None:
        A.__init__(self, x)
        self.y = y
[out]
def A.__init__(self, x):
    self :: __main__.A
    x :: int
    r0 :: bool
L0:
    self.x = x; r0 = is_error
    return 1
def B.__init__(self, x, y):
    self :: __main__.B
    x, y :: int
    r0 :: None
    r1 :: bool
L0:
    r0 = A.__init__(self, x)
    self.y = y; r1 = is_error
    return 1

[case testClassMethod]
class C:
    @staticmethod
    def foo(x: int) -> int: return 10 + x
    @classmethod
    def bar(cls, x: int) -> int: return 10 + x

def lol() -> int:
    return C.foo(1) + C.bar(2)
[out]
def C.foo(x):
    x, r0 :: int
L0:
    r0 = CPyTagged_Add(20, x)
    return r0
def C.bar(cls, x):
    cls :: object
    x, r0 :: int
L0:
    r0 = CPyTagged_Add(20, x)
    return r0
def lol():
    r0 :: int
    r1 :: object
    r2, r3 :: int
L0:
    r0 = C.foo(2)
    r1 = __main__.C :: type
    r2 = C.bar(r1, 4)
    r3 = CPyTagged_Add(r0, r2)
    return r3

[case testSuper1]
class A:
    def __init__(self, x: int) -> None:
        self.x = x
class B(A):
    def __init__(self, x: int, y: int) -> None:
        super().__init__(x)
        self.y = y
[out]
def A.__init__(self, x):
    self :: __main__.A
    x :: int
    r0 :: bool
L0:
    self.x = x; r0 = is_error
    return 1
def B.__init__(self, x, y):
    self :: __main__.B
    x, y :: int
    r0 :: None
    r1 :: bool
L0:
    r0 = A.__init__(self, x)
    self.y = y; r1 = is_error
    return 1

[case testSuper2]
from mypy_extensions import trait
@trait
class T:
    def foo(self) -> None: pass

class X(T):
    def foo(self) -> None:
        super().foo()
[out]
def T.foo(self):
    self :: __main__.T
L0:
    return 1
def X.foo(self):
    self :: __main__.X
    r0 :: None
L0:
    r0 = T.foo(self)
    return 1

[case testClassVariable]
from typing import ClassVar
class A:
    x = 10  # type: ClassVar[int]

def f() -> int:
    return A.x
[out]
def f():
    r0 :: object
    r1 :: str
    r2 :: object
    r3 :: int
L0:
    r0 = __main__.A :: type
    r1 = load_global CPyStatic_unicode_6 :: static  ('x')
    r2 = CPyObject_GetAttr(r0, r1)
    r3 = unbox(int, r2)
    return r3

[case testNoEqDefined]
class A:
    pass

def f(a: A, b: A) -> bool:
    return a == b

def f2(a: A, b: A) -> bool:
    return a != b

[out]
def f(a, b):
    a, b :: __main__.A
    r0 :: bit
L0:
    r0 = a == b
    return r0
def f2(a, b):
    a, b :: __main__.A
    r0 :: bit
L0:
    r0 = a != b
    return r0

[case testEqDefined]
class Base:
    def __eq__(self, other: object) -> bool:
        return False
class Derived(Base):
    def __eq__(self, other: object) -> bool:
        return True

def f(a: Base, b: Base) -> bool:
    return a == b

def f2(a: Base, b: Base) -> bool:
    return a != b

def fOpt(a: Derived, b: Derived) -> bool:
    return a == b

def fOpt2(a: Derived, b: Derived) -> bool:
    return a != b

[out]
def Base.__eq__(self, other):
    self :: __main__.Base
    other, r0 :: object
L0:
    r0 = box(bool, 0)
    return r0
def Base.__ne__(__mypyc_self__, rhs):
    __mypyc_self__ :: __main__.Base
    rhs, r0, r1 :: object
    r2 :: bit
    r3 :: int32
    r4 :: bit
    r5 :: bool
    r6 :: object
L0:
    r0 = __mypyc_self__.__eq__(rhs)
    r1 = load_address _Py_NotImplementedStruct
    r2 = r0 == r1
    if r2 goto L2 else goto L1 :: bool
L1:
    r3 = PyObject_Not(r0)
    r4 = r3 >= 0 :: signed
    r5 = truncate r3: int32 to builtins.bool
    r6 = box(bool, r5)
    return r6
L2:
    return r1
def Derived.__eq__(self, other):
    self :: __main__.Derived
    other, r0 :: object
L0:
    r0 = box(bool, 1)
    return r0
def f(a, b):
    a, b :: __main__.Base
    r0 :: object
    r1 :: bool
L0:
    r0 = PyObject_RichCompare(a, b, 2)
    r1 = unbox(bool, r0)
    return r1
def f2(a, b):
    a, b :: __main__.Base
    r0 :: object
    r1 :: bool
L0:
    r0 = PyObject_RichCompare(a, b, 3)
    r1 = unbox(bool, r0)
    return r1
def fOpt(a, b):
    a, b :: __main__.Derived
    r0 :: object
    r1 :: bool
L0:
    r0 = a.__eq__(b)
    r1 = unbox(bool, r0)
    return r1
def fOpt2(a, b):
    a, b :: __main__.Derived
    r0 :: object
    r1 :: bool
L0:
    r0 = a.__ne__(b)
    r1 = unbox(bool, r0)
    return r1

[case testEqDefinedLater]
def f(a: 'Base', b: 'Base') -> bool:
    return a == b

def f2(a: 'Base', b: 'Base') -> bool:
    return a != b

def fOpt(a: 'Derived', b: 'Derived') -> bool:
    return a == b

def fOpt2(a: 'Derived', b: 'Derived') -> bool:
    return a != b

class Base:
    pass
class Derived(Base):
    def __eq__(self, other: object) -> bool:
        return True

[out]
def f(a, b):
    a, b :: __main__.Base
    r0 :: object
    r1 :: bool
L0:
    r0 = PyObject_RichCompare(a, b, 2)
    r1 = unbox(bool, r0)
    return r1
def f2(a, b):
    a, b :: __main__.Base
    r0 :: object
    r1 :: bool
L0:
    r0 = PyObject_RichCompare(a, b, 3)
    r1 = unbox(bool, r0)
    return r1
def fOpt(a, b):
    a, b :: __main__.Derived
    r0 :: object
    r1 :: bool
L0:
    r0 = a.__eq__(b)
    r1 = unbox(bool, r0)
    return r1
def fOpt2(a, b):
    a, b :: __main__.Derived
    r0 :: str
    r1 :: object
    r2 :: bool
L0:
    r0 = load_global CPyStatic_unicode_1 :: static  ('__ne__')
    r1 = CPyObject_CallMethodObjArgs(a, r0, b, 0)
    r2 = unbox(bool, r1)
    return r2
def Derived.__eq__(self, other):
    self :: __main__.Derived
    other, r0 :: object
L0:
    r0 = box(bool, 1)
    return r0
def Derived.__ne__(__mypyc_self__, rhs):
    __mypyc_self__ :: __main__.Derived
    rhs, r0, r1 :: object
    r2 :: bit
    r3 :: int32
    r4 :: bit
    r5 :: bool
    r6 :: object
L0:
    r0 = __mypyc_self__.__eq__(rhs)
    r1 = load_address _Py_NotImplementedStruct
    r2 = r0 == r1
    if r2 goto L2 else goto L1 :: bool
L1:
    r3 = PyObject_Not(r0)
    r4 = r3 >= 0 :: signed
    r5 = truncate r3: int32 to builtins.bool
    r6 = box(bool, r5)
    return r6
L2:
    return r1

[case testDefaultVars]
from typing import ClassVar, Optional
class A:
    x = 10
    def lol(self) -> None:
        self.x = 100

LOL = 'lol'
class B(A):
    y = LOL
    z: Optional[str] = None
    b = True
    bogus = None  # type: int
[out]
def A.lol(self):
    self :: __main__.A
    r0 :: bool
L0:
    self.x = 200; r0 = is_error
    return 1
def A.__mypyc_defaults_setup(__mypyc_self__):
    __mypyc_self__ :: __main__.A
    r0 :: bool
L0:
    __mypyc_self__.x = 20; r0 = is_error
    return 1
def B.__mypyc_defaults_setup(__mypyc_self__):
    __mypyc_self__ :: __main__.B
    r0 :: bool
    r1 :: dict
    r2 :: str
    r3 :: object
    r4 :: str
    r5 :: bool
    r6 :: object
    r7, r8 :: bool
L0:
    __mypyc_self__.x = 20; r0 = is_error
    r1 = __main__.globals :: static
    r2 = load_global CPyStatic_unicode_9 :: static  ('LOL')
    r3 = CPyDict_GetItem(r1, r2)
    r4 = cast(str, r3)
    __mypyc_self__.y = r4; r5 = is_error
    r6 = box(None, 1)
    __mypyc_self__.z = r6; r7 = is_error
    __mypyc_self__.b = 1; r8 = is_error
    return 1

[case testSubclassDictSpecalized]
from typing import Dict
class WelpDict(Dict[str, int]):
    pass
def foo(x: WelpDict) -> None:
    # we care that the specalized op gets used
    x.update(x)
[out]
def foo(x):
    x :: dict
    r0 :: int32
    r1 :: bit
L0:
    r0 = CPyDict_Update(x, x)
    r1 = r0 >= 0 :: signed
    return 1

[case testNoSpuriousLinearity]
# Make sure that the non-trait MRO linearity check isn't affected by processing order
class A(B): pass
class B(C): pass
class C: pass
[out]