score:0

Structurally, what you have in your example seems to be correct, but the question is what will you be doing inside of those elipses to return that something.RenderedType. I threw a quick impl together to check that everything compiles (and it does), but like I said, it boils down to what's going on inside of that render function. Here's my code:

object RenderedTypeTest {

  def render(something : SomeEnumThing) : something.RenderedType = {
    something.renderType
  }
}

sealed abstract class SomeEnumThing {
    type RenderedType
    def renderType:RenderedType
}
object Type1 extends SomeEnumThing {
    type RenderedType = String
    def renderType = "hello"
}
object Type2 extends SomeEnumThing  {
     type RenderedType = Array[Byte]
     def renderType = Array()
}

Related Query

More Query from same tag