I am trying to understand the difference between with
in Scalac and &
in dotty. The following example does demonstrate it
trait Base {
def foo: Any
}
trait A extends Base {
override def foo: Int = 1
}
trait B extends Base {
override def foo: Any = "foo"
}
def func(ab: A with B): Int = ab.foo // Compiles with Dotty (In dotty with is treat as &). But fails with Scalac
But in the above example object creation for type A with B
is not possible. So there is no way to actually call func
.
Is there any visible difference between &
and with
that a programmer can make use of?