Skip to content

Commit ab6eea0

Browse files
committed
Fix
1 parent dad009a commit ab6eea0

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

mypyc/irbuild/prepare.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -838,16 +838,21 @@ def adjust_generator_classes_of_methods(mapper: Mapper) -> None:
838838
precise_ret_type = True
839839
if fn_ir.class_name is not None:
840840
class_ir = mapper.type_to_ir[fdef.info]
841-
for s in class_ir.subclasses():
842-
if name in s.method_decls:
843-
m = s.method_decls[name]
844-
if (
845-
m.is_generator != fn_ir.is_generator
846-
or m.is_coroutine != fn_ir.is_coroutine
847-
):
848-
# Override is of a different kind, and the optimization
849-
# to use a precise generator return type doesn't work.
850-
precise_ret_type = False
841+
subcls = class_ir.subclasses()
842+
if subcls is None:
843+
# Override could be of a different type, so we can't make assumptions.
844+
precise_ret_type = False
845+
else:
846+
for s in subcls:
847+
if name in s.method_decls:
848+
m = s.method_decls[name]
849+
if (
850+
m.is_generator != fn_ir.is_generator
851+
or m.is_coroutine != fn_ir.is_coroutine
852+
):
853+
# Override is of a different kind, and the optimization
854+
# to use a precise generator return type doesn't work.
855+
precise_ret_type = False
851856
else:
852857
class_ir = None
853858

0 commit comments

Comments
 (0)