First, we installed a complete and verifiable example:
precedencegroup LongArrowPrecedence { associativity: left higherThan: AssignmentPrecedence } infix operator --> : LongArrowPrecedence func -->(lhs: Int, rhs: Int) -> (() -> ()) -> () { return { print(lhs+rhs, terminator: ""); $0() } }
As well as examples of real calls covered by the parentes using this operator, immediately after that there is a closure call that returns --> .
let foo = 1 let bar = 2
This does not tell us much, but if we study the following unsuccessful cases
// ERROR: cannot call value of non-function type 'Int' foo
We understand that the problem here is not “priority below closure”, but rather that the call-argument-sentence-function (a set of brackets after any postfix expression) will try to call this postfix expression as if the postfix expression was / function / closure. If the postfix expression is not callable, or if the call inside the argument function-call-argument does not match the overload of the callable, then the compiler will throw an error.
42() // ERROR: cannot call value of non-function type 'Int' let foo = 42 foo() // ERROR: cannot call value of non-function type 'Int' func bar() {} // ERROR: argument passed to call that takes no arguments bar(42)
Therefore, the trailing closure delivered to the closure returned from --> does not matter here: it is just an argument of the returned closure, while the key problem is that Swift will use the function-call-argument-to postfix-expression clause immediately preceding the offer. In your example, bar represents this postfix expression, and only if you end foo --> bar in parantheses, the combined wrapped expression will be a postfix expression on which the following function-call-argument clause will be applied.
Postfix Expressions
Postfix expressions are generated by using the postfix operator or other postfix expression syntax. Syntactically, each expression is also a postfix expression.
Basic expressions
Primary expressions are the most basic form of expression. They can be used as expressions on their own, and they can be combined with other tokens to create prefix expressions, binary expressions, and postfix expressions.
You will not be able to get around this because the priority of the statement does not apply to the function-call-argument-clause clause; the latter (and its "priority") is determined by the grammar of the function call expression.