From 673f290395618e3d4a680f15b0517fd31dd76090 Mon Sep 17 00:00:00 2001 From: Matt Bovel Date: Tue, 8 Feb 2022 19:36:02 +0100 Subject: [PATCH] Revert "Use normal string escaping for f" This reverts commit 07d809fc12639ddc7030c4f94ed348a3a4f39665. --- compiler/src/dotty/tools/dotc/parsing/Scanners.scala | 2 +- compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala | 2 +- .../src/scala/quoted/runtime/impl/printers/SourceCode.scala | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala index 18f4f542b86c..1fee0f52f770 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala @@ -1253,7 +1253,7 @@ object Scanners { nextChar() } } - val alt = if oct == LF then raw"\n" else f"\\u$oct%04x" + val alt = if oct == LF then raw"\n" else f"${"\\"}u$oct%04x" error(s"octal escape literals are unsupported: use $alt instead", start) putChar(oct.toChar) } diff --git a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala index dd5d55b21f50..197a2e6ded9c 100644 --- a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala @@ -542,7 +542,7 @@ class PlainPrinter(_ctx: Context) extends Printer { case '"' => "\\\"" case '\'' => "\\\'" case '\\' => "\\\\" - case _ => if ch.isControl then f"\\u${ch.toInt}%04x" else String.valueOf(ch) + case _ => if (ch.isControl) f"${"\\"}u${ch.toInt}%04x" else String.valueOf(ch) } def toText(const: Constant): Text = const.tag match { diff --git a/compiler/src/scala/quoted/runtime/impl/printers/SourceCode.scala b/compiler/src/scala/quoted/runtime/impl/printers/SourceCode.scala index 88ee3e985277..b259b3f21b86 100644 --- a/compiler/src/scala/quoted/runtime/impl/printers/SourceCode.scala +++ b/compiler/src/scala/quoted/runtime/impl/printers/SourceCode.scala @@ -1423,7 +1423,7 @@ object SourceCode { case '"' => "\\\"" case '\'' => "\\\'" case '\\' => "\\\\" - case _ => if ch.isControl then f"\\u${ch.toInt}%04x" else String.valueOf(ch) + case _ => if (ch.isControl) f"${"\\"}u${ch.toInt}%04x" else String.valueOf(ch) } private def escapedString(str: String): String = str flatMap escapedChar