@@ -486,6 +486,7 @@ def fix_function_overloads(self, stmts: List[Statement]) -> List[Statement]:
486
486
ret : List [Statement ] = []
487
487
current_overload : List [OverloadPart ] = []
488
488
current_overload_name : Optional [str ] = None
489
+ seen_unconditional_func_def = False
489
490
last_if_stmt : Optional [IfStmt ] = None
490
491
last_if_overload : Optional [Union [Decorator , FuncDef , OverloadedFuncDef ]] = None
491
492
last_if_stmt_overload_name : Optional [str ] = None
@@ -498,6 +499,7 @@ def fix_function_overloads(self, stmts: List[Statement]) -> List[Statement]:
498
499
if (
499
500
isinstance (stmt , IfStmt )
500
501
and len (stmt .body [0 ].body ) == 1
502
+ and seen_unconditional_func_def is False
501
503
and (
502
504
isinstance (stmt .body [0 ].body [0 ], (Decorator , OverloadedFuncDef ))
503
505
or current_overload_name is not None
@@ -527,6 +529,8 @@ def fix_function_overloads(self, stmts: List[Statement]) -> List[Statement]:
527
529
self .fail_merge_overload (last_if_unknown_truth_value )
528
530
last_if_unknown_truth_value = None
529
531
current_overload .append (stmt )
532
+ if isinstance (stmt , FuncDef ):
533
+ seen_unconditional_func_def = True
530
534
elif (
531
535
current_overload_name is not None
532
536
and isinstance (stmt , IfStmt )
@@ -583,6 +587,7 @@ def fix_function_overloads(self, stmts: List[Statement]) -> List[Statement]:
583
587
# most of mypy/mypyc assumes that all the functions in an OverloadedFuncDef are
584
588
# related, but multiple underscore functions next to each other aren't necessarily
585
589
# related
590
+ seen_unconditional_func_def = False
586
591
if isinstance (stmt , Decorator ) and not unnamed_function (stmt .name ):
587
592
current_overload = [stmt ]
588
593
current_overload_name = stmt .name
0 commit comments