I have two traits
trait Base[A]
trait SometimesUsedWithBase[A] {
this: Base[A] =>
}
I then use these with a class
class StringThing extends Base[String] with SometimesUsedWithBase[String]
It would be great if I didn't have to define SometimesUsedWithBase's type, and instead it somehow understands that it's using the type defined in Base so that it looks like:
class StringThing extends Base[String] with SometimesUsedWithBase
Is this possible?
You should be able to do something like this.
trait Base[A] {
type BaseType = A
}
trait SometimesUsedWithBase {
this: Base[_] =>
def someFunction: BaseType
}
class StringThing extends Base[String] with SometimesUsedWithBase {
def someFunction: String = ""
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With