2

I have a class hierarchy like this:

abstract class Class1[T <: Class2 : ClassTag] extends Actor {

  protected val val1 = context.actorOf(Props[T])   // ops!
  //..........
}

abstract class Class2[T <: Actor] extends Actor {
//................
}

However, it complains type arguments [T] do not conform to method apply's type parameter bounds [T <: akka.actor.Actor]

How do I fix that?

Alan Coromano
  • 24,958
  • 53
  • 135
  • 205
  • 1
    Akka actors are not typed. This [SO post](http://stackoverflow.com/questions/5547947/why-are-messages-to-akka-actors-untyped) explains why. You may want to use [TypedActors](http://doc.akka.io/docs/akka/2.2.1/scala/typed-actors.html) instead. – S.R.I Sep 12 '13 at 04:39
  • Does `Class2` really need to have a generic type that is also an `Actor`? Is it going to use that type internally for something? – cmbaxter Sep 12 '13 at 12:59

1 Answers1

2

The error is because you are not passing type parameter with Class2. Give the type parameter and it works:

abstract class Class1[T <: Class2[_] : ClassTag] extends Actor {
    protected val val1 = context.actorOf(Props[T])
}
Jatin
  • 31,116
  • 15
  • 98
  • 163
  • @MariusKavansky Oops. Sorry I did not see the `Class2` declaration in your code. I have edited it. – Jatin Sep 12 '13 at 06:28