After some googling and reading up on scala type system it seems that it just won't work - scala won't use an implicit conversion with implicit parameters if its return type is not bound by explict parameter list, due dark magic that happens in the compiler. I'll have to settle for something like this:

implicit class Generalization[T](val something :T) extends AnyVal {
    def widen[X](implicit ev: X SuperType T) = ev.cast(value)

val union :Int || String = 1.widen

Or has anybody a more clever idea?


Move your implicit + the extra def gen... to the end of || object. It compiles on 2.10.

There is some weirdness about visibility of types and how scala compiles implicts.

Related Query

More Query from same tag