diff --git a/python/testData/pyi/type/overloadedNotMatchedGenericType/OverloadedNotMatchedGenericType.py b/python/testData/pyi/type/overloadedNotMatchedGenericType/OverloadedNotMatchedGenericType.py new file mode 100644 index 000000000000..7d0f380f72e4 --- /dev/null +++ b/python/testData/pyi/type/overloadedNotMatchedGenericType/OverloadedNotMatchedGenericType.py @@ -0,0 +1,6 @@ +from typing import Any +from m1 import C + +def f(x: list): +c = C() +expr = c.foo(non_existing=0) diff --git a/python/testData/pyi/type/overloadedNotMatchedGenericType/m1.pyi b/python/testData/pyi/type/overloadedNotMatchedGenericType/m1.pyi new file mode 100644 index 000000000000..2466ad1c3b84 --- /dev/null +++ b/python/testData/pyi/type/overloadedNotMatchedGenericType/m1.pyi @@ -0,0 +1,9 @@ +from typing import TypeVar, Generic, overload, List, Dict + +_T = TypeVar('_T') + +class C(Generic[_T]): + @overload + def foo(self, i: int) -> Dict[str, _T]: ... + @overload + def foo(self, s: str) -> List[_T]: ... diff --git a/python/testSrc/com/jetbrains/python/pyi/PyiTypeTest.java b/python/testSrc/com/jetbrains/python/pyi/PyiTypeTest.java index 33d3dfdbffcb..73401bdc72cd 100644 --- a/python/testSrc/com/jetbrains/python/pyi/PyiTypeTest.java +++ b/python/testSrc/com/jetbrains/python/pyi/PyiTypeTest.java @@ -118,4 +118,9 @@ public class PyiTypeTest extends PyTestCase { public void testOverloadedNotMatchedType() { doTest("Union[list, Any]"); } + + // PY-22808 + public void testOverloadedNotMatchedGenericType() { + doTest("Union[Dict[str, Any], list]"); + } }