Skip to content

Commit 4f6f252

Browse files
committed
Revert eager use of escape in interpolator
1 parent 9f17663 commit 4f6f252

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,7 @@ object Scanners {
12531253
nextChar()
12541254
}
12551255
}
1256-
val alt = if oct == LF then raw"\n" else f"\\u$oct%04x"
1256+
val alt = if oct == LF then raw"\n" else f"${"\\"}u$oct%04x"
12571257
error(s"octal escape literals are unsupported: use $alt instead", start)
12581258
putChar(oct.toChar)
12591259
}

compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ class PlainPrinter(_ctx: Context) extends Printer {
542542
case '"' => "\\\""
543543
case '\'' => "\\\'"
544544
case '\\' => "\\\\"
545-
case _ => if ch.isControl then f"\\u${ch.toInt}%04x" else String.valueOf(ch)
545+
case _ => if ch.isControl then f"${"\\"}u${ch.toInt}%04x" else String.valueOf(ch)
546546
}
547547

548548
def toText(const: Constant): Text = const.tag match {

compiler/src/scala/quoted/runtime/impl/printers/SourceCode.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1423,7 +1423,7 @@ object SourceCode {
14231423
case '"' => "\\\""
14241424
case '\'' => "\\\'"
14251425
case '\\' => "\\\\"
1426-
case _ => if ch.isControl then f"\\u${ch.toInt}%04x" else String.valueOf(ch)
1426+
case _ => if ch.isControl then f"${"\\"}u${ch.toInt}%04x" else String.valueOf(ch)
14271427
}
14281428

14291429
private def escapedString(str: String): String = str flatMap escapedChar

0 commit comments

Comments
 (0)