consider this library design that I have to use and cannot fix:
trait Foo class IgnoreMe extends Foo class A extends Foo { def bar: A = ...} class B extends Foo { def bar: B = ...}
In my code:
object Stuff { type Barred = { def bar: Foo } def doStuff(b:Barred) = b.bar }
All is well and good, except that Stuff.doStuff will accept anything that matches the Barred type, not just the Foo subtypes I want.
I would like to define Barred in such a way that it is a subtype of Foo and has a bar method, and I cannot :( Help evaluate.
source share