Reputation: 10701
I am given an abstract syntax tree which I cannot modify:
trait Expr
case class Equals(lhs: Expr, rhs: Expr) extends Expr
case class Plus(lhs: Expr, rhs: Expr) extends Expr
case class Id(value: String) extends Expr
Now I would like to create a converter, but this fails:
trait Converter[T <: Expr]
trait BinaryConverter[T <: Expr with { def lhs: Expr; def rhs: Expr }] extends Converter[Expr] {
???
}
But this does not work. If I remove Expr with
, then it compiles. Same if I remove with { def lhs: Expr; def rhs: Expr }
.
What should I do to make it work?
Upvotes: 2
Views: 353
Reputation: 53348
Use the correct syntax:
trait BinaryConverter[T <: Expr { def lhs: Expr; def rhs: Expr }] extends Converter[Expr]
Upvotes: 3