I tried to generalize a method to provide a type safe API as follows:
abstract class AbstractCommand {
type T = this.type
def shuffler(s: T => Seq[AbstractCommand])
}
class TestCommand extends AbstractCommand {
override def shuffler(s: (TestCommand) => Seq[AbstractCommand]): Unit = ??? //error
}
I wanted the expected type of the function argument to be the most specific in this hierarchy. But it didn't work.
Is there a way to do something like that in Scala without introducing some helper type parameters?