Skip to content

Commit 8a90b4d

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 8a90b4d

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ 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) =>
531531
this(x, od)
532532
case PrefixOp(op, od) =>

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)