@@ -452,7 +452,7 @@ object Parsers {
452
452
if (isLeftAssoc(op1) != op2LeftAssoc)
453
453
syntaxError(MixedLeftAndRightAssociativeOps (op1, op2, op2LeftAssoc), offset)
454
454
455
- def reduceStack (base : List [OpInfo ], top : Tree , prec : Int , leftAssoc : Boolean , op2 : Name ): Tree = {
455
+ def reduceStack (base : List [OpInfo ], top : Tree , prec : Int , leftAssoc : Boolean , op2 : Name , isType : Boolean ): Tree = {
456
456
if (opStack != base && precedence(opStack.head.operator.name) == prec)
457
457
checkAssoc(opStack.head.offset, opStack.head.operator.name, op2, leftAssoc)
458
458
def recur (top : Tree ): Tree = {
@@ -464,7 +464,15 @@ object Parsers {
464
464
opStack = opStack.tail
465
465
recur {
466
466
atPos(opInfo.operator.pos union opInfo.operand.pos union top.pos) {
467
- InfixOp (opInfo.operand, opInfo.operator, top)
467
+ val op = opInfo.operator
468
+ val l = opInfo.operand
469
+ val r = top
470
+ if (isType && ! op.isBackquoted && op.name == tpnme.raw.BAR ) {
471
+ OrTypeTree (l, r)
472
+ } else if (isType && ! op.isBackquoted && op.name == tpnme.raw.AMP ) {
473
+ AndTypeTree (l, r)
474
+ } else
475
+ InfixOp (l, op, r)
468
476
}
469
477
}
470
478
}
@@ -488,20 +496,20 @@ object Parsers {
488
496
var top = first
489
497
while (isIdent && isOperator) {
490
498
val op = if (isType) typeIdent() else termIdent()
491
- top = reduceStack(base, top, precedence(op.name), isLeftAssoc(op.name), op.name)
499
+ top = reduceStack(base, top, precedence(op.name), isLeftAssoc(op.name), op.name, isType )
492
500
opStack = OpInfo (top, op, in.offset) :: opStack
493
501
newLineOptWhenFollowing(canStartOperand)
494
502
if (maybePostfix && ! canStartOperand(in.token)) {
495
503
val topInfo = opStack.head
496
504
opStack = opStack.tail
497
- val od = reduceStack(base, topInfo.operand, 0 , true , in.name)
505
+ val od = reduceStack(base, topInfo.operand, 0 , true , in.name, isType )
498
506
return atPos(startOffset(od), topInfo.offset) {
499
507
PostfixOp (od, topInfo.operator)
500
508
}
501
509
}
502
510
top = operand()
503
511
}
504
- reduceStack(base, top, 0 , true , in.name)
512
+ reduceStack(base, top, 0 , true , in.name, isType )
505
513
}
506
514
507
515
/* -------- IDENTIFIERS AND LITERALS ------------------------------------------- */
0 commit comments