I have the following...
trait SourceTrait[T <: Connector] extends BeforeAndAfterAll{
...
override def beforeAll(): Unit = {
super.beforeAll()
ds = new T
connector = ds.asInstanceOf[Connector]
}
}
The idea is that now I can create custom traits for a variety of type like this with SourceTrait[Thing]
The problem is I get class type required but T found
when I try to compile this code.
Is there a way in a Scala trait I can create a new instance of a Generic Class?
This needs to work specifically for a Trait.