Skip to content
This repository has been archived by the owner on Jul 14, 2023. It is now read-only.

Identifiers are not escaped after merging #167

Closed
nigredo-tori opened this issue Apr 19, 2021 · 2 comments
Closed

Identifiers are not escaped after merging #167

nigredo-tori opened this issue Apr 19, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@nigredo-tori
Copy link

Config:

OrganizeImports {
  groupedImports = Merge
}

Input:

import org.http4s.headers.`Cache-Control`
import org.http4s.headers.Location

Output (note the lack of backticks):

import org.http4s.headers.{Cache-Control, Location}

Tested with OrganizeImports 0.4.0 and 0.5.0.

@liancheng liancheng added the bug Something isn't working label Apr 19, 2021
@liancheng
Copy link
Owner

liancheng commented Apr 19, 2021

@nigredo-tori, Scalafix 0.9.26 had a regression and may cause this issue. See scalacenter/scalafix#1337 and scalameta/scalameta#2260. Any chance that you are using Scalafix 0.9.26+?

I added the following test changes to master but could not reproduce this issue:

diff --git a/input/src/main/scala/fix/GroupedImportsMerge.scala b/input/src/main/scala/fix/GroupedImportsMerge.scala
index 4c4ca03..57ab0c4 100644
--- a/input/src/main/scala/fix/GroupedImportsMerge.scala
+++ b/input/src/main/scala/fix/GroupedImportsMerge.scala
@@ -4,8 +4,13 @@ OrganizeImports.groupedImports = Merge
  */
 package fix
 
+import fix.GroupedImportsMerge.`a->b`
+import fix.GroupedImportsMerge.`b->c`
 import scala.collection.mutable.Buffer
 import scala.collection.mutable.StringBuilder
 import scala.collection.mutable.ArrayBuffer
 
-object GroupedImportsMerge
+object GroupedImportsMerge {
+  val `a->b` = ???
+  val `b->c` = ???
+}
diff --git a/output/src/main/scala/fix/GroupedImportsMerge.scala b/output/src/main/scala/fix/GroupedImportsMerge.scala
index f7cac59..0bffd9a 100644
--- a/output/src/main/scala/fix/GroupedImportsMerge.scala
+++ b/output/src/main/scala/fix/GroupedImportsMerge.scala
@@ -1,5 +1,10 @@
 package fix
 
+import fix.GroupedImportsMerge.{`a->b`, `b->c`}
+
 import scala.collection.mutable.{ArrayBuffer, Buffer, StringBuilder}
 
-object GroupedImportsMerge
+object GroupedImportsMerge {
+  val `a->b` = ???
+  val `b->c` = ???
+}

@nigredo-tori
Copy link
Author

I was using Scalafix 0.9.19 in my project.

The thing is, when running scalafix via SBT I actually don't get this error. This only happens when I run the corresponding task in Metals. So it seems like Metals uses a buggy scalafix version (0.9.27 FWICT).

Thank you. Sorry for not minimizing the issue before posting.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants