I think this is easier to show with an example.
Say I have a case class of conditions, with an accompanying condition object that is used to provide an alternative constructor, for example:
case class Condition(
field: String,
values: List[String])
}
object Condition {
def apply(field: String, value: String): Condition = {
Condition(field, List(value))
}
}
When I import it from another, I get the following warning (which eventually turns into an error):
import utils.query.Condition
[warn] [...]/ConditionBuilder.scala:14: imported `Condition' is permanently hidden by definition of object Condition in package query
[warn] import utils.query.Condition
[warn] ^
[warn] one warning found
I want to have access to the type of the condition when declargin is the type of the variable and the companion object, when one of its methods is executed
Is there a way to achieve this and avoid this warning (except, of course, renaming the companion object)?
source
share