Resolve '@' to '__matmul__' and '__rmatmul__' (PY-15390)

This commit is contained in:
Andrey Vlasovskikh
2015-03-24 18:42:45 +03:00
parent 9f555474a7
commit 009cb3ee3d
4 changed files with 27 additions and 1 deletions
@@ -118,7 +118,7 @@ public class PyTokenTypes {
public static final PyElementType RBRACKET = new PyElementType("RBRACKET");// ]
public static final PyElementType LBRACE = new PyElementType("LBRACE");// {
public static final PyElementType RBRACE = new PyElementType("RBRACE");// }
public static final PyElementType AT = new PyElementType("AT");// @
public static final PyElementType AT = new PyElementType("AT", "__matmul__");// @
public static final PyElementType COMMA = new PyElementType("COMMA");// ,
public static final PyElementType COLON = new PyElementType("COLON");// :
public static final PyElementType DOT = new PyElementType("DOT");// .
+8
View File
@@ -0,0 +1,8 @@
class C:
def __matmul__(self, other):
return self
x = C()
x @ y
# <ref>
+8
View File
@@ -0,0 +1,8 @@
class C:
def __rmatmul__(self, other):
return self
x = C()
y @ x
# <ref>
@@ -571,4 +571,14 @@ public class PyResolveTest extends PyResolveTestCase {
public void testResolveAttributesUsingOldStyleMROWhenUnresolvedAncestorsAndC3Fails() {
assertResolvesTo(PyFunction.class, "foo");
}
// PY-15390
public void testMatMul() {
assertResolvesTo(PyFunction.class, "__matmul__");
}
// PY-15390
public void testRMatMul() {
assertResolvesTo(PyFunction.class, "__rmatmul__");
}
}