I don't think you can unfortunately. TestEnum.One
is really just an instance of the class Enumeration#Value
. In fact, it's lots worse than just this - your enumeration values are all erased by type to the same thing:
object Weekday extends Enumeration {
val Mon, Tue, Wed, Thu, Fri, Sat, Sun = Value
}
def foo(w: Weekday.Value)
def foo(e: TestEnum.Value) //won't compile as they erase to same type
As the instances of your enumeration are just instances of Enumeration#Value
, their declaring class is just scala.Enumeration
.
It's frustrating but it seems like these scala enums are worse than useless; if you pass them through serialization (at least in 2.7.7), then you can't do equality checks either!