Skip to content

Same filename as another file causes duplicate object definition with clean builds #2931

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

Closed
scabug opened this issue Jan 20, 2010 · 7 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Jan 20, 2010

Steps to reproduce:

(1) Create two files:

src/test/BarFile.scala

package test

import test2.BarFile

object Bar {
  def main(args: Array[String]) {
    
  }
}

src/test2/BarFile.scala

package test2

class BarFile {

}

(2) Do clean build

(3) Notice error in problems view "Bar is already defined as object Bar". Also, no classfiles are compiled.

(4) Edit and save test/BarFile.scala

(5) Notice that classfiles are generated and the problems view shows no errors

Of course, in my environment the second BarFile was not in the same project (it was in a jar). Strangely, renaming test/BarFile.scala to test/Bar.scala fixes the problem.

@scabug
Copy link
Author

scabug commented Jan 20, 2010

Imported From: https://issues.scala-lang.org/browse/SI-2931?orig=1
Reporter: @ijuma

@scabug
Copy link
Author

scabug commented Jan 20, 2010

@milessabin said:
Interesting! Do you see this with fsc as well?

@scabug
Copy link
Author

scabug commented Jan 20, 2010

@ijuma said:
fsc seems to work OK:

[ijuma@mac]% /opt/scala-2.8.0.Beta1-RC8/bin/fsc test/BarFile.scala test2/BarFile.scala
[ijuma@mac]%

@scabug
Copy link
Author

scabug commented Jan 25, 2010

@milessabin said:
(In r20660) Use file paths for equality and hashCode to deal with mixed-type file equality test issues in the IDE. Fixes #2931.

@scabug
Copy link
Author

scabug commented Jan 25, 2010

@ijuma said:
Thanks! I am hoping that this will solve all the duplicate object/class definitions I'm seeing during clean builds (the workarounds for other cases were not as easy as the one I described in the creation comment). If not, I'll be back (on separate tickets). ;)

@scabug
Copy link
Author

scabug commented Jan 26, 2010

@ijuma said:
I can confirm that clean builds now work for all the projects I have converted to 2.8 without introducing any errors. Excellent stuff!

@scabug
Copy link
Author

scabug commented Jan 26, 2010

@milessabin said:
Thanks for the update.

@scabug scabug closed this as completed May 18, 2011
@scabug scabug added this to the 2.8.0 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants