Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asterisk to underscore replacement when organizing imports in Scala 3 #6359

Closed
DLakomy opened this issue Apr 28, 2024 · 2 comments · Fixed by #6389
Closed

Asterisk to underscore replacement when organizing imports in Scala 3 #6359

DLakomy opened this issue Apr 28, 2024 · 2 comments · Fixed by #6389
Assignees
Labels
improvement Not a bug or a feature, but something general we can improve
Milestone

Comments

@DLakomy
Copy link

DLakomy commented Apr 28, 2024

Steps to reproduce:

  1. Create a project by sbt new scala/scala3.g8
  2. Change the main.scala contents to this (the important thing is to add some unsorted imports):
import java.util.concurrent.*
import java.util.*

@main def hello(): Unit =
  println("Hello world!")
  1. Add empty .scalafix.conf file next to build.sbt (it doesn't have to be empty, but its presence seems to be necessary to reproduce the problem).
  2. Run Organize Imports action, for instance by pressing Cmd+Shift+P, type Organize Imports, press Return (Enter)

The result is :

import java.util._
import java.util.concurrent._
...

Expected behaviour:

The result should be:

import java.util.*
import java.util.concurrent.*
...

Operating system:
Mac OS X

Java version:
17.0.8

Editor/extension:
Visual Studio Code v1.88.1

Metals version:
1.3.0

Extra context or search terms:

I think it didn't happen in Metals 1.2.0 (with scalafix.conf containing only one line, OrganizeImports.removeUnused = false, to silence an error). The issue is quite similar to #5121, but it's marked as solved and is quite old, so I thought I should submit this one.

Workspace information:

  • Scala versions: 3.4.1; 2.12.18
  • Build tools: 0. sbt
  • Build servers:
    0. Bloop v1.5.17
  • All build tools in workspace: Bloop; sbt
@tgodzik
Copy link
Contributor

tgodzik commented Apr 29, 2024

Thanks for reporting! You should be able to use:
OrganizeImports.targetDialect = Scala3

With no .scalafix.conf this doesn't happen?

We should make sure this doesn't happen by default.

@tgodzik tgodzik added the improvement Not a bug or a feature, but something general we can improve label Apr 29, 2024
@DLakomy
Copy link
Author

DLakomy commented Apr 29, 2024

OrganizeImports.targetDialect = Scala3 works correctly, thank you.

I confirm, with no .scalafix.conf this doesn't happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Not a bug or a feature, but something general we can improve
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants