Skip to content

Commit 0c84876

Browse files
authored
Merge pull request scala#9783 from lrytz/formatted
Deprecate anyVal.formatted(formatString)
2 parents 7413b09 + 6013cd3 commit 0c84876

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

src/compiler/scala/tools/ant/sabbus/Compilers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ object Compilers extends scala.collection.DefaultMap[String, Compiler] {
4545
}
4646

4747
private def freeMemoryString: String =
48-
(Runtime.getRuntime.freeMemory/1048576.0).formatted("%10.2f") + " MB"
48+
f"${Runtime.getRuntime.freeMemory/1048576.0}%10.2f MB"
4949
}

src/library/scala/Predef.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ object Predef extends LowPriorityImplicits with DeprecatedPredef {
327327
* Format strings are as for `String.format`
328328
* (@see java.lang.String.format).
329329
*/
330+
@deprecated("Use `formatString.format(value)` instead of `value.formatted(formatString)`,\nor use the `f\"\"` string interpolator. In Java 15 and later, `formatted` resolves to the new method in String which has reversed parameters.", "2.12.16")
330331
@inline def formatted(fmtstr: String): String = fmtstr format self
331332
}
332333

src/reflect/scala/reflect/internal/util/ChromeTrace.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ final class ChromeTrace(f: Path) extends Closeable {
4343
private val traceWriter = FileUtils.newAsyncBufferedWriter(f)
4444
private val context = mutable.ArrayStack[JsonContext](TopContext)
4545
private val tidCache = new ThreadLocal[String]() {
46-
override def initialValue(): String = Thread.currentThread().getId.formatted("%05d")
46+
override def initialValue(): String = f"${Thread.currentThread().getId}%05d"
4747
}
4848
objStart()
4949
fld("traceEvents")

0 commit comments

Comments
 (0)