Skip to content

Commit 48413b4

Browse files
committed
SI-7919 Newline after empty string interp
Consume the newline non-raw for safe handling after single-line interpolation.
1 parent b75a84b commit 48413b4

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/compiler/scala/tools/nsc/ast/parser/Scanners.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,14 +475,17 @@ trait Scanners extends ScannersCommon {
475475
if (token == INTERPOLATIONID) {
476476
nextRawChar()
477477
if (ch == '\"') {
478-
nextRawChar()
479-
if (ch == '\"') {
478+
val lookahead = lookaheadReader
479+
lookahead.nextChar()
480+
if (lookahead.ch == '\"') {
481+
nextRawChar() // now eat it
480482
offset += 3
481483
nextRawChar()
482484
getStringPart(multiLine = true)
483485
sepRegions = STRINGPART :: sepRegions // indicate string part
484486
sepRegions = STRINGLIT :: sepRegions // once more to indicate multi line string part
485487
} else {
488+
nextChar()
486489
token = STRINGLIT
487490
strVal = ""
488491
}

test/files/pos/t7919.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
object X {
3+
val x = s""
4+
val y = true
5+
}
6+

0 commit comments

Comments
 (0)