diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 40c90bc25e3c..ccecb2132643 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -2553,7 +2553,7 @@ object Parsers { */ def newExpr(): Tree = val start = in.skipToken() - def reposition(t: Tree) = t.withSpan(Span(start, in.lastOffset)) + def reposition(t: Tree) = t.withSpan(Span(start, in.lastCharOffset)) possibleTemplateStart() val parents = if in.isNestedStart then Nil diff --git a/tests/neg/i18265.check b/tests/neg/i18265.check new file mode 100644 index 000000000000..8f9df80f77dc --- /dev/null +++ b/tests/neg/i18265.check @@ -0,0 +1,6 @@ +-- [E019] Syntax Error: tests/neg/i18265.scala:5:13 ---------------------------- +5 | def twice + | ^ + | Missing return type + | + | longer explanation available when compiling with `-explain` \ No newline at end of file diff --git a/tests/neg/i18265.scala b/tests/neg/i18265.scala new file mode 100644 index 000000000000..e937a5203ecb --- /dev/null +++ b/tests/neg/i18265.scala @@ -0,0 +1,5 @@ +trait Foo + +val foo = new Foo: + extension (s: String) + def twice \ No newline at end of file