This compiles:
import scala.collection._
trait Foo[A, +This <: SortedSet[A] with SortedSetLike[A,This]]
extends SortedSetLike[A, This] { this: This =>
def bar: This = (this: SortedSetLike[A,This]).empty
}
But if the upcast is removed it fails to compile:
import scala.collection._
trait Foo[A, +This <: SortedSet[A] with SortedSetLike[A,This]]
extends SortedSetLike[A, This] { this: This =>
def bar: This = this.empty
}
Why? From the extends clause we know that Foo is a SortedSetLike[A, This], so the upcast is valid of course - but doesn't this show that the compiler has allowed conflicting inheritance to occur?