@@ -984,6 +984,13 @@ object Parsers {
984984 recur(top)
985985 }
986986
987+ /** True if we are seeing a lambda argument after a colon of the form:
988+ * : (params) =>
989+ * body
990+ */
991+ def isColonLambda =
992+ in.fewerBracesEnabled && in.token == COLONfollow && followingIsLambdaAfterColon()
993+
987994 /** operand { infixop operand | MatchClause } [postfixop],
988995 *
989996 * respecting rules of associativity and precedence.
@@ -998,24 +1005,25 @@ object Parsers {
9981005 val base = opStack
9991006
10001007 def recur (top : Tree ): Tree =
1001- val isType = kind == ParseKind .Type
1002- if (isIdent && isOperator) {
1008+ def isType = kind == ParseKind .Type
1009+ def maybePostfix = kind == ParseKind .Expr && in.postfixOpsEnabled
1010+ if isIdent && isOperator then
10031011 val op = if isType then typeIdent() else termIdent()
10041012 val top1 = reduceStack(base, top, precedence(op.name), ! op.name.isRightAssocOperatorName, op.name, isType)
10051013 opStack = OpInfo (top1, op, in.offset) :: opStack
10061014 colonAtEOLOpt()
10071015 newLineOptWhenFollowing(canStartOperand)
1008- val maybePostfix = kind == ParseKind .Expr && in.postfixOpsEnabled
1009- if (maybePostfix && ! canStartOperand(in.token)) {
1016+ if isColonLambda then
1017+ in.nextToken()
1018+ recur(expr(Location .InColonArg ))
1019+ else if maybePostfix && ! canStartOperand(in.token) then
10101020 val topInfo = opStack.head
10111021 opStack = opStack.tail
10121022 val od = reduceStack(base, topInfo.operand, 0 , true , in.name, isType)
10131023 atSpan(startOffset(od), topInfo.offset) {
10141024 PostfixOp (od, topInfo.operator)
10151025 }
1016- }
10171026 else recur(operand(location))
1018- }
10191027 else
10201028 val t = reduceStack(base, top, minPrec, leftAssoc = true , in.name, isType)
10211029 if ! isType && in.token == MATCH then recurAtMinPrec(matchClause(t))
@@ -2399,7 +2407,7 @@ object Parsers {
23992407 makeParameter(name.asTermName, typedOpt(), Modifiers (), isBackquoted = isBackquoted(id))
24002408 }
24012409 case _ => t
2402- else if in.fewerBracesEnabled && in.token == COLONfollow && followingIsLambdaAfterColon() then
2410+ else if isColonLambda then
24032411 val app = atSpan(startOffset(t), in.skipToken()) {
24042412 Apply (t, expr(Location .InColonArg ) :: Nil )
24052413 }
0 commit comments