From 009cb3ee3d9229a541931924ad998edece3a7d82 Mon Sep 17 00:00:00 2001 From: Andrey Vlasovskikh Date: Tue, 24 Mar 2015 18:38:03 +0300 Subject: [PATCH] Resolve '@' to '__matmul__' and '__rmatmul__' (PY-15390) --- .../psi-api/src/com/jetbrains/python/PyTokenTypes.java | 2 +- python/testData/resolve/MatMul.py | 8 ++++++++ python/testData/resolve/RMatMul.py | 8 ++++++++ python/testSrc/com/jetbrains/python/PyResolveTest.java | 10 ++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 python/testData/resolve/MatMul.py create mode 100644 python/testData/resolve/RMatMul.py diff --git a/python/psi-api/src/com/jetbrains/python/PyTokenTypes.java b/python/psi-api/src/com/jetbrains/python/PyTokenTypes.java index f1f73a969fd9..a54bdc39ad92 100644 --- a/python/psi-api/src/com/jetbrains/python/PyTokenTypes.java +++ b/python/psi-api/src/com/jetbrains/python/PyTokenTypes.java @@ -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");// . diff --git a/python/testData/resolve/MatMul.py b/python/testData/resolve/MatMul.py new file mode 100644 index 000000000000..d3315dfe09b3 --- /dev/null +++ b/python/testData/resolve/MatMul.py @@ -0,0 +1,8 @@ +class C: + def __matmul__(self, other): + return self + + +x = C() +x @ y +# diff --git a/python/testData/resolve/RMatMul.py b/python/testData/resolve/RMatMul.py new file mode 100644 index 000000000000..ed242419d045 --- /dev/null +++ b/python/testData/resolve/RMatMul.py @@ -0,0 +1,8 @@ +class C: + def __rmatmul__(self, other): + return self + + +x = C() +y @ x +# diff --git a/python/testSrc/com/jetbrains/python/PyResolveTest.java b/python/testSrc/com/jetbrains/python/PyResolveTest.java index 78be57f40c5a..27c7558970b9 100644 --- a/python/testSrc/com/jetbrains/python/PyResolveTest.java +++ b/python/testSrc/com/jetbrains/python/PyResolveTest.java @@ -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__"); + } }