All this talk about recursive function and type is a red herring. Scala grammar does not allow postfix operators anywhere except at the end of an expression. This is the grammar we are talking about: the syntax of things without any semantics. Here is the relevant grammar from the specifications:
Expr ::= (Bindings | [βimplicitβ] id | β_β) β=>β Expr
| Expr1
Expr1 ::= βifβ β(β Expr β)β {nl} Expr [[semi] else Expr]
| βwhileβ β(β Expr β)β {nl} Expr
| βtryβ β{β Block β}β [βcatchβ β{β CaseClauses β}β]
[βfinallyβ Expr]
| βdoβ Expr [semi] βwhileβ β(β Expr β)β
| βforβ (β(β Enumerators β)β | β{β Enumerators β}β)
| {nl} [βyieldβ] Expr
| βthrowβ Expr
| βreturnβ [Expr]
| [SimpleExpr β.β] id β=β Expr
| SimpleExpr1 ArgumentExprs β=β Expr
| PostfixExpr
| PostfixExpr Ascription
| PostfixExpr βmatchβ β{β CaseClauses β}β
PostfixExpr ::= InfixExpr [id [nl]]
, PostfixExpr , if case : _* . , , , , , - match.
, ? , , , . BlockStat a Block, , .
, , -, . :
val aFact = a!
println("factorial of " + a + " is " + aFact)
:
val id = id id
id ( stringLit id id id stringLit id id )
:
val id = id id id ( expr )
val Pattern2 = SimpleExpr1 id SimpleExpr1 ArgumentExprs
val Pattern2 = InfixExpr
val Pattern2 = Expr
val PatDef
PatVarDef
Def
BlockStat
, infix , . , , , , .