-
Notifications
You must be signed in to change notification settings - Fork 21
Closed
Description
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.
Metadata
Metadata
Assignees
Labels
No labels