I have a trait that looks like this:
trait Ingredient[T] {
def foo(t: T): Unit = {
// Some complex logic
}
}
And types for which I want to have methods:
class Cheese
class Pepperoni
class Oregano
How can I make another trait that has methods:
def foo(t: Cheese)
def foo(t: Pepperoni)
def foo(t: Oregano)
without duplicating the code? The following will not work as it has illegal inheritance from the same trait multiple times:
trait Pizza extends Ingredient[Cheese] with Ingredient[Pepperoni] with Ingredient[Oregano] {}