Skip to content

Commit

Permalink
Merge pull request #1618 from gontard/redundantsyntax_fix
Browse files Browse the repository at this point in the history
Fix RedundantSyntax raw interpolator handling
  • Loading branch information
bjaglin authored Jun 11, 2022
2 parents 59ed8c0 + 20dcbb1 commit 57042bd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ 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"

implicit class MyInterpolator(sc: StringContext) {
def my(subs: Any*): String = sc.toString + subs.mkString("")
}
}
}

0 comments on commit 57042bd

Please sign in to comment.