@@ -674,8 +674,13 @@ def typecheck_method_override(m1, m2, location):
674674 # TODO move to caller
675675 (_ , type1 ) = eval_type (t1 , a1 .site , location , global_scope )
676676 (_ , type2 ) = eval_type (t2 , a2 .site , location , global_scope )
677- if safe_realtype_unconst (type1 ).cmp (
678- safe_realtype_unconst (type2 )) != 0 :
677+ type1 = safe_realtype_unconst (type1 )
678+ type2 = safe_realtype_unconst (type2 )
679+
680+ ok = (type1 .cmp_fuzzy (type2 )
681+ if compat .lenient_typechecking in dml .globals .enabled_compat
682+ else type1 .cmp (type2 )) == 0
683+ if not ok :
679684 raise EMETH (a1 .site , a2 .site ,
680685 f"mismatching types in input argument { n1 } " )
681686
@@ -684,8 +689,12 @@ def typecheck_method_override(m1, m2, location):
684689 ((n1 , t1 ), (n2 , t2 )) = (a1 .args , a2 .args )
685690 (_ , type1 ) = eval_type (t1 , a1 .site , location , global_scope )
686691 (_ , type2 ) = eval_type (t2 , a2 .site , location , global_scope )
687- if safe_realtype_unconst (type1 ).cmp (
688- safe_realtype_unconst (type2 )) != 0 :
692+ type1 = safe_realtype_unconst (type1 )
693+ type2 = safe_realtype_unconst (type2 )
694+ ok = (type1 .cmp_fuzzy (type2 )
695+ if compat .lenient_typechecking in dml .globals .enabled_compat
696+ else type1 .cmp (type2 )) == 0
697+ if not ok :
689698 msg = "mismatching types in return value"
690699 if len (outp1 ) > 1 :
691700 msg += f" { i + 1 } "
0 commit comments