The Artima Developer Community
Sponsored Link

Akka Concurrency Forum
Ch 6.2: Page 128, refactoring

2 replies on 1 page. Most recent reply: Feb 19, 2013 11:45 AM by Dan Luu

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Dan Luu

Posts: 27
Nickname: amitra
Registered: Feb, 2013

Ch 6.2: Page 128, refactoring Posted: Feb 18, 2013 4:38 PM
Reply to this message Reply
Advertisement
After I make the following changes


trait EventSource {
def sendEvent[T](event: T): Unit
def eventSourceReceive: Actor.Receive
}
trait ProductionEventSource extends EventSource { this: Actor =>
// Original contents of EventSource here
}



class Altimeter extends Actor with ActorLogging {
this: EventSource =>
// Original contents of Altimeter here
}
object Altimeter {
// Content as before. We're changing the factory method.
def apply() = new Altimeter with ProductionEventSource
}


I get this error:
[error] classes/eclipse/akkaC/src/main/scala/Altimeter.scala:12: illegal inheritance;
[error] self-type zzz.akka.avionics.Altimeter with zzz.akka.avionics.ProductionEventSource does not conform to Altimeter's selftype zzz.akka.avionics.Altimeter with zzz.akka.avionics.EventSource
[error] def apply() = new Altimeter with ProductionEventSource

This is fixed if I use the original
class Altimeter extends Actor with ActorLogging with ProductionEventSource{
instead of
class Altimeter extends Actor with ActorLogging { this: EventSource =>

Am I doing something wrong here? I tried to see if anyone else is having this issue, and all I found was this github repo (https://github.com/dfy/artima-akka-concurrency/blob/39dfd35d9a1be8595f8fe6d394b33ebfffdb0791/src/main/scala/zzz/akka/avionics/Altimeter.scala) of someone else working through the book, who also seems to have come up with the same solution I did.

I'm assuming the code is well tested, and that both me and this other fellow must be falling into some obvious trap?


Stig Brautaset

Posts: 7
Nickname: stigbra
Registered: Dec, 2012

Re: Ch 6.2: Page 128, refactoring Posted: Feb 18, 2013 9:57 PM
Reply to this message Reply
Are you using Scala 2.10.0? That part works for me...

https://github.com/stig/AkkaConcurrency

Dan Luu

Posts: 27
Nickname: amitra
Registered: Feb, 2013

Re: Ch 6.2: Page 128, refactoring Posted: Feb 19, 2013 11:45 AM
Reply to this message Reply
Thank you. I was able to find the bug by looking at your code, and I think I understand what the error message means now, too.

Flat View: This topic has 2 replies on 1 page
Topic: Hints about which code snippets to implement Previous Topic   Next Topic Topic: Dependency issues


Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2014 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us