From 40d493580bfed7d59f1802d0d45c56cee97e466d Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Thu, 29 Oct 2015 09:50:19 +0100 Subject: Set position on annotations parsed from Java Fix a crash in Typer#assertPositioned --- src/dotty/tools/dotc/parsing/JavaParsers.scala | 2 +- tests/pos/java-interop/volatile/volatile.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 tests/pos/java-interop/volatile/volatile.java diff --git a/src/dotty/tools/dotc/parsing/JavaParsers.scala b/src/dotty/tools/dotc/parsing/JavaParsers.scala index 297f3c0f9..7b9d29ce3 100644 --- a/src/dotty/tools/dotc/parsing/JavaParsers.scala +++ b/src/dotty/tools/dotc/parsing/JavaParsers.scala @@ -356,7 +356,7 @@ object JavaParsers { // assumed true unless we see public/private/protected var isPackageAccess = true var annots: List[Tree] = Nil - def addAnnot(sym: ClassSymbol) = annots :+= New(TypeTree(sym.typeRef)) + def addAnnot(sym: ClassSymbol) = annots :+= New(TypeTree(sym.typeRef)).withPos(Position(in.offset)) while (true) { in.token match { diff --git a/tests/pos/java-interop/volatile/volatile.java b/tests/pos/java-interop/volatile/volatile.java new file mode 100644 index 000000000..c6a607b4d --- /dev/null +++ b/tests/pos/java-interop/volatile/volatile.java @@ -0,0 +1,3 @@ +public class Foo { + volatile int x = 1; +} -- cgit v1.2.3