From dbab6b1c208df1b61e4b7f7a12aa7c72794fcbaf Mon Sep 17 00:00:00 2001 From: Brice Jaglin Date: Fri, 25 Jun 2021 01:33:10 +0200 Subject: [PATCH] Scala 3: groupExplicitlyImportedImplicitsSeparately has no effect --- README.adoc | 10 +++++++++- .../fix/ExplicitlyImportedImplicits.scala | 0 rules/src/main/scala/fix/OrganizeImports.scala | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) rename input/src/main/{scala => scala-2}/fix/ExplicitlyImportedImplicits.scala (100%) diff --git a/README.adoc b/README.adoc index 4fbf8b5..cc44b94 100644 --- a/README.adoc +++ b/README.adoc @@ -91,6 +91,7 @@ Known limitations: . The <> option must be explicitly set to `false` . Source files using new syntax introduced in Scala 3 such as https://docs.scala-lang.org/scala3/book/ca-given-imports.html[`given` imports] may not work properly . Usage of http://dotty.epfl.ch/docs/reference/dropped-features/package-objects.html[deprecated package objects] may result in incorrect imports +. The <> option has no effect == Configuration @@ -455,6 +456,13 @@ Unfortunately, Scalafix is not able to surgically identify conflicting implicit CAUTION: In general, order-sensitive imports are fragile, and can easily be broken by either human collaborators or tools (e.g., the IntelliJ IDEA Scala import optimizer does not handle this case correctly). They should be eliminated whenever possible. This option is mostly useful when you are dealing with a large trunk of legacy codebase, and you want to minimize manual intervention and guarantee correctness in all cases. + +[IMPORTANT] +==== +The `groupExplicitlyImportedImplicitsSeparately` option has currently no effect on source files compiled with Scala 3, as the https://github.com/lampepfl/dotty/issues/12766[compiler does not expose full signature information], preventing the rule to identify imported implicits. +==== + + ==== Value type Boolean @@ -483,7 +491,7 @@ Configuration: ---- OrganizeImports { groups = ["scala.", "*"] - groupExplicitlyImportedImplicitsSeparately = true + groupExplicitlyImportedImplicitsSeparately = true // not supported in Scala 3 } ---- diff --git a/input/src/main/scala/fix/ExplicitlyImportedImplicits.scala b/input/src/main/scala-2/fix/ExplicitlyImportedImplicits.scala similarity index 100% rename from input/src/main/scala/fix/ExplicitlyImportedImplicits.scala rename to input/src/main/scala-2/fix/ExplicitlyImportedImplicits.scala diff --git a/rules/src/main/scala/fix/OrganizeImports.scala b/rules/src/main/scala/fix/OrganizeImports.scala index 381d8c9..9b10712 100644 --- a/rules/src/main/scala/fix/OrganizeImports.scala +++ b/rules/src/main/scala/fix/OrganizeImports.scala @@ -181,6 +181,9 @@ class OrganizeImports(config: OrganizeImportsConfig) extends SemanticRule("Organ )(implicit doc: SemanticDocument): (Seq[Importer], Seq[Importer]) = { val (implicits, implicitPositions) = importers.flatMap { case importer @ Importer(_, importees) => + importees.foreach { i => + println(i.symbol.info) + } importees collect { case i: Importee.Name if i.symbol.infoNoThrow exists (_.isImplicit) => importer.copy(importees = i :: Nil) -> i.pos