Skip to content

Commit 4f937e1

Browse files
author
Abel Nieto
committed
Fix #1959: infix type operators in the REPL
Infix type operators were broken in the REPL. The REPL uses fold methods from the untpd package, but those were skipping the operator subtree when folding over an InfixOp. Fix the issue by taking the operator into account. Tested: 1) Verified that only the REPL code uses the modified fold method. 2) Added repl test.
1 parent a0c0b60 commit 4f937e1

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

compiler/src/dotty/tools/dotc/ast/untpd.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -526,11 +526,11 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
526526
case Function(args, body) =>
527527
this(this(x, args), body)
528528
case InfixOp(left, op, right) =>
529-
this(this(x, left), right)
529+
this(this(this(x, left), op), right)
530530
case PostfixOp(od, op) =>
531-
this(x, od)
531+
this(this(x, od), op)
532532
case PrefixOp(op, od) =>
533-
this(x, od)
533+
this(this(x, op), od)
534534
case Parens(t) =>
535535
this(x, t)
536536
case Tuple(trees) =>

tests/repl/infixTypeOp.check

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
scala> trait +[A, B]
2+
defined trait +
3+
scala> type IntAndString = Int + String
4+
defined type alias IntAndString
5+
scala> :quit

0 commit comments

Comments
 (0)