scalacenter / bloop

Bloop is a build server and CLI tool to compile, test and run Scala fast from any editor or build tool.
https://scalacenter.github.io/bloop/
Apache License 2.0
907 stars 202 forks source link

Converting package to object gives "<object> is already defined as package <package>" #1466

Open pjoneswork opened 3 years ago

pjoneswork commented 3 years ago

Converting a package to a top level object with the same name gives " is already defined as package "

To reproduce start with the follow setup:

 > cat build.sbt
ThisBuild / organization := "foo"
ThisBuild / scalaVersion := "2.12.12"

lazy val root = (project in file ("."))

> cat project/build.properties
sbt.version=1.4.6

> cat src/main/scala/foo.scala
package foo.bar

object Bar {
  val myFooBar: Int = 1
}

> cat project/metals.sbt
// DO NOT EDIT! This file is auto-generated.
// This file enables sbt-bloop to create bloop config files.

addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.4.6-21-464e4ec4")

After metals has loaded and built the project change foo.scala to

package foo

object bar {
  object Bar {
    val myFooBar: Int = 1
  }
}

Get the error message bar is already defined as package bar.

The error message remains even through doing the following commands exposed by VSCode:

  • Clean compiling workspace
  • Restarting the build server
  • (Re-)Importing the build

I can get rid of the error message by doing

 > rm -fr .bloop

and reimporting the build.

tgodzik commented 3 years ago

Thanks for reporting! I think the issue here is that we don't fully clean the results when being sent the clean request. It's soemthing on my list to take a look at.