diff --git a/scalafix-rules/src/main/scala/scalafix/internal/rule/RedundantSyntax.scala b/scalafix-rules/src/main/scala/scalafix/internal/rule/RedundantSyntax.scala index 807223a62..4e07d04c5 100644 --- a/scalafix-rules/src/main/scala/scalafix/internal/rule/RedundantSyntax.scala +++ b/scalafix-rules/src/main/scala/scalafix/internal/rule/RedundantSyntax.scala @@ -35,8 +35,7 @@ class RedundantSyntax(config: RedundantSyntaxConfig) Nil ) if config.stringInterpolator - && (p == "s" || p == "f" || (p == "raw" && StringContext - .processEscapes(v) == v)) => + && (p == "s" || p == "f" || (p == "raw" && !v.contains('\\'))) => Patch.removeTokens(interpolator.prefix.tokens) }.asPatch } diff --git a/scalafix-tests/input/src/main/scala/test/redundantSyntax/StringInterpolator.scala b/scalafix-tests/input/src/main/scala/test/redundantSyntax/StringInterpolator.scala index 6b36a3542..6a06f5cd1 100644 --- a/scalafix-tests/input/src/main/scala/test/redundantSyntax/StringInterpolator.scala +++ b/scalafix-tests/input/src/main/scala/test/redundantSyntax/StringInterpolator.scala @@ -27,6 +27,7 @@ class StringInterpolator { b = raw"foo $a \nbar" b = raw"foo\nbar\\" b = raw"foo bar" + b = raw"a\*b\+" b = my"foo" b = my"foo $a bar" diff --git a/scalafix-tests/output/src/main/scala/test/redundantSyntax/StringInterpolator.scala b/scalafix-tests/output/src/main/scala/test/redundantSyntax/StringInterpolator.scala index 997b921a2..a9a998550 100644 --- a/scalafix-tests/output/src/main/scala/test/redundantSyntax/StringInterpolator.scala +++ b/scalafix-tests/output/src/main/scala/test/redundantSyntax/StringInterpolator.scala @@ -22,6 +22,7 @@ class StringInterpolator { b = raw"foo $a \nbar" b = raw"foo\nbar\\" b = "foo bar" + b = raw"a\*b\+" b = my"foo" b = my"foo $a bar" @@ -29,4 +30,4 @@ class StringInterpolator { implicit class MyInterpolator(sc: StringContext) { def my(subs: Any*): String = sc.toString + subs.mkString("") } -} \ No newline at end of file +}