diff options
author | Paul Phillips <paulp@improving.org> | 2011-12-07 10:13:43 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-12-07 10:56:07 -0800 |
commit | 33f3c60ce1931b450053ba4635f7227727aed668 (patch) | |
tree | 401dbf5b7163d70ebc6c39d4c1f22d751851ca56 /src | |
parent | 332fec96e31840878bed41dd7b5314b97d8da7c2 (diff) | |
download | scala-33f3c60ce1931b450053ba4635f7227727aed668.tar.gz scala-33f3c60ce1931b450053ba4635f7227727aed668.tar.bz2 scala-33f3c60ce1931b450053ba4635f7227727aed668.zip |
Changed shadowed constructor parameter names.
One of my more recent warnings tells us this a bunch of places
if we compile with -Xlint, one example:
scala/actors/ReplyReactorTask.scala:26: warning:
private[this] value reactor in class ReplyReactorTask shadows
mutable reactor inherited from class ReactorTask. Changes to reactor
will not be visible within class ReplyReactorTask - you may want to
give them distinct names.
In some cases (like that one) I was not confident whether the shadowing
was intentional, in which case I left the semantics but changed the name
anyway because it will be eternally confusing otherwise.
Review by @phaller.
Diffstat (limited to 'src')
-rw-r--r-- | src/actors/scala/actors/ActorTask.scala | 13 | ||||
-rw-r--r-- | src/actors/scala/actors/ReplyReactorTask.scala | 13 |
2 files changed, 20 insertions, 6 deletions
diff --git a/src/actors/scala/actors/ActorTask.scala b/src/actors/scala/actors/ActorTask.scala index 8d0379c095..090d0448f0 100644 --- a/src/actors/scala/actors/ActorTask.scala +++ b/src/actors/scala/actors/ActorTask.scala @@ -12,12 +12,16 @@ package scala.actors /** * @author Philipp Haller + * @note This class inherits a public var called 'msg' from ReactorTask, + * and also defines a constructor parameter which shadows it (which makes any + * changes to the underlying var invisible.) I can't figure out what's supposed + * to happen, so I renamed the constructor parameter to at least be less confusing. */ private[actors] class ActorTask(actor: Actor, fun: () => Unit, handler: PartialFunction[Any, Any], - msg: Any) - extends ReplyReactorTask(actor, fun, handler, msg) { + initialMsg: Any) + extends ReplyReactorTask(actor, fun, handler, initialMsg) { protected override def beginExecution() { super.beginExecution() @@ -31,8 +35,11 @@ private[actors] class ActorTask(actor: Actor, val senderInfo = try { Some(actor.sender) } catch { case _: Exception => None } + // !!! If this is supposed to be setting the current contents of the + // inherited mutable var rather than always the value given in the constructor, + // then it should be changed from initialMsg to msg. val uncaught = UncaughtException(actor, - if (msg != null) Some(msg) else None, + if (initialMsg != null) Some(initialMsg) else None, senderInfo, Thread.currentThread, e) diff --git a/src/actors/scala/actors/ReplyReactorTask.scala b/src/actors/scala/actors/ReplyReactorTask.scala index 1db722f89b..cb63d7e000 100644 --- a/src/actors/scala/actors/ReplyReactorTask.scala +++ b/src/actors/scala/actors/ReplyReactorTask.scala @@ -12,18 +12,25 @@ package scala.actors /** * @author Philipp Haller + * @note This class inherits a public var called 'reactor' from ReactorTask, + * and also defines a constructor parameter which shadows it (which makes any + * changes to the underlying var invisible.) I can't figure out what's supposed + * to happen, so I renamed the constructor parameter to at least be less confusing. */ -private[actors] class ReplyReactorTask(reactor: ReplyReactor, +private[actors] class ReplyReactorTask(replyReactor: ReplyReactor, fun: () => Unit, handler: PartialFunction[Any, Any], msg: Any) - extends ReactorTask(reactor, fun, handler, msg) { + extends ReactorTask(replyReactor, fun, handler, msg) { var saved: ReplyReactor = _ protected override def beginExecution() { saved = Actor.tl.get - Actor.tl set reactor + // !!! If this is supposed to be setting the current contents of the + // inherited mutable var rather than always the value given in the constructor, + // then it should be changed to "set reactor". + Actor.tl set replyReactor } protected override def suspendExecution() { |