I assumed the issue was concerning erasure. That makes sense. Thanks to all.
On Tuesday, September 30, 2014 4:07:02 PM UTC-4, Michael Frank wrote: > > not technically incorrect... it did compile, after all :) it produced > an unexpected result due to type erasure. Type erasure means the type T of > Success[T] is only available at compile time, and is lost at runtime. > check your compiler output, you should have seen a warning to that effect. > see also > http://en.wikipedia.org/wiki/Generics_in_Java#Problems_with_type_erasure > > atomly's version makes the type explicit in the pattern match, so the type > is available at runtime. > > -Michael > > On 09/30/14 12:41, bearrito wrote: > > > Yes this works, is my version considered incorrect? > > I'd like some insight into why the match failed. > > > > On Tuesday, September 30, 2014 3:19:11 PM UTC-4, atomly wrote: >> >> Try this instead, perhaps? >> >> case Event(Success(streamConfig: StreamConfig), req) => { >> stay() using StreamConfigRetrieved(streamConfig, req.session) >> forMax(timeout) >> } >> case Event(Success(dockConfig: DockConfig), req) => { >> stay() using DockConfigRetrieved(dockConfig, req.session) >> forMax(timeout) >> } >> >> :: atomly :: >> >> [ [email protected] : www.atomly.com : http://blog.atomly.com/ ... >> [ atomiq records : new york city : +1.347.692.8661 ... >> [ e-mail [email protected] for atomly info and updates ... >> >> On Tue, Sep 30, 2014 at 1:20 PM, bearrito <[email protected]> wrote: >> >>> >>> I believe I have a misunderstanding of the way the Events are matched. >>> >>> The below code snippet generates the following exception >>> >>> case Event(streamConfig : Success[StreamConfig],req: Request) => { >>> stay() using StreamConfigRetrieved(streamConfig.get,req.session) >>> forMax(timeout) >>> } >>> case Event(dockConfig : Success[DockConfig], req: Request) => { >>> stay() using DockConfigRetrieved(dockConfig.get,req.session) >>> forMax(timeout) >>> } >>> >>> >>> [akka://CityActorSpec/user/$$a] >>> trafficland.commons.data.flycast.DockConfig cannot be cast to >>> trafficland.commons.data.flycast.StreamConfig >>> java.lang.ClassCastException: >>> trafficland.commons.data.flycast.DockConfig cannot be cast to >>> trafficland.commons.data.flycast.StreamConfig >>> >>> I've watched it take place in the debugger. The first event is matched >>> but the Success(StreamConfig) is actually a Success(DockConfig) >>> >>> Can we not match on generic traits? >>> >>> -- >>> >>>>>>>>>> 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. >>> >> >> -- > >>>>>>>>>> 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] <javascript:>. > To post to this group, send email to [email protected] > <javascript:>. > Visit this group at http://groups.google.com/group/akka-user. > For more options, visit https://groups.google.com/d/optout. > > > -- >>>>>>>>>> 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.
