From 5936dcd3832d71df1aa0e1c73569d27f1d85ecab Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Sun, 9 Feb 2020 15:47:51 -0800 Subject: [PATCH] Fix line-ending empty interpolation Forward port fix from 2.11. Also fix position of interpolated parts from 2.10. --- compiler/src/dotty/tools/dotc/parsing/Scanners.scala | 11 ++++++++--- tests/pos/t7919.scala | 11 +++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 tests/pos/t7919.scala diff --git a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala index 5bedbb06375b..6593d90c4636 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala @@ -742,17 +742,22 @@ object Scanners { if (token == INTERPOLATIONID) { nextRawChar() if (ch == '\"') { - nextRawChar() - if (ch == '\"') { + if (lookaheadChar() == '\"') { + nextRawChar() + //offset += 3 // first part is positioned at the quote nextRawChar() stringPart(multiLine = true) } else { + nextChar() token = STRINGLIT strVal = "" } } - else stringPart(multiLine = false) + else { + //offset += 1 // first part is positioned at the quote + stringPart(multiLine = false) + } } else { nextChar() diff --git a/tests/pos/t7919.scala b/tests/pos/t7919.scala new file mode 100644 index 000000000000..220ab9e43002 --- /dev/null +++ b/tests/pos/t7919.scala @@ -0,0 +1,11 @@ + +object X { + val x = s"" + val y = true +} + +/* was: +4 | val y = true + | ^^^ + | end of statement expected but 'val' found +*/