aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbel Nieto <abeln@google.com>2017-03-31 09:14:27 -0400
committerAbel Nieto <abeln@google.com>2017-04-02 12:50:19 -0400
commit4f937e1735574ffda679761a0a9a8bebbe9cb2ae (patch)
tree226fc4a47ca029d847cd310752f2f532494a1a8c
parenta0c0b605110980abb5d993dadcc943d148e8e262 (diff)
downloaddotty-4f937e1735574ffda679761a0a9a8bebbe9cb2ae.tar.gz
dotty-4f937e1735574ffda679761a0a9a8bebbe9cb2ae.tar.bz2
dotty-4f937e1735574ffda679761a0a9a8bebbe9cb2ae.zip
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.
-rw-r--r--compiler/src/dotty/tools/dotc/ast/untpd.scala6
-rw-r--r--tests/repl/infixTypeOp.check5
2 files changed, 8 insertions, 3 deletions
diff --git a/compiler/src/dotty/tools/dotc/ast/untpd.scala b/compiler/src/dotty/tools/dotc/ast/untpd.scala
index 8ca91590f..c253af852 100644
--- a/compiler/src/dotty/tools/dotc/ast/untpd.scala
+++ b/compiler/src/dotty/tools/dotc/ast/untpd.scala
@@ -526,11 +526,11 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
case Function(args, body) =>
this(this(x, args), body)
case InfixOp(left, op, right) =>
- this(this(x, left), right)
+ this(this(this(x, left), op), right)
case PostfixOp(od, op) =>
- this(x, od)
+ this(this(x, od), op)
case PrefixOp(op, od) =>
- this(x, od)
+ this(this(x, op), od)
case Parens(t) =>
this(x, t)
case Tuple(trees) =>
diff --git a/tests/repl/infixTypeOp.check b/tests/repl/infixTypeOp.check
new file mode 100644
index 000000000..fe8e453fb
--- /dev/null
+++ b/tests/repl/infixTypeOp.check
@@ -0,0 +1,5 @@
+scala> trait +[A, B]
+defined trait +
+scala> type IntAndString = Int + String
+defined type alias IntAndString
+scala> :quit