Skip to content

Commit 1aaaca0

Browse files
committed
Make sure errorTermTrees have positions
Crashed the parser before, because errorTermTree did not have a position.
1 parent adb37ee commit 1aaaca0

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,8 @@ object Parsers {
269269
def acceptStatSepUnlessAtEnd(altEnd: Token = EOF) =
270270
if (!isStatSeqEnd && in.token != altEnd) acceptStatSep()
271271

272-
def errorTermTree = atPos(in.offset) { Literal(Constant(null)) }
272+
def errorTermTree =
273+
Literal(Constant(null)).withPos(Position(in.offset, in.offset))
273274

274275
private var inFunReturnType = false
275276
private def fromWithinReturnType[T](body: => T): T = {

tests/neg/i1705.scala

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
object DepBug {
2+
class A {
3+
class B
4+
def mkB = new B
5+
def m(b: B) = b
6+
}
7+
trait Dep {
8+
val a: A
9+
val b: a.B
10+
}
11+
val dep = new {
12+
val a = new A
13+
val b = a mkB
14+
}
15+
def useDep(d: Dep) { // error: procedure syntax
16+
import d._
17+
a m (b)
18+
}
19+
{ // error: Null does not take parameters (follow on)
20+
import dep._
21+
a m (b)
22+
}
23+
dep.a m (dep b) // error (follow on)
24+
}

0 commit comments

Comments
 (0)