I'm having a problem whose solution should be equivalent to the solution to this: Suppose I want to write a method which, given an Enumeration, returns a list of all its values. I want to write:
def makeList[E <: Enumeration](enum: E): List[enum.Value] = enum.values.toList
but compilation fails with an illegal dependent method type
error. Is it OK to write this instead?
def makeList[E <: Enumeration](enum: E): List[E#Value] = enum.values.toList
You can use a path dependent type there but it's an experimental feature right now. Use -Xexperimental for scala or scalac.