After some inspection in the Scala specification, I think I can give it a shot.
If I am wrong please correct me.
first, an if
or match
are defined as Expr
- expressions.
You are trying to create an infix expression (defined by the use of the operator between two expressions)
However the especification (section 3.2.8) states that :
All type infix operators have the same precedence; parentheses have to
be used for grouping
It also also states that:
In a sequence of consecutive type infix operations t0 op1 t1 op2 . .
.opn tn, all operators op1, . . . , opn must have the same
associativity. If they are all left-associative, the sequence is
interpreted as (. . . (t0 op1 t1) op2 . . .) opn tn.
So my take is that Scala does not know what to reduce first: the match or the method '+' invocation.
Take a look at this answer
Please correct me if I am wrong.