Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scala Future mapTo fails to compile because of missing ClassTag

Tags:

scala

akka

future

Simple question, I have a problem where using mapTo on the result of ask results in a compiler error along the lines of:

not found: value ClassTag

For example:

(job ? "Run").mapTo[Result]
                   ^

I don't understand why it needs a ClassTag to do the cast? If I substitute a standard class from Predef like String as in (job ? "Run").mapTo[String] that compiles OK.

This happens when I define the class right above the line in question, as in:

class Result {}
(job ? "Run").mapTo[Result]

I still get the same problem.

Thanks, Jason.

I should also state that I'm using Scala 2.10.0 and Akka 2.1.0 (if that makes a difference).

like image 380
JMac Avatar asked Mar 23 '13 07:03

JMac


1 Answers

This seems to be a particular problem with the Scala 2.10.0 version

After adding

import reflect.ClassTag

the implicitly used ClassTag parameter in mapTo should work.

Either that or updating to a newer Version of Akka/Scala (which should be prefered if possible).

like image 149
michael_s Avatar answered Nov 20 '22 12:11

michael_s