/
genops-classes.test
1063 lines (1004 loc) · 19.3 KB
/
genops-classes.test
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
[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 :: short_int
r1 :: bool
r2 :: None
L0:
r0 = 1
a.x = r0; r1 = is_error
r2 = None
return r2
[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 :: short_int
r2 :: bool
r3, a :: list
r4 :: short_int
r5 :: object
r6, d :: __main__.C
r7 :: int
r8 :: short_int
r9 :: int
L0:
r0 = C()
c = r0
r1 = 5
c.x = r1; r2 = is_error
r3 = [c]
a = r3
r4 = 0
r5 = a[r4] :: list
r6 = cast(__main__.C, r5)
d = r6
r7 = d.x
r8 = 1
r9 = r7 + r8 :: int
return r9
[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 :: short_int
r1 :: int
L0:
r0 = 10
r1 = x + r0 :: int
return r1
def g(a):
a :: __main__.A
r0 :: short_int
r1 :: str
r2 :: int
r3 :: None
L0:
r0 = 1
r1 = unicode_4 :: static ('hi')
r2 = a.f(r0, r1)
r3 = None
return r3
[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 :: None
r2 :: object
r3, r4 :: bool
r5 :: short_int
r6 :: union[__main__.Node, None]
r7 :: __main__.Node
r8, r9 :: int
r10 :: short_int
L0:
r0 = self.next
r1 = None
r2 = box(None, r1)
r3 = r0 is r2
r4 = !r3
if r4 goto L1 else goto L2 :: bool
L1:
r5 = 1
r6 = self.next
r7 = cast(__main__.Node, r6)
r8 = r7.length()
r9 = r5 + r8 :: int
return r9
L2:
r10 = 1
return r10
[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 :: short_int
r1 :: bool
r2 :: None
L0:
r0 = 10
self.x = r0; r1 = is_error
r2 = None
return r2
def B.__init__(self):
self :: __main__.B
r0 :: short_int
r1 :: bool
r2 :: short_int
r3 :: bool
r4 :: None
L0:
r0 = 20
self.x = r0; r1 = is_error
r2 = 30
self.y = r2; r3 = is_error
r4 = None
return r4
[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 :: short_int
r1 :: bool
r2 :: None
L0:
r0 = 1
self.x = r0; r1 = is_error
r2 = None
return r2
def increment(o):
o :: __main__.O
r0 :: int
r1 :: short_int
r2 :: int
r3 :: bool
L0:
r0 = o.x
r1 = 1
r2 = r0 += r1 :: int
o.x = r2; r3 = 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 :: object
r1 :: str
L0:
r0 = box(int, x)
r1 = str r0 :: object
return r1
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 = id x :: object
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 :: bool
r3 :: str
r4, r5, r6 :: object
r7 :: bool
r8 :: str
r9, r10 :: object
r11 :: dict
r12 :: str
r13 :: object
r14 :: str
r15 :: bool
r16 :: str
r17 :: object
r18 :: str
r19 :: bool
r20, r21 :: object
r22 :: bool
r23 :: str
r24, r25 :: object
r26 :: dict
r27 :: str
r28 :: object
r29 :: str
r30 :: bool
r31 :: str
r32 :: dict
r33 :: str
r34, r35 :: object
r36 :: dict
r37 :: str
r38 :: bool
r39 :: object
r40 :: str
r41, r42 :: object
r43 :: bool
r44 :: str
r45 :: tuple
r46 :: bool
r47 :: dict
r48 :: str
r49 :: bool
r50 :: object
r51 :: str
r52, r53 :: object
r54 :: bool
r55 :: str
r56 :: tuple
r57 :: bool
r58 :: dict
r59 :: str
r60 :: bool
r61, r62 :: object
r63 :: dict
r64 :: str
r65 :: object
r66 :: dict
r67 :: str
r68, r69 :: object
r70 :: tuple
r71 :: str
r72, r73 :: object
r74 :: bool
r75, r76 :: str
r77 :: tuple
r78 :: bool
r79 :: dict
r80 :: str
r81 :: bool
r82 :: None
L0:
r0 = builtins.module :: static
r1 = builtins.None :: object
r2 = r0 is not r1
if r2 goto L2 else goto L1 :: bool
L1:
r3 = unicode_0 :: static ('builtins')
r4 = import r3 :: str
builtins.module = r4 :: static
L2:
r5 = typing.module :: static
r6 = builtins.None :: object
r7 = r5 is not r6
if r7 goto L4 else goto L3 :: bool
L3:
r8 = unicode_1 :: static ('typing')
r9 = import r8 :: str
typing.module = r9 :: static
L4:
r10 = typing.module :: static
r11 = __main__.globals :: static
r12 = unicode_2 :: static ('TypeVar')
r13 = getattr r10, r12
r14 = unicode_2 :: static ('TypeVar')
r15 = r11.__setitem__(r14, r13) :: dict
r16 = unicode_3 :: static ('Generic')
r17 = getattr r10, r16
r18 = unicode_3 :: static ('Generic')
r19 = r11.__setitem__(r18, r17) :: dict
r20 = mypy_extensions.module :: static
r21 = builtins.None :: object
r22 = r20 is not r21
if r22 goto L6 else goto L5 :: bool
L5:
r23 = unicode_4 :: static ('mypy_extensions')
r24 = import r23 :: str
mypy_extensions.module = r24 :: static
L6:
r25 = mypy_extensions.module :: static
r26 = __main__.globals :: static
r27 = unicode_5 :: static ('trait')
r28 = getattr r25, r27
r29 = unicode_5 :: static ('trait')
r30 = r26.__setitem__(r29, r28) :: dict
r31 = unicode_6 :: static ('T')
r32 = __main__.globals :: static
r33 = unicode_2 :: static ('TypeVar')
r34 = r32[r33] :: dict
r35 = py_call(r34, r31)
r36 = __main__.globals :: static
r37 = unicode_6 :: static ('T')
r38 = r36.__setitem__(r37, r35) :: dict
r39 = <error> :: object
r40 = unicode_7 :: static ('__main__')
r41 = __main__.C_template :: type
r42 = pytype_from_template(r41, r39, r40)
r43 = C_trait_vtable_setup()
r44 = unicode_8 :: static ('__mypyc_attrs__')
r45 = () :: tuple
r46 = setattr r42, r44, r45
__main__.C = r42 :: type
r47 = __main__.globals :: static
r48 = unicode_9 :: static ('C')
r49 = r47.__setitem__(r48, r42) :: dict
r50 = <error> :: object
r51 = unicode_7 :: static ('__main__')
r52 = __main__.S_template :: type
r53 = pytype_from_template(r52, r50, r51)
r54 = S_trait_vtable_setup()
r55 = unicode_8 :: static ('__mypyc_attrs__')
r56 = () :: tuple
r57 = setattr r53, r55, r56
__main__.S = r53 :: type
r58 = __main__.globals :: static
r59 = unicode_10 :: static ('S')
r60 = r58.__setitem__(r59, r53) :: dict
r61 = __main__.C :: type
r62 = __main__.S :: type
r63 = __main__.globals :: static
r64 = unicode_3 :: static ('Generic')
r65 = r63[r64] :: dict
r66 = __main__.globals :: static
r67 = unicode_6 :: static ('T')
r68 = r66[r67] :: dict
r69 = r65[r68] :: object
r70 = (r61, r62, r69) :: tuple
r71 = unicode_7 :: static ('__main__')
r72 = __main__.D_template :: type
r73 = pytype_from_template(r72, r70, r71)
r74 = D_trait_vtable_setup()
r75 = unicode_8 :: static ('__mypyc_attrs__')
r76 = unicode_11 :: static ('__dict__')
r77 = (r76) :: tuple
r78 = setattr r73, r75, r77
__main__.D = r73 :: type
r79 = __main__.globals :: static
r80 = unicode_12 :: static ('D')
r81 = r79.__setitem__(r80, r73) :: dict
r82 = None
return r82
[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 :: bool
r2, r3 :: __main__.B
L0:
r0 = __main__.B :: type
r1 = type_is x, r0
if r1 goto L1 else goto L2 :: bool
L1:
r2 = cast(__main__.B, x)
return r2
L2:
r3 = B()
return r3
[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, r2 :: bool
r3 :: object
r4 :: bool
r5 :: union[__main__.A, __main__.B]
r6 :: __main__.A
L0:
r0 = __main__.A :: type
r1 = type_is x, r0
if r1 goto L1 else goto L2 :: bool
L1:
r2 = r1
goto L3
L2:
r3 = __main__.B :: type
r4 = type_is x, r3
r2 = r4
L3:
if r2 goto L4 else goto L5 :: bool
L4:
r5 = cast(union[__main__.A, __main__.B], x)
return r5
L5:
r6 = A()
return r6
[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, r2 :: bool
r3 :: object
r4 :: bool
r5 :: __main__.R
r6 :: __main__.A
L0:
r0 = __main__.A :: type
r1 = type_is x, r0
if r1 goto L1 else goto L2 :: bool
L1:
r2 = r1
goto L3
L2:
r3 = __main__.R :: type
r4 = type_is x, r3
r2 = r4
L3:
if r2 goto L4 else goto L5 :: bool
L4:
r5 = cast(__main__.R, x)
return r5
L5:
r6 = A()
return r6
[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, r2 :: bool
r3 :: object
r4 :: bool
r5 :: __main__.R
r6 :: __main__.A
L0:
r0 = __main__.A :: type
r1 = type_is x, r0
if r1 goto L1 else goto L2 :: bool
L1:
r2 = r1
goto L3
L2:
r3 = __main__.C :: type
r4 = type_is x, r3
r2 = r4
L3:
if r2 goto L4 else goto L5 :: bool
L4:
r5 = cast(__main__.R, x)
return r5
L5:
r6 = A()
return r6
[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 = isinstance 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
r1 :: None
L0:
self.x = x; r0 = is_error
r1 = None
return r1
def B.__init__(self, x, y):
self :: __main__.B
x, y :: int
r0 :: None
r1 :: bool
r2 :: None
L0:
r0 = A.__init__(self, x)
self.y = y; r1 = is_error
r2 = None
return r2
[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 :: int
r0 :: short_int
r1 :: int
L0:
r0 = 10
r1 = r0 + x :: int
return r1
def C.bar(cls, x):
cls :: object
x :: int
r0 :: short_int
r1 :: int
L0:
r0 = 10
r1 = r0 + x :: int
return r1
def lol():
r0 :: short_int
r1 :: int
r2 :: object
r3 :: short_int
r4, r5 :: int
L0:
r0 = 1
r1 = C.foo(r0)
r2 = __main__.C :: type
r3 = 2
r4 = C.bar(r2, r3)
r5 = r1 + r4 :: int
return r5
[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
r1 :: None
L0:
self.x = x; r0 = is_error
r1 = None
return r1
def B.__init__(self, x, y):
self :: __main__.B
x, y :: int
r0 :: None
r1 :: bool
r2 :: None
L0:
r0 = A.__init__(self, x)
self.y = y; r1 = is_error
r2 = None
return r2
[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
r0 :: None
L0:
r0 = None
return r0
def X.foo(self):
self :: __main__.X
r0, r1 :: None
L0:
r0 = T.foo(self)
r1 = None
return r1
[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 = unicode_6 :: static ('x')
r2 = 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 :: bool
L0:
r0 = a is b
return r0
def f2(a, b):
a, b :: __main__.A
r0 :: bool
L0:
r0 = a is not 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 :: object
r0 :: bool
r1 :: object
L0:
r0 = False
r1 = box(bool, r0)
return r1
def Base.__ne__(self, rhs):
self :: __main__.Base
rhs, r0 :: object
r1 :: bool
L0:
r0 = self.__eq__(rhs)
r1 = not r0
return r1
def Derived.__eq__(self, other):
self :: __main__.Derived
other :: object
r0 :: bool
r1 :: object
L0:
r0 = True
r1 = box(bool, r0)
return r1
def f(a, b):
a, b :: __main__.Base
r0 :: object
r1 :: bool
L0:
r0 = a == b
r1 = unbox(bool, r0)
return r1
def f2(a, b):
a, b :: __main__.Base
r0 :: object
r1 :: bool
L0:
r0 = a != b
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 :: bool
L0:
r0 = a.__ne__(b)
return r0
[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 = a == b
r1 = unbox(bool, r0)
return r1
def f2(a, b):
a, b :: __main__.Base
r0 :: object
r1 :: bool
L0:
r0 = a != b
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 = unicode_1 :: static ('__ne__')
r1 = py_method_call(a, r0, b)
r2 = unbox(bool, r1)
return r2
def Derived.__eq__(self, other):
self :: __main__.Derived
other :: object
r0 :: bool
r1 :: object
L0:
r0 = True
r1 = box(bool, r0)
return r1
def Derived.__ne__(self, rhs):
self :: __main__.Derived
rhs, r0 :: object
r1 :: bool
L0:
r0 = self.__eq__(rhs)
r1 = not r0
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):