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

Commit

Permalink
Scala 3: groupExplicitlyImportedImplicitsSeparately has no effect
Browse files Browse the repository at this point in the history
  • Loading branch information
github-brice-jaglin committed Jun 24, 2021
1 parent af681b4 commit dbab6b1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
10 changes: 9 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ Known limitations:
. The <<removeUnused, `removeUnused`>> 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 <<groupExplicitlyImportedImplicitsSeparately, groupExplicitlyImportedImplicitsSeparately>> option has no effect

== Configuration

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -483,7 +491,7 @@ Configuration:
----
OrganizeImports {
groups = ["scala.", "*"]
groupExplicitlyImportedImplicitsSeparately = true
groupExplicitlyImportedImplicitsSeparately = true // not supported in Scala 3
}
----

Expand Down
3 changes: 3 additions & 0 deletions rules/src/main/scala/fix/OrganizeImports.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dbab6b1

Please sign in to comment.