Back to Intellij Community

CanUnescapeDollarLiteral

plugins/kotlin/code-insight/descriptions/resources-en/inspectionDescriptions/CanUnescapeDollarLiteral.html

2025.3-rc-2508 B
Original Source

Reports that escaped dollar characters in a string can be replaced with regular literals.

Escaping is only necessary when string content after dollar can be misinterpreted as a string interpolation entry.

Example:

fun example() {
    "The price today is \$10. The price tomorrow will be ${'$'}20."
  }

The quick fix converts all safely replaceable escaped dollar characters to regular dollar characters:

fun example() {
    "The price today is $10. The price tomorrow will be $20."
  }