From 08774c8ac2dff599e29a59d69431453e7023b2e8 Mon Sep 17 00:00:00 2001 From: Olivier Blanvillain Date: Thu, 16 Nov 2017 15:29:14 +0100 Subject: [PATCH 1/2] Fix MatchError: InfixOp on TreeAccumulator In case of errors it may be that typed trees point to untyped ones. I think it makes sense to avoid the MatchError in that case, not only in Interative mode. --- compiler/src/dotty/tools/dotc/ast/Trees.scala | 2 +- tests/neg/i3487.scala | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 tests/neg/i3487.scala diff --git a/compiler/src/dotty/tools/dotc/ast/Trees.scala b/compiler/src/dotty/tools/dotc/ast/Trees.scala index 8ae79347fc0f..4d142a59d905 100644 --- a/compiler/src/dotty/tools/dotc/ast/Trees.scala +++ b/compiler/src/dotty/tools/dotc/ast/Trees.scala @@ -1325,7 +1325,7 @@ object Trees { this(this(x, arg), annot) case Thicket(ts) => this(x, ts) - case _ if ctx.mode.is(Mode.Interactive) => + case _ => // In case of errors it may be that typed trees point to untyped ones. // The IDE can still traverse inside such trees, either in the run where errors // are reported, or in subsequent ones. diff --git a/tests/neg/i3487.scala b/tests/neg/i3487.scala new file mode 100644 index 000000000000..8a28100c66d2 --- /dev/null +++ b/tests/neg/i3487.scala @@ -0,0 +1,4 @@ +object Test { + type &:[H, T] = Int + val a: F[Int] { type X = Int &: String } = ??? // error +} From bfd425f61704b2c5d0c6071253931b79a308ade7 Mon Sep 17 00:00:00 2001 From: Olivier Blanvillain Date: Fri, 26 Jan 2018 16:11:54 +0100 Subject: [PATCH 2/2] Address review --- compiler/src/dotty/tools/dotc/ast/Trees.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/ast/Trees.scala b/compiler/src/dotty/tools/dotc/ast/Trees.scala index 4d142a59d905..0c8972fff871 100644 --- a/compiler/src/dotty/tools/dotc/ast/Trees.scala +++ b/compiler/src/dotty/tools/dotc/ast/Trees.scala @@ -1325,7 +1325,8 @@ object Trees { this(this(x, arg), annot) case Thicket(ts) => this(x, ts) - case _ => + case _ if ctx.reporter.errorsReported || ctx.mode.is(Mode.Interactive) => + // In interactive mode, errors might come from previous runs. // In case of errors it may be that typed trees point to untyped ones. // The IDE can still traverse inside such trees, either in the run where errors // are reported, or in subsequent ones.