@@ -3776,15 +3776,23 @@ f(x, empty) # E: Cannot infer value of type parameter "T" of "f"
37763776f(["no"], empty) # E: Cannot infer value of type parameter "T" of "f"
37773777[builtins fixtures/list.pyi]
37783778
3779- [case testInferenceWorksWithEmptyCollectionsUnion-xfail ]
3779+ [case testInferenceWorksWithEmptyCollectionsUnion]
37803780from typing import Any, Dict, NoReturn, NoReturn, Union
37813781
37823782def foo() -> Union[Dict[str, Any], Dict[int, Any]]:
37833783 return {}
3784+ [builtins fixtures/dict.pyi]
3785+
3786+ [case testExistingEmptyCollectionDoesNotUpcast]
3787+ from typing import Any, Dict, NoReturn, NoReturn, Union
37843788
37853789empty: Dict[NoReturn, NoReturn]
3790+
3791+ def foo() -> Dict[str, Any]:
3792+ return empty # E: Incompatible return value type (got "dict[Never, Never]", expected "dict[str, Any]")
3793+
37863794def bar() -> Union[Dict[str, Any], Dict[int, Any]]:
3787- return empty
3795+ return empty # E: Incompatible return value type (got "dict[Never, Never]", expected "Union[dict[str, Any], dict[int, Any]]")
37883796[builtins fixtures/dict.pyi]
37893797
37903798[case testUpperBoundInferenceFallbackNotOverused]
0 commit comments