Interesting.
Which Scala version are you using?
I've copied your code into a Scala project I have that uses Scala 2.11.2
(with akka 2.3.6) and I get no warnings.
Also the IDE (Intellij) correctly shows that receive is of type
PartialFunction[Any,Unit].
Have you tried modifying it to:
def receive: Receive = { x orElse y }
?
I would assume that should cause type inference to be skipped and therefore
also make the warning go away, like in the previous answer.
On Tuesday, September 23, 2014 7:29:08 PM UTC+3, Tim Pigden wrote:
>
> The following example:
>
> class TestPF extends Actor {
>
> val x: Receive = {
> case "hi" => sender ! "hello"
> }
>
> val y: Receive = {
> case "bye" => sender ! "farewell"
> }
>
> def receive = { x orElse y }
>
> }
>
> gets a warning
> Warning:(18, 28) a type was inferred to be `Any`; this may indicate a
> programming error.
> def receive = { x orElse y }
> ^
>
> Am I doing something wrong? I thought this was the intended use pattern.
> Can I make these warnings go away?
>
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.