diff --git a/python/src/com/jetbrains/python/refactoring/PyReplaceExpressionUtil.java b/python/src/com/jetbrains/python/refactoring/PyReplaceExpressionUtil.java index 9b4c95f7d2b2..8aeba796877a 100644 --- a/python/src/com/jetbrains/python/refactoring/PyReplaceExpressionUtil.java +++ b/python/src/com/jetbrains/python/refactoring/PyReplaceExpressionUtil.java @@ -453,7 +453,7 @@ public class PyReplaceExpressionUtil implements PyElementTypes { else if (expr instanceof PyBinaryExpression) { final IElementType opType = getOperationType(expr); if (opType == EXP) priority = 3; - if (opType == MULT || opType == DIV || opType == PERC || opType == FLOORDIV) priority = 4; + if (opType == MULT || opType == AT || opType == DIV || opType == PERC || opType == FLOORDIV) priority = 4; if (opType == PLUS || opType == MINUS) priority = 5; if (opType == LTLT || opType == GTGT) priority = 6; if (opType == AND) priority = 7; diff --git a/python/testData/refactoring/inlinelocal/operatorPrecedence/matrixMultiplication.after.py b/python/testData/refactoring/inlinelocal/operatorPrecedence/matrixMultiplication.after.py new file mode 100644 index 000000000000..932b7d34be33 --- /dev/null +++ b/python/testData/refactoring/inlinelocal/operatorPrecedence/matrixMultiplication.after.py @@ -0,0 +1,57 @@ +(y @ z)[::-5] +(y @ z)[5] +(y @ z)(5) +(y @ z).foo + +-(y @ z) ++(y @ z) +~(y @ z) + +5 ** (y @ z) +(y @ z) ** 5 + +5 * y @ z +y @ z * 5 + +5 / (y @ z) +y @ z / 5 + +5 // (y @ z) +y @ z // 5 + +5 + y @ z +y @ z + 5 + +y @ z - 5 +5 - y @ z + +5 >> y @ z +y @ z << 5 + +5 & y @ z +y @ z & 5 + +5 ^ y @ z +y @ z ^ 5 + +5 | y @ z +y @ z | 5 + +() in y @ z +y @ z in () + +5 is y @ z +y @ z is 5 + +5 < y @ z +y @ z < 5 + +not y @ z + +5 and y @ z +y @ z and 5 + +5 or y @ z +y @ z or 5 + +y @ z if y @ z else y @ z diff --git a/python/testSrc/com/jetbrains/python/refactoring/PyInlineLocalTest.java b/python/testSrc/com/jetbrains/python/refactoring/PyInlineLocalTest.java index 993c0fd794b2..30e68e38ece0 100644 --- a/python/testSrc/com/jetbrains/python/refactoring/PyInlineLocalTest.java +++ b/python/testSrc/com/jetbrains/python/refactoring/PyInlineLocalTest.java @@ -145,6 +145,11 @@ public class PyInlineLocalTest extends PyTestCase { checkOperatorPrecedence("x = 10 if True else 2", "conditional"); } + // PY-15390 + public void testMatMulPrecedence() throws Exception { + checkOperatorPrecedence("x = y @ z", "matrixMultiplication"); + } + private void checkOperatorPrecedence(@NotNull final String firstLine, @NotNull String resultPrefix) throws Exception { myFixture.configureByFile("/refactoring/inlinelocal/operatorPrecedence/template.py"); WriteCommandAction.runWriteCommandAction(myFixture.getProject(), new Runnable() {