From 8c6231acb5e24f1cccee5f4f366098f0d465712a Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 18 Mar 2019 11:53:29 +0100 Subject: [PATCH] Fix #6035: Make sure assigned positions in Parser contain child positions --- compiler/src/dotty/tools/dotc/parsing/Parsers.scala | 2 +- tests/neg/i6035.scala | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 tests/neg/i6035.scala diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index ad5d39291536..43215258f8a3 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -80,7 +80,7 @@ object Parsers { * If `t` does not have a span yet, set its span to the given one. */ def atSpan[T <: Positioned](span: Span)(t: T): T = - if (t.span.isSourceDerived) t else t.withSpan(span) + if (t.span.isSourceDerived) t else t.withSpan(span.union(t.span)) def atSpan[T <: Positioned](start: Offset, point: Offset, end: Offset)(t: T): T = atSpan(Span(start, end, point))(t) diff --git a/tests/neg/i6035.scala b/tests/neg/i6035.scala new file mode 100644 index 000000000000..c2d70f8cac3b --- /dev/null +++ b/tests/neg/i6035.scala @@ -0,0 +1 @@ +type i1 <: i1 = ; } // error // error