From 515388de7d0acb2b82718a437617dd1ea9035e54 Mon Sep 17 00:00:00 2001 From: Brice Jaglin Date: Sat, 28 Oct 2023 23:01:52 +0200 Subject: [PATCH] better support of backquoted identifiers in SymbolMatcher --- .../main/scala/scalafix/internal/util/SymbolOps.scala | 9 ++++++--- .../scala/scalafix/tests/v1/SymbolMatcherSuite.scala | 9 +++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/scalafix-core/src/main/scala/scalafix/internal/util/SymbolOps.scala b/scalafix-core/src/main/scala/scalafix/internal/util/SymbolOps.scala index 52eea0b46..3f047b9c0 100644 --- a/scalafix-core/src/main/scala/scalafix/internal/util/SymbolOps.scala +++ b/scalafix-core/src/main/scala/scalafix/internal/util/SymbolOps.scala @@ -98,7 +98,10 @@ object SymbolOps { } def inferTrailingDot(symbol: String): String = - if (symbol.isEmpty) symbol - else if (Character.isJavaIdentifierPart(symbol.last)) symbol + "." - else symbol + if (symbol.isEmpty) + symbol + else if (Character.isJavaIdentifierPart(symbol.last) || symbol.last == '`') + symbol + "." + else + symbol } diff --git a/scalafix-tests/integration/src/test/scala/scalafix/tests/v1/SymbolMatcherSuite.scala b/scalafix-tests/integration/src/test/scala/scalafix/tests/v1/SymbolMatcherSuite.scala index 79e4716a5..3bfc59860 100644 --- a/scalafix-tests/integration/src/test/scala/scalafix/tests/v1/SymbolMatcherSuite.scala +++ b/scalafix-tests/integration/src/test/scala/scalafix/tests/v1/SymbolMatcherSuite.scala @@ -46,6 +46,15 @@ class SymbolMatcherSuite extends AnyFunSuite { assert(map.matches(Symbol("scala/Option#map(+1).")), sym) assert(map.matches(Symbol("scala/Option.map(+1).")), sym) } + + List( + "scala.Int.`+`", + "scala.Int.`+`#", + "scala.Int.`+`." + ).foreach { sym => + val option = SymbolMatcher.normalized(sym) + assert(option.matches(Symbol("scala/Int#`+`(+4).")), sym) + } } test("matches/unapply") {