Skip to content

Commit

Permalink
allow $ escaping double quotes in interpolations
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnhoekstra committed Mar 8, 2021
1 parent 262f6e9 commit 51e25c5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
Expand Up @@ -912,7 +912,7 @@ trait Scanners extends ScannersCommon {
}
} else if (ch == '$') {
nextRawChar()
if (ch == '$') {
if (ch == '$' || (currentRun.isScala3 && ch == '"')) {
putChar(ch)
nextRawChar()
getStringPart(multiLine)
Expand All @@ -938,7 +938,10 @@ trait Scanners extends ScannersCommon {
next.token = kwArray(idx)
}
} else {
syntaxError(s"invalid string interpolation $$$ch, expected: $$$$, $$identifier or $${expression}")
val expectations =
if (currentRun.isScala3) "$$, $\", $identifier or ${expression}"
else "$$, $identifier or ${expression}"
syntaxError(s"invalid string interpolation $$$ch, expected: $expectations")
}
} else {
val isUnclosedLiteral = (ch == SU || (!multiLine && (ch == CR || ch == LF)))
Expand Down

0 comments on commit 51e25c5

Please sign in to comment.