Don't apply substitution from ancestor if class defines its own type variable (PY-27783)

This commit is contained in:
Semyon Proshev
2018-04-09 17:48:57 +03:00
parent 91af98d772
commit 9bdf80e66e
2 changed files with 30 additions and 1 deletions
@@ -953,6 +953,27 @@ public class Py3TypeTest extends PyTestCase {
);
}
// PY-27783
public void testApplyingSuperSubstituionToGenericClass() {
runWithLanguageLevel(
LanguageLevel.PYTHON36,
() -> doTest("Dict[T, int]",
"from typing import TypeVar, Generic, Dict, List\n" +
"\n" +
"T = TypeVar('T')\n" +
"\n" +
"class A(Generic[T]):\n" +
" pass\n" +
"\n" +
"class B(A[List[T]], Generic[T]):\n" +
" def __init__(self) -> None:\n" +
" self.value_set: Dict[T, int] = {}\n" +
"\n" +
" def foo(self) -> None:\n" +
" expr = self.value_set")
);
}
private void doTest(final String expectedType, final String text) {
myFixture.configureByText(PythonFileType.INSTANCE, text);
final PyExpression expr = myFixture.findElementByText("expr", PyExpression.class);