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

Confusing 'permanently hidden' import warning #8808

Closed
scabug opened this issue Aug 21, 2014 · 2 comments
Closed

Confusing 'permanently hidden' import warning #8808

scabug opened this issue Aug 21, 2014 · 2 comments

Comments

@scabug
Copy link

scabug commented Aug 21, 2014

When an import adds in scope an object with the same name as a class defined in the package, the imported SomeClass' is permanently hidden by ...` warning makes it look like the import statement is not useful. When in fact it might be used to access the elements of the object.

The warning appears with the following files, and the code doesn't compile anymore if the import is removed.

// anotherpackage/SomeClass.scala
package anotherpackage

object SomeClass {
  val CONST= 1
}
// apackage/ScalaClass.scala
package apackage

import anotherpackage.SomeClass  // permanently hidden warning here

class ScalaClass {
  val i = SomeClass.CONST  // error if the import is removed
}

class SomeClass {

}

To be fair, the warning states that the class is hidden, not the object.

The only way to have code that compiles without warning is to use an import rename.

@scabug
Copy link
Author

scabug commented Aug 21, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8808?orig=1
Reporter: @skyluc
Affected Versions: 2.11.2
See #8121

@scabug
Copy link
Author

scabug commented Aug 21, 2014

@som-snytt said:
Probably a duplicate, since it also fails on separate compilation, but succeeds on clean global compilation.

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

3 participants