consider this design of a library I need 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
}
Thats all well and good except that the Stuff.doStuff will accept anything conforming to the type Barred, not just the subtypes of Foo I want.
I would like to define Barred such that it is both a subtype of Foo and has a bar method, and I cannot 🙁 Help appreciated.
Simply