Skip to content

Commit 5936dcd

Browse files
committed
Fix line-ending empty interpolation
Forward port fix from 2.11. Also fix position of interpolated parts from 2.10.
1 parent 25cdd9e commit 5936dcd

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

compiler/src/dotty/tools/dotc/parsing/Scanners.scala

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -742,17 +742,22 @@ object Scanners {
742742
if (token == INTERPOLATIONID) {
743743
nextRawChar()
744744
if (ch == '\"') {
745-
nextRawChar()
746-
if (ch == '\"') {
745+
if (lookaheadChar() == '\"') {
746+
nextRawChar()
747+
//offset += 3 // first part is positioned at the quote
747748
nextRawChar()
748749
stringPart(multiLine = true)
749750
}
750751
else {
752+
nextChar()
751753
token = STRINGLIT
752754
strVal = ""
753755
}
754756
}
755-
else stringPart(multiLine = false)
757+
else {
758+
//offset += 1 // first part is positioned at the quote
759+
stringPart(multiLine = false)
760+
}
756761
}
757762
else {
758763
nextChar()

tests/pos/t7919.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
object X {
3+
val x = s""
4+
val y = true
5+
}
6+
7+
/* was:
8+
4 | val y = true
9+
| ^^^
10+
| end of statement expected but 'val' found
11+
*/

0 commit comments

Comments
 (0)