diff options
author | Paul Phillips <paulp@improving.org> | 2009-09-14 14:18:37 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2009-09-14 14:18:37 +0000 |
commit | 2788c1ad5b82929a1103a070f5c0bcce83a931e8 (patch) | |
tree | 5e6f13ee64e291cb5df067d31ebbc3b48fe60076 /src/library | |
parent | c45e93e798e6a97aeda628b6d10f0e549b085704 (diff) | |
download | scala-2788c1ad5b82929a1103a070f5c0bcce83a931e8.tar.gz scala-2788c1ad5b82929a1103a070f5c0bcce83a931e8.tar.bz2 scala-2788c1ad5b82929a1103a070f5c0bcce83a931e8.zip |
Workaround for by-name/implicit/default clash d...
Workaround for by-name/implicit/default clash described in #2290.
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/concurrent/ops.scala | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/library/scala/concurrent/ops.scala b/src/library/scala/concurrent/ops.scala index 4ff26d4465..67ef093847 100644 --- a/src/library/scala/concurrent/ops.scala +++ b/src/library/scala/concurrent/ops.scala @@ -20,7 +20,10 @@ import scala.util.control.Exception.allCatch */ object ops { - + // !!! I don't think this should be implicit, but it does need to be + // made available as a default argument (difficult at present, see spawn.) + // If it is merely implicit without being specified as a default, then it + // will not be in scope for callers unless ops._ is first imported. implicit val defaultRunner: FutureTaskRunner = TaskRunners.threadRunner @@ -46,7 +49,12 @@ object ops * * @param p the expression to evaluate */ - def spawn(p: => Unit)(implicit runner: TaskRunner = defaultRunner): Unit = { + // !!! this should have a signature like: + // def spawn(p: => Unit)(implicit runner: TaskRunner = defaultRunner): Unit + // but at present the mixture of by-name argument and default implicit causes a crash. + + def spawn(p: => Unit): Unit = spawn(p, defaultRunner) + def spawn(p: => Unit, runner: TaskRunner): Unit = { runner execute runner.functionAsTask(() => p) } @@ -54,7 +62,10 @@ object ops * @param p ... * @return ... */ - def future[A](p: => A)(implicit runner: FutureTaskRunner = defaultRunner): () => A = { + // See spawn above, this should have a signature like + // def future[A](p: => A)(implicit runner: FutureTaskRunner = defaultRunner): () => A + def future[A](p: => A): () => A = future[A](p, defaultRunner) + def future[A](p: => A, runner: FutureTaskRunner): () => A = { runner.futureAsFunction(runner submit runner.functionAsTask(() => p)) } |