I can\'t create an actor for some reason (here is a simple version of my class hierarchy):
abstract class Class1[T <: Class2[_]: ClassTag] extends Actor {
One approach I have used involves creating an 'instantiator' trait which can be used to create instances of types for which an implicit instantiator exists:
trait Instantiator[+A] {
def apply(): A
}
object Instantiator {
def apply[A](create: => A): Instantiator[A] = new Instantiator[A] {
def apply(): A = create
}
}
class Foo() { ... }
object Foo {
implicit val instantiator: Instantiator[Foo] = Instantiator { new Foo() }
}
// def someMethod[A]()(implicit instantiator: Instantiator[A]): A = {
def someMethod[A : Instantiator](): A = {
val a = implicitly[Instantiator[A]].apply()
...
}
someMethod[Foo]()