Result of in operation is always bool (PY-31956)

This commit is contained in:
Semyon Proshev
2018-11-30 21:09:30 +03:00
parent ca46b0c37d
commit 8ff5dd251f
2 changed files with 13 additions and 0 deletions
@@ -136,6 +136,9 @@ public class PyBinaryExpressionImpl extends PyElementImpl implements PyBinaryExp
}
return PyUnionType.union(leftType, rightType);
}
if (PyNames.CONTAINS.equals(getReferencedName())) return PyBuiltinCache.getInstance(this).getBoolType();
final List<PyCallExpression.PyArgumentsMapping> results =
PyCallExpressionHelper.mapArguments(this, PyResolveContext.noImplicits().withTypeEvalContext(context));
if (!results.isEmpty()) {
@@ -3305,6 +3305,16 @@ public class PyTypeTest extends PyTestCase {
" expr = a");
}
// PY-31956
public void testInAndNotBoolContains() {
doTest("bool",
"class MyClass:\n" +
" def __contains__(self):\n" +
" return 42\n" +
"\n" +
"expr = 1 in MyClass()");
}
// PY-32533
public void testSuperWithAnotherType() {
runWithLanguageLevel(