summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Cunei <antonio.cunei@epfl.ch>2009-12-23 11:36:08 +0000
committerAntonio Cunei <antonio.cunei@epfl.ch>2009-12-23 11:36:08 +0000
commit4069be072e8ad7ec53a1d91a639c03ad96d98070 (patch)
treedd49b65b4e9b28e8b47de46448efaedb84046357
parent648a50a76eb865b3891092aff0fc06a92a9edf1c (diff)
downloadscala-4069be072e8ad7ec53a1d91a639c03ad96d98070.tar.gz
scala-4069be072e8ad7ec53a1d91a639c03ad96d98070.tar.bz2
scala-4069be072e8ad7ec53a1d91a639c03ad96d98070.zip
Merged revisions 20262-20263,20266-20267,20269-...
Merged revisions 20262-20263,20266-20267,20269-20270,20284,20287-20289,20292,20294-20297, 20300 via svnmerge from https://lampsvn.epfl.ch/svn-repos/scala/scala/trunk ........ r20262 | phaller | 2009-12-21 17:03:07 +0100 (Mon, 21 Dec 2009) | 1 line closed #2829. review by rompf. ........ r20263 | phaller | 2009-12-21 17:36:37 +0100 (Mon, 21 Dec 2009) | 1 line small correction in doc comment. no review. ........ r20266 | phaller | 2009-12-21 18:16:55 +0100 (Mon, 21 Dec 2009) | 1 line closed #2181. no review. ........ r20267 | odersky | 2009-12-21 18:30:23 +0100 (Mon, 21 Dec 2009) | 3 lines (1) Added some classes to allow arbitrary patches to source buffers. These are not yet complete so do not need a review yet I think. (2) Avoided reflexive array operations in ScalaRunTime. review by community. ........ r20269 | phaller | 2009-12-21 20:28:18 +0100 (Mon, 21 Dec 2009) | 1 line closed #1449. review by community. ........ r20270 | odersky | 2009-12-21 20:41:51 +0100 (Mon, 21 Dec 2009) | 2 lines Closed #2709. Thanks for the patch! Review by community. ........ r20284 | rytz | 2009-12-22 10:56:21 +0100 (Tue, 22 Dec 2009) | 1 line close #2809. thanks for the small example. review by community ........ r20287 | rytz | 2009-12-22 13:22:56 +0100 (Tue, 22 Dec 2009) | 1 line fix the build. no review. ........ r20288 | prokopec | 2009-12-22 15:00:58 +0100 (Tue, 22 Dec 2009) | 2 lines fixed #2548 - reverse, reverseIterator for views bug. Also - reverseMap for views now should work. review by phaller. ........ r20289 | prokopec | 2009-12-22 15:32:16 +0100 (Tue, 22 Dec 2009) | 2 lines Small change in test. no review ........ r20292 | odersky | 2009-12-22 18:11:54 +0100 (Tue, 22 Dec 2009) | 1 line Closes #2819, #2705, #2805. Review by community. ........ r20294 | odersky | 2009-12-22 18:57:13 +0100 (Tue, 22 Dec 2009) | 1 line Closes #2812 (and removed a left-over println in Types). no review necessary. ........ r20295 | phaller | 2009-12-22 19:15:43 +0100 (Tue, 22 Dec 2009) | 1 line Closes #2538. no review necessary. ........ r20296 | extempore | 2009-12-22 21:11:29 +0100 (Tue, 22 Dec 2009) | 3 lines Took full advantage of the new =>? alias for the superverbosely named PartialFunction by renaming every usage of the latter except when in comments. ........ r20297 | odersky | 2009-12-23 00:42:37 +0100 (Wed, 23 Dec 2009) | 2 lines tentative fix for RC5 lift build problem. ........ r20300 | odersky | 2009-12-23 01:22:11 +0100 (Wed, 23 Dec 2009) | 2 lines Another fix to make lift build under RC5; review by dragos ........
-rw-r--r--src/actors/scala/actors/Actor.scala30
-rw-r--r--src/actors/scala/actors/Channel.scala8
-rw-r--r--src/actors/scala/actors/Future.scala72
-rw-r--r--src/actors/scala/actors/InputChannel.scala8
-rw-r--r--src/actors/scala/actors/ReactChannel.scala8
-rw-r--r--src/actors/scala/actors/Reaction.scala2
-rw-r--r--src/actors/scala/actors/Reactor.scala8
-rw-r--r--src/actors/scala/actors/Replyable.scala2
-rw-r--r--src/actors/scala/actors/ReplyableActor.scala8
-rw-r--r--src/actors/scala/actors/ReplyableReactor.scala2
-rw-r--r--src/actors/scala/actors/remote/Proxy.scala2
-rw-r--r--src/actors/scala/actors/scheduler/ThreadPoolConfig.scala10
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/BracePatch.scala1
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Change.scala10
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Patch.scala8
-rw-r--r--src/compiler/scala/tools/nsc/interactive/RichCompilationUnits.scala1
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Definitions.scala2
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Types.scala7
-rw-r--r--src/compiler/scala/tools/nsc/transform/CleanUp.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/TailCalls.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/UnCurry.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Namers.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala6
-rw-r--r--src/library/scala/Option.scala2
-rw-r--r--src/library/scala/PartialFunction.scala12
-rw-r--r--src/library/scala/collection/Iterator.scala2
-rw-r--r--src/library/scala/collection/SeqViewLike.scala11
-rw-r--r--src/library/scala/collection/TraversableLike.scala4
-rw-r--r--src/library/scala/collection/TraversableProxyLike.scala2
-rw-r--r--src/library/scala/collection/interfaces/TraversableMethods.scala2
-rw-r--r--src/library/scala/collection/mutable/Publisher.scala3
-rw-r--r--src/library/scala/concurrent/MailBox.scala6
-rw-r--r--src/library/scala/package.scala2
-rw-r--r--src/library/scala/runtime/ScalaRunTime.scala46
-rw-r--r--src/library/scala/util/control/Exception.scala14
-rw-r--r--src/library/scala/util/parsing/combinator/Parsers.scala14
-rw-r--r--src/scalap/scala/tools/scalap/scalax/rules/Rule.scala6
-rw-r--r--src/swing/scala/swing/Reactions.scala2
-rw-r--r--test/files/jvm/future-awaitall-zero.check1
-rw-r--r--test/files/jvm/future-awaitall-zero.scala17
-rw-r--r--test/files/jvm/t1449.check1
-rw-r--r--test/files/jvm/t1449.scala15
-rw-r--r--test/files/neg/names-defaults-neg-ref.check2
-rw-r--r--test/files/pos/t2809.scala20
-rw-r--r--test/files/run/ReverseSeqView.scala25
46 files changed, 302 insertions, 116 deletions
diff --git a/src/actors/scala/actors/Actor.scala b/src/actors/scala/actors/Actor.scala
index 625b19ebdd..fb90cb9c46 100644
--- a/src/actors/scala/actors/Actor.scala
+++ b/src/actors/scala/actors/Actor.scala
@@ -160,7 +160,7 @@ object Actor {
* @param f a partial function specifying patterns and actions
* @return the result of processing the received message
*/
- def receive[A](f: PartialFunction[Any, A]): A =
+ def receive[A](f: Any =>? A): A =
self.receive(f)
/**
@@ -175,7 +175,7 @@ object Actor {
* @param f a partial function specifying patterns and actions
* @return the result of processing the received message
*/
- def receiveWithin[R](msec: Long)(f: PartialFunction[Any, R]): R =
+ def receiveWithin[R](msec: Long)(f: Any =>? R): R =
self.receiveWithin(msec)(f)
/**
@@ -188,7 +188,7 @@ object Actor {
* @param f a partial function specifying patterns and actions
* @return this function never returns
*/
- def react(f: PartialFunction[Any, Unit]): Nothing =
+ def react(f: Any =>? Unit): Nothing =
rawSelf.react(f)
/**
@@ -202,14 +202,14 @@ object Actor {
* @param f a partial function specifying patterns and actions
* @return this function never returns
*/
- def reactWithin(msec: Long)(f: PartialFunction[Any, Unit]): Nothing =
+ def reactWithin(msec: Long)(f: Any =>? Unit): Nothing =
self.reactWithin(msec)(f)
- def eventloop(f: PartialFunction[Any, Unit]): Nothing =
+ def eventloop(f: Any =>? Unit): Nothing =
rawSelf.react(new RecursiveProxyHandler(rawSelf, f))
- private class RecursiveProxyHandler(a: Reactor, f: PartialFunction[Any, Unit])
- extends PartialFunction[Any, Unit] {
+ private class RecursiveProxyHandler(a: Reactor, f: Any =>? Unit)
+ extends (Any =>? Unit) {
def isDefinedAt(m: Any): Boolean =
true // events are immediately removed from the mailbox
def apply(m: Any) {
@@ -261,9 +261,9 @@ object Actor {
* }
* </pre>
*/
- def respondOn[A, B](fun: PartialFunction[A, Unit] => Nothing):
- PartialFunction[A, B] => Responder[B] =
- (caseBlock: PartialFunction[A, B]) => new Responder[B] {
+ def respondOn[A, B](fun: A =>? Unit => Nothing):
+ A =>? B => Responder[B] =
+ (caseBlock: A =>? B) => new Responder[B] {
def respond(k: B => Unit) = fun(caseBlock andThen k)
}
@@ -428,7 +428,7 @@ trait Actor extends AbstractActor with ReplyReactor with ReplyableActor {
* @param f a partial function with message patterns and actions
* @return result of processing the received value
*/
- def receive[R](f: PartialFunction[Any, R]): R = {
+ def receive[R](f: Any =>? R): R = {
assert(Actor.self(scheduler) == this, "receive from channel belonging to other actor")
synchronized {
@@ -479,7 +479,7 @@ trait Actor extends AbstractActor with ReplyReactor with ReplyableActor {
* @param f a partial function with message patterns and actions
* @return result of processing the received value
*/
- def receiveWithin[R](msec: Long)(f: PartialFunction[Any, R]): R = {
+ def receiveWithin[R](msec: Long)(f: Any =>? R): R = {
assert(Actor.self(scheduler) == this, "receive from channel belonging to other actor")
synchronized {
@@ -559,7 +559,7 @@ trait Actor extends AbstractActor with ReplyReactor with ReplyableActor {
*
* @param f a partial function with message patterns and actions
*/
- override def react(f: PartialFunction[Any, Unit]): Nothing = {
+ override def react(f: Any =>? Unit): Nothing = {
assert(Actor.self(scheduler) == this, "react on channel belonging to other actor")
synchronized {
if (shouldExit) exit() // links
@@ -580,7 +580,7 @@ trait Actor extends AbstractActor with ReplyReactor with ReplyableActor {
* @param msec the time span before timeout
* @param f a partial function with message patterns and actions
*/
- def reactWithin(msec: Long)(f: PartialFunction[Any, Unit]): Nothing = {
+ def reactWithin(msec: Long)(f: Any =>? Unit): Nothing = {
assert(Actor.self(scheduler) == this, "react on channel belonging to other actor")
synchronized {
@@ -646,7 +646,7 @@ trait Actor extends AbstractActor with ReplyReactor with ReplyableActor {
}
// guarded by lock of this
- private[actors] override def scheduleActor(f: PartialFunction[Any, Unit], msg: Any) =
+ private[actors] override def scheduleActor(f: Any =>? Unit, msg: Any) =
if ((f eq null) && (continuation eq null)) {
// do nothing (timeout is handled instead)
}
diff --git a/src/actors/scala/actors/Channel.scala b/src/actors/scala/actors/Channel.scala
index 24340d22f2..1454f29214 100644
--- a/src/actors/scala/actors/Channel.scala
+++ b/src/actors/scala/actors/Channel.scala
@@ -76,7 +76,7 @@ class Channel[Msg](val receiver: Actor) extends InputChannel[Msg] with OutputCha
* @param f a partial function with message patterns and actions
* @return result of processing the received value
*/
- def receive[R](f: PartialFunction[Msg, R]): R = {
+ def receive[R](f: Msg =>? R): R = {
val C = this.asInstanceOf[Channel[Any]]
val recvActor = receiver.asInstanceOf[Actor]
recvActor.receive {
@@ -99,7 +99,7 @@ class Channel[Msg](val receiver: Actor) extends InputChannel[Msg] with OutputCha
* @param f a partial function with message patterns and actions
* @return result of processing the received value
*/
- def receiveWithin[R](msec: Long)(f: PartialFunction[Any, R]): R = {
+ def receiveWithin[R](msec: Long)(f: Any =>? R): R = {
val C = this.asInstanceOf[Channel[Any]]
val recvActor = receiver.asInstanceOf[Actor]
recvActor.receiveWithin(msec) {
@@ -116,7 +116,7 @@ class Channel[Msg](val receiver: Actor) extends InputChannel[Msg] with OutputCha
*
* @param f a partial function with message patterns and actions
*/
- def react(f: PartialFunction[Msg, Unit]): Nothing = {
+ def react(f: Msg =>? Unit): Nothing = {
val C = this.asInstanceOf[Channel[Any]]
receiver.react {
case C ! msg if (f.isDefinedAt(msg.asInstanceOf[Msg])) => f(msg.asInstanceOf[Msg])
@@ -133,7 +133,7 @@ class Channel[Msg](val receiver: Actor) extends InputChannel[Msg] with OutputCha
* @param msec the time span before timeout
* @param f a partial function with message patterns and actions
*/
- def reactWithin(msec: Long)(f: PartialFunction[Any, Unit]): Nothing = {
+ def reactWithin(msec: Long)(f: Any =>? Unit): Nothing = {
val C = this.asInstanceOf[Channel[Any]]
val recvActor = receiver.asInstanceOf[Actor]
recvActor.reactWithin(msec) {
diff --git a/src/actors/scala/actors/Future.scala b/src/actors/scala/actors/Future.scala
index ea0c3a691f..1369ed6255 100644
--- a/src/actors/scala/actors/Future.scala
+++ b/src/actors/scala/actors/Future.scala
@@ -10,6 +10,8 @@
package scala.actors
+import scala.actors.scheduler.DaemonScheduler
+
/** A `Future[T]` is a function of arity 0 that returns
* a value of type `T`.
* Applying a future blocks the current actor (`Actor.self`)
@@ -21,6 +23,7 @@ package scala.actors
* @author Philipp Haller
*/
abstract class Future[+T](val inputChannel: InputChannel[T]) extends Responder[T] with Function0[T] {
+ @volatile
private[actors] var fvalue: Option[Any] = None
private[actors] def fvalueTyped = fvalue.get.asInstanceOf[T]
@@ -37,7 +40,7 @@ abstract class Future[+T](val inputChannel: InputChannel[T]) extends Responder[T
def isSet: Boolean
}
-/** The <code>Futures</code> object contains methods that operate on futures.
+/** The `Futures` object contains methods that operate on futures.
*
* @author Philipp Haller
*/
@@ -45,6 +48,39 @@ object Futures {
private case object Eval
+ private class FutureActor[T](fun: () => T, channel: Channel[T])
+ extends Future[T](channel) with DaemonActor {
+
+ def isSet = !fvalue.isEmpty
+
+ def apply(): T = {
+ if (fvalue.isEmpty)
+ this !? Eval
+ fvalueTyped
+ }
+
+ def respond(k: T => Unit) {
+ if (isSet) k(fvalueTyped)
+ else {
+ val ft = this !! Eval
+ ft.inputChannel.react {
+ case _ => k(fvalueTyped)
+ }
+ }
+ }
+
+ def act() {
+ val res = fun()
+ fvalue = Some(res)
+ channel ! res
+ Actor.loop {
+ Actor.react {
+ case Eval => Actor.reply()
+ }
+ }
+ }
+ }
+
/** Arranges for the asynchronous execution of `body`,
* returning a future representing the result.
*
@@ -53,15 +89,10 @@ object Futures {
* computation
*/
def future[T](body: => T): Future[T] = {
- val a = new DaemonActor {
- def act() {
- Actor.react {
- case Eval => Actor.reply(body)
- }
- }
- }
+ val c = new Channel[T](Actor.self(DaemonScheduler))
+ val a = new FutureActor[T](() => body, c)
a.start()
- a !! (Eval, { case any => any.asInstanceOf[T] })
+ a
}
/** Creates a future that resolves after a given time span.
@@ -105,17 +136,10 @@ object Futures {
* aborted
* @param fts the futures to be awaited
* @return the list of optional future values
- * @throws `java.lang.IllegalArgumentException` if timeout
- * is negative, or timeout + `System.currentTimeMillis()`
- * is negative.
+ * @throws java.lang.IllegalArgumentException if timeout is negative,
+ * or timeout + `System.currentTimeMillis()` is negative.
*/
def awaitAll(timeout: Long, fts: Future[Any]*): List[Option[Any]] = {
- val thisActor = Actor.self
- val timerTask = new java.util.TimerTask {
- def run() { thisActor ! TIMEOUT }
- }
- Actor.timer.schedule(timerTask, timeout)
-
var resultsMap: collection.mutable.Map[Int, Option[Any]] = new collection.mutable.HashMap[Int, Option[Any]]
var cnt = 0
@@ -129,14 +153,20 @@ object Futures {
val partFuns = unsetFts.map((p: Pair[Int, Future[Any]]) => {
val FutCh = p._2.inputChannel
- val singleCase: PartialFunction[Any, Pair[Int, Any]] = {
+ val singleCase: Any =>? Pair[Int, Any] = {
case FutCh ! any => Pair(p._1, any)
}
singleCase
})
- def awaitWith(partFuns: Seq[PartialFunction[Any, Pair[Int, Any]]]) {
- val reaction: PartialFunction[Any, Unit] = new PartialFunction[Any, Unit] {
+ val thisActor = Actor.self
+ val timerTask = new java.util.TimerTask {
+ def run() { thisActor ! TIMEOUT }
+ }
+ Actor.timer.schedule(timerTask, timeout)
+
+ def awaitWith(partFuns: Seq[Any =>? Pair[Int, Any]]) {
+ val reaction: Any =>? Unit = new (Any =>? Unit) {
def isDefinedAt(msg: Any) = msg match {
case TIMEOUT => true
case _ => partFuns exists (_ isDefinedAt msg)
diff --git a/src/actors/scala/actors/InputChannel.scala b/src/actors/scala/actors/InputChannel.scala
index 46988159fa..fb922f27b2 100644
--- a/src/actors/scala/actors/InputChannel.scala
+++ b/src/actors/scala/actors/InputChannel.scala
@@ -25,7 +25,7 @@ trait InputChannel[+Msg] {
* @param f a partial function with message patterns and actions
* @return result of processing the received value
*/
- def receive[R](f: PartialFunction[Msg, R]): R
+ def receive[R](f: Msg =>? R): R
/**
* Receives a message from this <code>InputChannel</code> within
@@ -35,7 +35,7 @@ trait InputChannel[+Msg] {
* @param f a partial function with message patterns and actions
* @return result of processing the received value
*/
- def receiveWithin[R](msec: Long)(f: PartialFunction[Any, R]): R
+ def receiveWithin[R](msec: Long)(f: Any =>? R): R
/**
* Receives a message from this <code>InputChannel</code>.
@@ -45,7 +45,7 @@ trait InputChannel[+Msg] {
*
* @param f a partial function with message patterns and actions
*/
- def react(f: PartialFunction[Msg, Unit]): Nothing
+ def react(f: Msg =>? Unit): Nothing
/**
* Receives a message from this <code>InputChannel</code> within
@@ -57,7 +57,7 @@ trait InputChannel[+Msg] {
* @param msec the time span before timeout
* @param f a partial function with message patterns and actions
*/
- def reactWithin(msec: Long)(f: PartialFunction[Any, Unit]): Nothing
+ def reactWithin(msec: Long)(f: Any =>? Unit): Nothing
/**
* Receives the next message from this <code>Channel</code>.
diff --git a/src/actors/scala/actors/ReactChannel.scala b/src/actors/scala/actors/ReactChannel.scala
index 8bbbc04f53..926805fbe7 100644
--- a/src/actors/scala/actors/ReactChannel.scala
+++ b/src/actors/scala/actors/ReactChannel.scala
@@ -55,7 +55,7 @@ private[actors] class ReactChannel[Msg](receiver: Reactor) extends InputChannel[
*
* @param f a partial function with message patterns and actions
*/
- def react(f: PartialFunction[Msg, Unit]): Nothing = {
+ def react(f: Msg =>? Unit): Nothing = {
val C = this
receiver.react {
case SendToReactor(C, msg) if (f.isDefinedAt(msg.asInstanceOf[Msg])) =>
@@ -73,7 +73,7 @@ private[actors] class ReactChannel[Msg](receiver: Reactor) extends InputChannel[
* @param msec the time span before timeout
* @param f a partial function with message patterns and actions
*/
- def reactWithin(msec: Long)(f: PartialFunction[Any, Unit]): Nothing = {
+ def reactWithin(msec: Long)(f: Any =>? Unit): Nothing = {
val C = this
val recvActor = receiver.asInstanceOf[Actor]
recvActor.reactWithin(msec) {
@@ -89,7 +89,7 @@ private[actors] class ReactChannel[Msg](receiver: Reactor) extends InputChannel[
* @param f a partial function with message patterns and actions
* @return result of processing the received value
*/
- def receive[R](f: PartialFunction[Msg, R]): R = {
+ def receive[R](f: Msg =>? R): R = {
val C = this
val recvActor = receiver.asInstanceOf[Actor]
recvActor.receive {
@@ -106,7 +106,7 @@ private[actors] class ReactChannel[Msg](receiver: Reactor) extends InputChannel[
* @param f a partial function with message patterns and actions
* @return result of processing the received value
*/
- def receiveWithin[R](msec: Long)(f: PartialFunction[Any, R]): R = {
+ def receiveWithin[R](msec: Long)(f: Any =>? R): R = {
val C = this
val recvActor = receiver.asInstanceOf[Actor]
recvActor.receiveWithin(msec) {
diff --git a/src/actors/scala/actors/Reaction.scala b/src/actors/scala/actors/Reaction.scala
index 25aea803af..a4736f9489 100644
--- a/src/actors/scala/actors/Reaction.scala
+++ b/src/actors/scala/actors/Reaction.scala
@@ -26,7 +26,7 @@ private[actors] class KillActorException extends Throwable with ControlException
* @deprecated("this class is going to be removed in a future release")
* @author Philipp Haller
*/
-class Reaction(a: Actor, f: PartialFunction[Any, Unit], msg: Any) extends ActorTask(a, () => {
+class Reaction(a: Actor, f: Any =>? Unit, msg: Any) extends ActorTask(a, () => {
if (f == null)
a.act()
else
diff --git a/src/actors/scala/actors/Reactor.scala b/src/actors/scala/actors/Reactor.scala
index 0eff67c163..d641f54eb6 100644
--- a/src/actors/scala/actors/Reactor.scala
+++ b/src/actors/scala/actors/Reactor.scala
@@ -41,7 +41,7 @@ trait Reactor extends OutputChannel[Any] {
* message handler that react was called with.
*/
@volatile
- private[actors] var continuation: PartialFunction[Any, Unit] = null
+ private[actors] var continuation: Any =>? Unit = null
/* Whenever this Actor executes on some thread, waitingFor is
* guaranteed to be equal to waitingForNone.
@@ -61,7 +61,7 @@ trait Reactor extends OutputChannel[Any] {
*/
def act(): Unit
- protected[actors] def exceptionHandler: PartialFunction[Exception, Unit] =
+ protected[actors] def exceptionHandler: Exception =>? Unit =
Map()
protected[actors] def scheduler: IScheduler =
@@ -159,7 +159,7 @@ trait Reactor extends OutputChannel[Any] {
}
}
- protected[actors] def react(f: PartialFunction[Any, Unit]): Nothing = {
+ protected[actors] def react(f: Any =>? Unit): Nothing = {
assert(Actor.rawSelf(scheduler) == this, "react on channel belonging to other actor")
synchronized { drainSendBuffer(mailbox) }
continuation = f
@@ -172,7 +172,7 @@ trait Reactor extends OutputChannel[Any] {
*
* assume handler != null
*/
- private[actors] def scheduleActor(handler: PartialFunction[Any, Unit], msg: Any) = {
+ private[actors] def scheduleActor(handler: Any =>? Unit, msg: Any) = {
val fun = () => handler(msg)
val task = new ReactorTask(this, fun)
scheduler executeFromActor task
diff --git a/src/actors/scala/actors/Replyable.scala b/src/actors/scala/actors/Replyable.scala
index 2c7e55e06a..b1ccb3205e 100644
--- a/src/actors/scala/actors/Replyable.scala
+++ b/src/actors/scala/actors/Replyable.scala
@@ -59,7 +59,7 @@ trait Replyable[-T, +R] {
* @param f the function to be applied to the response
* @return the future
*/
- def !![P](msg: T, f: PartialFunction[R, P]): () => P =
+ def !![P](msg: T, f: R =>? P): () => P =
() => f(this !? msg)
}
diff --git a/src/actors/scala/actors/ReplyableActor.scala b/src/actors/scala/actors/ReplyableActor.scala
index 2122dd854b..b562dbf855 100644
--- a/src/actors/scala/actors/ReplyableActor.scala
+++ b/src/actors/scala/actors/ReplyableActor.scala
@@ -62,7 +62,7 @@ private[actors] trait ReplyableActor extends ReplyableReactor {
* <code>f</code>. This also allows to recover a more
* precise type for the reply value.
*/
- override def !![A](msg: Any, f: PartialFunction[Any, A]): Future[A] = {
+ override def !![A](msg: Any, f: Any =>? A): Future[A] = {
val ftch = new Channel[A](Actor.self(thiz.scheduler))
thiz.send(msg, new OutputChannel[Any] {
def !(msg: Any) =
@@ -108,7 +108,7 @@ private[actors] trait ReplyableActor extends ReplyableReactor {
Futures.fromInputChannel(someChan)
}
// should never be invoked; return dummy value
- override def !![A](msg: Any, f: PartialFunction[Any, A]): Future[A] = {
+ override def !![A](msg: Any, f: Any =>? A): Future[A] = {
val someChan = new Channel[A](Actor.self(thiz.scheduler))
Futures.fromInputChannel(someChan)
}
@@ -117,7 +117,7 @@ private[actors] trait ReplyableActor extends ReplyableReactor {
thiz.send(msg, linkedChannel)
new Future[Any](ftch) {
var exitReason: Option[Any] = None
- val handleReply: PartialFunction[Any, Unit] = {
+ val handleReply: Any =>? Unit = {
case Exit(from, reason) =>
exitReason = Some(reason)
case any =>
@@ -145,7 +145,7 @@ private[actors] trait ReplyableActor extends ReplyableReactor {
def isSet = (fvalue match {
case None =>
- val handleTimeout: PartialFunction[Any, Boolean] = {
+ val handleTimeout: Any =>? Boolean = {
case TIMEOUT =>
false
}
diff --git a/src/actors/scala/actors/ReplyableReactor.scala b/src/actors/scala/actors/ReplyableReactor.scala
index ecca50e26d..f5a2752f54 100644
--- a/src/actors/scala/actors/ReplyableReactor.scala
+++ b/src/actors/scala/actors/ReplyableReactor.scala
@@ -70,7 +70,7 @@ private[actors] trait ReplyableReactor extends Replyable[Any, Any] {
* <code>f</code>. This also allows to recover a more
* precise type for the reply value.
*/
- override def !![A](msg: Any, f: PartialFunction[Any, A]): Future[A] = {
+ override def !![A](msg: Any, f: Any =>? A): Future[A] = {
val myself = Actor.rawSelf(this.scheduler)
val ftch = new ReactChannel[A](myself)
val res = new scala.concurrent.SyncVar[A]
diff --git a/src/actors/scala/actors/remote/Proxy.scala b/src/actors/scala/actors/remote/Proxy.scala
index f9a6cd8fed..c1744a2dfc 100644
--- a/src/actors/scala/actors/remote/Proxy.scala
+++ b/src/actors/scala/actors/remote/Proxy.scala
@@ -69,7 +69,7 @@ private[remote] class Proxy(node: Node, name: Symbol, @transient var kernel: Net
override def !!(msg: Any): Future[Any] =
del !! msg
- override def !![A](msg: Any, f: PartialFunction[Any, A]): Future[A] =
+ override def !![A](msg: Any, f: Any =>? A): Future[A] =
del !! (msg, f)
def linkTo(to: AbstractActor): Unit =
diff --git a/src/actors/scala/actors/scheduler/ThreadPoolConfig.scala b/src/actors/scala/actors/scheduler/ThreadPoolConfig.scala
index 5ffbc80421..93112ae80a 100644
--- a/src/actors/scala/actors/scheduler/ThreadPoolConfig.scala
+++ b/src/actors/scala/actors/scheduler/ThreadPoolConfig.scala
@@ -36,10 +36,12 @@ object ThreadPoolConfig {
}
}
- val maxPoolSize = getIntegerProp("actors.maxPoolSize") match {
- case Some(i) if (i >= corePoolSize) => i
- case Some(i) if (i < corePoolSize) => corePoolSize
- case _ => 256
+ val maxPoolSize = {
+ val preMaxSize = getIntegerProp("actors.maxPoolSize") match {
+ case Some(i) => i
+ case _ => 256
+ }
+ if (preMaxSize >= corePoolSize) preMaxSize else corePoolSize
}
private[actors] def useForkJoin: Boolean =
diff --git a/src/compiler/scala/tools/nsc/ast/parser/BracePatch.scala b/src/compiler/scala/tools/nsc/ast/parser/BracePatch.scala
index 0ef4374a9b..803f35d9cd 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/BracePatch.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/BracePatch.scala
@@ -10,3 +10,4 @@ package ast.parser
* @param inserted If true, brace needs to be inserted, otherwise brace needs to be deleted.
*/
case class BracePatch(off: Int, inserted: Boolean)
+extends Patch(off, if (inserted) Insertion("{") else Deletion(1)) \ No newline at end of file
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Change.scala b/src/compiler/scala/tools/nsc/ast/parser/Change.scala
new file mode 100644
index 0000000000..12f189ac6b
--- /dev/null
+++ b/src/compiler/scala/tools/nsc/ast/parser/Change.scala
@@ -0,0 +1,10 @@
+/* NSC -- new Scala compiler
+ * Copyright 2005-2010 LAMP/EPFL
+ * @author Martin Odersky
+ */
+package scala.tools.nsc.ast.parser
+
+abstract class Change
+case class Insertion(text: String) extends Change
+case class Deletion(nchars: Int) extends Change
+
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Patch.scala b/src/compiler/scala/tools/nsc/ast/parser/Patch.scala
new file mode 100644
index 0000000000..a55f84151c
--- /dev/null
+++ b/src/compiler/scala/tools/nsc/ast/parser/Patch.scala
@@ -0,0 +1,8 @@
+/* NSC -- new Scala compiler
+ * Copyright 2005-2010 LAMP/EPFL
+ * @author Martin Odersky
+ */
+package scala.tools.nsc.ast.parser
+
+class Patch(off: Int, change: Change)
+
diff --git a/src/compiler/scala/tools/nsc/interactive/RichCompilationUnits.scala b/src/compiler/scala/tools/nsc/interactive/RichCompilationUnits.scala
index 5c71ab4f73..40f9209c1b 100644
--- a/src/compiler/scala/tools/nsc/interactive/RichCompilationUnits.scala
+++ b/src/compiler/scala/tools/nsc/interactive/RichCompilationUnits.scala
@@ -40,6 +40,5 @@ trait RichCompilationUnits { self: Global =>
def targetPos_=(p: Position) { _targetPos = p }
var contexts: Contexts = new Contexts
-
}
}
diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
index e1cf7a5a7e..7a77095293 100644
--- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
@@ -19,7 +19,7 @@ trait Definitions {
// Working around bug #2133
private object definitionHelpers {
- def cond[T](x: T)(f: PartialFunction[T, Boolean]) = (f isDefinedAt x) && f(x)
+ def cond[T](x: T)(f: T =>? Boolean) = (f isDefinedAt x) && f(x)
}
import definitionHelpers._
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala
index c4772b6407..d87a30f847 100644
--- a/src/compiler/scala/tools/nsc/symtab/Types.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Types.scala
@@ -2312,7 +2312,9 @@ A type's typeSymbol should never be inspected directly.
/** The canonical creator for this-types */
def mkThisType(sym: Symbol): Type = {
- if (phase.erasedTypes) sym.tpe else unique(new ThisType(sym) with UniqueType)
+ if (!phase.erasedTypes) unique(new ThisType(sym) with UniqueType)
+ else if (sym.isImplClass) sym.typeOfThis
+ else sym.tpe
}
/** The canonical creator for single-types */
@@ -4031,6 +4033,7 @@ A type's typeSymbol should never be inspected directly.
/** Does type `tp1' conform to `tp2'?
*/
private def isSubType2(tp1: Type, tp2: Type, depth: Int): Boolean = {
+ if (tp1 eq tp2) return true
if (isErrorOrWildcard(tp1)) return true
if (isErrorOrWildcard(tp2)) return true
if (tp1 eq NoType) return false
@@ -4349,6 +4352,8 @@ A type's typeSymbol should never be inspected directly.
}
tvar.constr.inst = NoType // necessary because hibounds/lobounds may contain tvar
+ //println("solving "+tvar+" "+up+" "+(if (up) (tvar.constr.hiBounds) else tvar.constr.loBounds)+((if (up) (tvar.constr.hiBounds) else tvar.constr.loBounds) map (_.widen)))
+
tvar setInst (
if (up) {
if (depth != AnyDepth) glb(tvar.constr.hiBounds, depth) else glb(tvar.constr.hiBounds)
diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
index cf217dcd23..09ed32253a 100644
--- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala
+++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
@@ -280,7 +280,7 @@ abstract class CleanUp extends Transform with ast.TreeDSL {
val testForBoolean: Tree = (qual IS_OBJ BoxedBooleanClass.tpe)
val testForNumberOrBoolean = testForNumber OR testForBoolean
- val getPrimitiveReplacementForStructuralCall: PartialFunction[Name, (Symbol, Tree)] = {
+ val getPrimitiveReplacementForStructuralCall: Name =>? (Symbol, Tree) = {
val testsForNumber = Map() ++ List(
nme.UNARY_+ -> "positive",
nme.UNARY_- -> "negate",
diff --git a/src/compiler/scala/tools/nsc/transform/TailCalls.scala b/src/compiler/scala/tools/nsc/transform/TailCalls.scala
index cf3b2db53b..1575ec1384 100644
--- a/src/compiler/scala/tools/nsc/transform/TailCalls.scala
+++ b/src/compiler/scala/tools/nsc/transform/TailCalls.scala
@@ -158,7 +158,7 @@ abstract class TailCalls extends Transform
val newCtx = mkContext(ctx)
newCtx.currentMethod = tree.symbol
newCtx.makeLabel()
- val currentClassParam = tree.symbol.newSyntheticValueParam(currentClass.tpe)
+ val currentClassParam = tree.symbol.newSyntheticValueParam(currentClass.typeOfThis)
newCtx.label.setInfo(MethodType(currentClassParam :: tree.symbol.tpe.params, tree.symbol.tpe.finalResultType))
newCtx.tailPos = true
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
index 8c129f66d7..8ea0b69049 100644
--- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala
+++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
@@ -296,11 +296,11 @@ abstract class UnCurry extends InfoTransform with TypingTransformers {
* }
* new $anon()
*
- * transform a function node (x => body) of type PartialFunction[T, R] where
+ * transform a function node (x => body) of type T =>? R where
* body = expr match { case P_i if G_i => E_i }_i=1..n
* to:
*
- * class $anon() extends Object() with PartialFunction[T, R] with ScalaObject {
+ * class $anon() extends Object() with T =>? R with ScalaObject {
* def apply(x: T): R = (expr: @unchecked) match {
* { case P_i if G_i => E_i }_i=1..n
* def isDefinedAt(x: T): boolean = (x: @unchecked) match {
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
index 99fb60ccf4..2acc09b70e 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
@@ -422,6 +422,7 @@ trait Contexts { self: Analyzer =>
||
(accessWithin(ab) || accessWithin(ab.linkedClassOfClass)) &&
(!sym.hasFlag(LOCAL) ||
+ sym.owner.isImplClass || // allow private local accesses to impl classes
(sym hasFlag PROTECTED) && isSubThisType(pre, sym.owner) ||
pre =:= sym.owner.thisType)
||
@@ -506,6 +507,9 @@ trait Contexts { self: Analyzer =>
} else if (imports != nextOuter.imports) {
assert(imports.tail == nextOuter.imports)
collectImplicitImports(imports.head)
+ } else if (owner.isPackageClass) {
+ // the corresponding package object may contain implicit members.
+ collectImplicits(owner.tpe.implicitMembers, owner.tpe)
} else List()
implicitsCache = if (newImplicits.isEmpty) nextOuter.implicitss
else newImplicits :: nextOuter.implicitss
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
index d5bd9c3c3f..40eb72aaeb 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
@@ -1164,7 +1164,7 @@ trait Namers { self: Analyzer =>
val expr1 = typer.typedQualifier(expr)
val base = expr1.tpe
typer.checkStable(expr1)
- if (expr1.symbol.isRootPackage) context.error(tree.pos, "_root_ cannot be imported")
+ if ((expr1.symbol ne null) && expr1.symbol.isRootPackage) context.error(tree.pos, "_root_ cannot be imported")
def checkNotRedundant(pos: Position, from: Name, to: Name): Boolean = {
if (!tree.symbol.hasFlag(SYNTHETIC) &&
!((expr1.symbol ne null) && expr1.symbol.isInterpreterWrapper) &&
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index 4c919f227a..835b6f2024 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -78,7 +78,7 @@ abstract class RefChecks extends InfoTransform {
private def checkDefaultsInOverloaded(clazz: Symbol) {
def check(members: List[Symbol]): Unit = members match {
case x :: xs =>
- if (x.paramss.exists(_.exists(p => p.hasFlag(DEFAULTPARAM)))) {
+ if (x.paramss.exists(_.exists(p => p.hasFlag(DEFAULTPARAM))) && !nme.isProtectedAccessor(x.name)) {
val others = xs.filter(alt => {
alt.name == x.name &&
alt.paramss.exists(_.exists(_.hasFlag(DEFAULTPARAM))) &&
@@ -87,7 +87,7 @@ abstract class RefChecks extends InfoTransform {
if (!others.isEmpty) {
val all = x :: others
val rest = if (all.exists(_.owner != clazz)) ".\nThe members with defaults are defined in "+
- all.map(_.owner).mkString("", " and ", ".")
+ all.map(_.owner).mkString("", " and ", ".") else "."
unit.error(clazz.pos, "in "+ clazz +", multiple overloaded alternatives of "+ x +
" define default arguments"+ rest)
}
@@ -425,7 +425,7 @@ abstract class RefChecks extends InfoTransform {
infoString(member) + " is marked `abstract' and `override'" +
(if (other != NoSymbol)
" and overrides incomplete superclass member " + infoString(other)
- else ""))
+ else ", but no concrete implementation could be found in a base class"))
}
// 3. Check that concrete classes do not have deferred definitions
diff --git a/src/library/scala/Option.scala b/src/library/scala/Option.scala
index 8511fa78a5..6cb0fec929 100644
--- a/src/library/scala/Option.scala
+++ b/src/library/scala/Option.scala
@@ -110,7 +110,7 @@ sealed abstract class Option[+A] extends Product {
*
* @param pf the partial function.
*/
- def partialMap[B](pf: PartialFunction[A, B]): Option[B] =
+ def partialMap[B](pf: A =>? B): Option[B] =
if (!isEmpty && pf.isDefinedAt(this.get)) Some(pf(this.get)) else None
/** If the option is nonempty return it,
diff --git a/src/library/scala/PartialFunction.scala b/src/library/scala/PartialFunction.scala
index 81ca2e4e10..f62fa68565 100644
--- a/src/library/scala/PartialFunction.scala
+++ b/src/library/scala/PartialFunction.scala
@@ -38,7 +38,7 @@ trait PartialFunction[-A, +B] extends (A => B) {
* of this partial function and `that`. The resulting partial function
* takes `x` to `this(x)` where `this` is defined, and to `that(x)` where it is not.
*/
- def orElse[A1 <: A, B1 >: B](that: PartialFunction[A1, B1]) : PartialFunction[A1, B1] =
+ def orElse[A1 <: A, B1 >: B](that: A1 =>? B1) : A1 =>? B1 =
new PartialFunction[A1, B1] {
def isDefinedAt(x: A1): Boolean =
PartialFunction.this.isDefinedAt(x) || that.isDefinedAt(x)
@@ -54,7 +54,7 @@ trait PartialFunction[-A, +B] extends (A => B) {
* @return a partial function with the same domain as this partial function, which maps
* arguments `x` to `k(this(x))`.
*/
- override def andThen[C](k: B => C) : PartialFunction[A, C] = new PartialFunction[A, C] {
+ override def andThen[C](k: B => C): A =>? C = new PartialFunction[A, C] {
def isDefinedAt(x: A): Boolean = PartialFunction.this.isDefinedAt(x)
def apply(x: A): C = k(PartialFunction.this.apply(x))
}
@@ -92,18 +92,18 @@ object PartialFunction
* @param pf the partial function
* @return true, iff `x` is in the domain of `pf` and `pf(x) == true`.
*/
- def cond[T](x: T)(pf: PartialFunction[T, Boolean]): Boolean =
+ def cond[T](x: T)(pf: T =>? Boolean): Boolean =
(pf isDefinedAt x) && pf(x)
- /** Transforms a PartialFunction[T,U] `pf' into Function1[T, Option[U]] `f'
+ /** Transforms a PartialFunction[T, U] `pf' into Function1[T, Option[U]] `f'
* whose result is Some(x) if the argument is in pf's domain and None otherwise,
* and applies it to the value `x'. In effect, it is a 'match' statement
* which wraps all case results in Some(_) and adds 'case _ => None' to the end.
*
* @param x the value to test
- * @param pf the PartialFunction[T,U]
+ * @param pf the PartialFunction[T, U]
* @return `Some(pf(x))` if `pf isDefinedAt x`, `None` otherwise.
*/
- def condOpt[T,U](x: T)(pf: PartialFunction[T, U]): Option[U] =
+ def condOpt[T,U](x: T)(pf: T =>? U): Option[U] =
if (pf isDefinedAt x) Some(pf(x)) else None
}
diff --git a/src/library/scala/collection/Iterator.scala b/src/library/scala/collection/Iterator.scala
index 54a38848dd..5f28161ed3 100644
--- a/src/library/scala/collection/Iterator.scala
+++ b/src/library/scala/collection/Iterator.scala
@@ -411,7 +411,7 @@ trait Iterator[+A] { self =>
* @return a new iterator which yields each value `x` produced by this iterator for
* which `pf` is defined the image `pf(x)`.
*/
- def partialMap[B](pf: PartialFunction[A, B]): Iterator[B] = {
+ def partialMap[B](pf: A =>? B): Iterator[B] = {
val self = buffered
new Iterator[B] {
private def skip() = while (self.hasNext && !pf.isDefinedAt(self.head)) self.next()
diff --git a/src/library/scala/collection/SeqViewLike.scala b/src/library/scala/collection/SeqViewLike.scala
index 66345ed311..1a8cd20013 100644
--- a/src/library/scala/collection/SeqViewLike.scala
+++ b/src/library/scala/collection/SeqViewLike.scala
@@ -117,10 +117,16 @@ trait SeqViewLike[+A,
}
trait Reversed extends Transformed[A] {
- override def iterator: Iterator[A] = self.reverseIterator
+ override def iterator: Iterator[A] = createReversedIterator
override def length: Int = self.length
override def apply(idx: Int): A = self.apply(length - 1 - idx)
override def stringPrefix = self.stringPrefix+"R"
+
+ private def createReversedIterator = {
+ var lst = List[A]()
+ for (elem <- self) lst ::= elem
+ lst.iterator
+ }
}
trait Patched[B >: A] extends Transformed[B] {
@@ -166,6 +172,9 @@ trait SeqViewLike[+A,
override def padTo[B >: A, That](len: Int, elem: B)(implicit bf: CanBuildFrom[This, B, That]): That =
patch(length, fill(len - length)(elem), 0)
+ override def reverseMap[B, That](f: A => B)(implicit bf: CanBuildFrom[This, B, That]): That =
+ reverse.map(f)
+
override def stringPrefix = "SeqView"
}
diff --git a/src/library/scala/collection/TraversableLike.scala b/src/library/scala/collection/TraversableLike.scala
index 8c8f619b5e..f570c4ca9a 100644
--- a/src/library/scala/collection/TraversableLike.scala
+++ b/src/library/scala/collection/TraversableLike.scala
@@ -292,13 +292,13 @@ self =>
* `pf` to each element on which it is defined and collecting the results.
* The order of the elements is preserved.
*
- * @usecase def partialMap[B](pf: PartialFunction[A, B]): $Coll[B]
+ * @usecase def partialMap[B](pf: A =>? B): $Coll[B]
*
* @return a new $coll resulting from applying the given partial function
* `pf` to each element on which it is defined and collecting the results.
* The order of the elements is preserved.
*/
- def partialMap[B, That](pf: PartialFunction[A, B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
+ def partialMap[B, That](pf: A =>? B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
val b = bf(repr)
for (x <- this) if (pf.isDefinedAt(x)) b += pf(x)
b.result
diff --git a/src/library/scala/collection/TraversableProxyLike.scala b/src/library/scala/collection/TraversableProxyLike.scala
index 24d6c7048d..d8e3ed2a1b 100644
--- a/src/library/scala/collection/TraversableProxyLike.scala
+++ b/src/library/scala/collection/TraversableProxyLike.scala
@@ -36,7 +36,7 @@ trait TraversableProxyLike[+A, +This <: TraversableLike[A, This] with Traversabl
override def ++[B >: A, That](that: Iterator[B])(implicit bf: CanBuildFrom[This, B, That]): That = self.++(that)(bf)
override def map[B, That](f: A => B)(implicit bf: CanBuildFrom[This, B, That]): That = self.map(f)(bf)
override def flatMap[B, That](f: A => Traversable[B])(implicit bf: CanBuildFrom[This, B, That]): That = self.flatMap(f)(bf)
- override def partialMap[B, That](pf: PartialFunction[A, B])(implicit bf: CanBuildFrom[This, B, That]): That = self.partialMap(pf)(bf)
+ override def partialMap[B, That](pf: A =>? B)(implicit bf: CanBuildFrom[This, B, That]): That = self.partialMap(pf)(bf)
override def filter(p: A => Boolean): This = self.filter(p)
override def filterNot(p: A => Boolean): This = self.filterNot(p)
override def partition(p: A => Boolean): (This, This) = self.partition(p)
diff --git a/src/library/scala/collection/interfaces/TraversableMethods.scala b/src/library/scala/collection/interfaces/TraversableMethods.scala
index 08ade7586d..4cf133d36a 100644
--- a/src/library/scala/collection/interfaces/TraversableMethods.scala
+++ b/src/library/scala/collection/interfaces/TraversableMethods.scala
@@ -24,7 +24,7 @@ trait TraversableMethods[+A, +This <: TraversableLike[A, This] with Traversable[
// maps/iteration
def flatMap[B, That](f: A => Traversable[B])(implicit bf: CanBuildFrom[This, B, That]): That
def map[B, That](f: A => B)(implicit bf: CanBuildFrom[This, B, That]): That
- def partialMap[B, That](pf: PartialFunction[A, B])(implicit bf: CanBuildFrom[This, B, That]): That
+ def partialMap[B, That](pf: A =>? B)(implicit bf: CanBuildFrom[This, B, That]): That
// new collections
def ++[B >: A, That](that: Iterator[B])(implicit bf: CanBuildFrom[This, B, That]): That
diff --git a/src/library/scala/collection/mutable/Publisher.scala b/src/library/scala/collection/mutable/Publisher.scala
index da3e0c8238..4f675eff9f 100644
--- a/src/library/scala/collection/mutable/Publisher.scala
+++ b/src/library/scala/collection/mutable/Publisher.scala
@@ -48,7 +48,8 @@ trait Publisher[Evt] {
protected def publish(event: Evt) {
filters.keysIterator.foreach(sub =>
- if (filters.entryExists(sub, p => p(event)))
+ if (!suspended.contains(sub) &&
+ filters.entryExists(sub, p => p(event)))
sub.notify(self, event)
)
}
diff --git a/src/library/scala/concurrent/MailBox.scala b/src/library/scala/concurrent/MailBox.scala
index c23bbf1c80..3b00d6165d 100644
--- a/src/library/scala/concurrent/MailBox.scala
+++ b/src/library/scala/concurrent/MailBox.scala
@@ -26,7 +26,7 @@ class MailBox extends AnyRef with ListQueueCreator {
def isDefinedAt(msg: Message): Boolean
}
- private class Receiver[A](receiver: PartialFunction[Message, A]) extends PreReceiver {
+ private class Receiver[A](receiver: Message =>? A) extends PreReceiver {
def isDefinedAt(msg: Message) = receiver.isDefinedAt(msg)
@@ -85,7 +85,7 @@ class MailBox extends AnyRef with ListQueueCreator {
* Block until there is a message in the mailbox for which the processor
* <code>f</code> is defined.
*/
- def receive[A](f: PartialFunction[Message, A]): A = {
+ def receive[A](f: Message =>? A): A = {
val r = new Receiver(f)
scanSentMsgs(r)
r.receive()
@@ -95,7 +95,7 @@ class MailBox extends AnyRef with ListQueueCreator {
* Block until there is a message in the mailbox for which the processor
* <code>f</code> is defined or the timeout is over.
*/
- def receiveWithin[A](msec: Long)(f: PartialFunction[Message, A]): A = {
+ def receiveWithin[A](msec: Long)(f: Message =>? A): A = {
val r = new Receiver(f)
scanSentMsgs(r)
r.receiveWithin(msec)
diff --git a/src/library/scala/package.scala b/src/library/scala/package.scala
index 9fa09e3b72..bc5b5d36f2 100644
--- a/src/library/scala/package.scala
+++ b/src/library/scala/package.scala
@@ -64,6 +64,8 @@ package object scala {
type Range = scala.collection.immutable.Range
val Range = scala.collection.immutable.Range
+ type =>? [-A, +B] = PartialFunction[A, B]
+
// Migrated from Predef
val $scope = scala.xml.TopScope
diff --git a/src/library/scala/runtime/ScalaRunTime.scala b/src/library/scala/runtime/ScalaRunTime.scala
index f6c4cf79dc..ebce675347 100644
--- a/src/library/scala/runtime/ScalaRunTime.scala
+++ b/src/library/scala/runtime/ScalaRunTime.scala
@@ -30,13 +30,49 @@ object ScalaRunTime {
def isValueClass(clazz: Class[_]) = clazz.isPrimitive()
/** Retrieve generic array element */
- def array_apply(xs: AnyRef, idx: Int): Any = java.lang.reflect.Array.get(xs, idx)
+ def array_apply(xs: AnyRef, idx: Int): Any = xs match {
+ case x: Array[AnyRef] => x(idx).asInstanceOf[Any]
+ case x: Array[Int] => x(idx).asInstanceOf[Any]
+ case x: Array[Double] => x(idx).asInstanceOf[Any]
+ case x: Array[Long] => x(idx).asInstanceOf[Any]
+ case x: Array[Float] => x(idx).asInstanceOf[Any]
+ case x: Array[Char] => x(idx).asInstanceOf[Any]
+ case x: Array[Byte] => x(idx).asInstanceOf[Any]
+ case x: Array[Short] => x(idx).asInstanceOf[Any]
+ case x: Array[Boolean] => x(idx).asInstanceOf[Any]
+ case x: Array[Unit] => x(idx).asInstanceOf[Any]
+ case null => throw new NullPointerException
+ }
/** update generic array element */
- def array_update(xs: AnyRef, idx: Int, value: Any): Unit = java.lang.reflect.Array.set(xs, idx, value)
+ def array_update(xs: AnyRef, idx: Int, value: Any): Unit = xs match {
+ case x: Array[AnyRef] => x(idx) = value.asInstanceOf[AnyRef]
+ case x: Array[Int] => x(idx) = value.asInstanceOf[Int]
+ case x: Array[Double] => x(idx) = value.asInstanceOf[Double]
+ case x: Array[Long] => x(idx) = value.asInstanceOf[Long]
+ case x: Array[Float] => x(idx) = value.asInstanceOf[Float]
+ case x: Array[Char] => x(idx) = value.asInstanceOf[Char]
+ case x: Array[Byte] => x(idx) = value.asInstanceOf[Byte]
+ case x: Array[Short] => x(idx) = value.asInstanceOf[Short]
+ case x: Array[Boolean] => x(idx) = value.asInstanceOf[Boolean]
+ case x: Array[Unit] => x(idx) = value.asInstanceOf[Unit]
+ case null => throw new NullPointerException
+ }
/** Get generic array length */
- def array_length(xs: AnyRef): Int = java.lang.reflect.Array.getLength(xs)
+ def array_length(xs: AnyRef): Int = xs match {
+ case x: Array[AnyRef] => x.length
+ case x: Array[Int] => x.length
+ case x: Array[Double] => x.length
+ case x: Array[Long] => x.length
+ case x: Array[Float] => x.length
+ case x: Array[Char] => x.length
+ case x: Array[Byte] => x.length
+ case x: Array[Short] => x.length
+ case x: Array[Boolean] => x.length
+ case x: Array[Unit] => x.length
+ case null => throw new NullPointerException
+ }
/** Convert a numeric value array to an object array.
* Needed to deal with vararg arguments of primtive types that are passed
@@ -64,7 +100,7 @@ object ScalaRunTime {
if (x == null) throw new UninitializedError else x
abstract class Try[+A] {
- def Catch[B >: A](handler: PartialFunction[Throwable, B]): B
+ def Catch[B >: A](handler: Throwable =>? B): B
def Finally(fin: => Unit): A
}
@@ -79,7 +115,7 @@ object ScalaRunTime {
def run() { result = block }
- def Catch[B >: A](handler: PartialFunction[Throwable, B]): B =
+ def Catch[B >: A](handler: Throwable =>? B): B =
if (exception == null) result
else if (handler isDefinedAt exception) handler(exception)
else throw exception
diff --git a/src/library/scala/util/control/Exception.scala b/src/library/scala/util/control/Exception.scala
index 356b11df51..67f9ec183b 100644
--- a/src/library/scala/util/control/Exception.scala
+++ b/src/library/scala/util/control/Exception.scala
@@ -23,14 +23,14 @@ object Exception
// We get lots of crashes using this, so for now we just use Class[_]
// type ExClass = Class[_ <: Throwable]
- type Catcher[+T] = PartialFunction[Throwable, T]
- type ExceptionCatcher[+T] = PartialFunction[Exception, T]
+ type Catcher[+T] = Throwable =>? T
+ type ExceptionCatcher[+T] = Exception =>? T
// due to the magic of contravariance, Throwable => T is a subtype of
// Exception => T, not the other way around. So we manually construct
// a Throwable => T and simply rethrow the non-Exceptions.
implicit def fromExceptionCatcher[T](pf: ExceptionCatcher[T]): Catcher[T] = {
- new PartialFunction[Throwable, T] {
+ new (Throwable =>? T) {
def isDefinedAt(x: Throwable) = x match {
case e: Exception if pf.isDefinedAt(e) => true
case _ => false
@@ -101,7 +101,7 @@ object Exception
/** Create a new Catch with the same isDefinedAt logic as this one,
* but with the supplied apply method replacing the current one. */
def withApply[U](f: (Throwable) => U): Catch[U] = {
- val pf2 = new PartialFunction[Throwable, U] {
+ val pf2 = new (Throwable =>? U) {
def isDefinedAt(x: Throwable) = pf isDefinedAt x
def apply(x: Throwable) = f(x)
}
@@ -139,8 +139,8 @@ object Exception
override def toString() = List("Try(<body>)", catcher.toString) mkString " "
}
- final val nothingCatcher: PartialFunction[Throwable, Nothing] =
- new PartialFunction[Throwable, Nothing] {
+ final val nothingCatcher: Throwable =>? Nothing =
+ new (Throwable =>? Nothing) {
def isDefinedAt(x: Throwable) = false
def apply(x: Throwable) = throw x
}
@@ -207,7 +207,7 @@ object Exception
classes exists (_ isAssignableFrom x.getClass)
private def pfFromExceptions(exceptions: Class[_]*) =
- new PartialFunction[Throwable, Nothing] {
+ new (Throwable =>? Nothing) {
def apply(x: Throwable) = throw x
def isDefinedAt(x: Throwable) = wouldMatch(x, exceptions)
}
diff --git a/src/library/scala/util/parsing/combinator/Parsers.scala b/src/library/scala/util/parsing/combinator/Parsers.scala
index 3aa7cc7de1..1205d2f911 100644
--- a/src/library/scala/util/parsing/combinator/Parsers.scala
+++ b/src/library/scala/util/parsing/combinator/Parsers.scala
@@ -93,7 +93,7 @@ trait Parsers {
* `f' applied to the result of this `ParseResult', packaged up as a new `ParseResult'.
* If `f' is not defined, `Failure'.
*/
- def mapPartial[U](f: PartialFunction[T, U], error: T => String): ParseResult[U]
+ def mapPartial[U](f: T =>? U, error: T => String): ParseResult[U]
def flatMapWithNext[U](f: T => Input => ParseResult[U]): ParseResult[U]
@@ -119,7 +119,7 @@ trait Parsers {
*/
case class Success[+T](result: T, override val next: Input) extends ParseResult[T] {
def map[U](f: T => U) = Success(f(result), next)
- def mapPartial[U](f: PartialFunction[T, U], error: T => String): ParseResult[U]
+ def mapPartial[U](f: T =>? U, error: T => String): ParseResult[U]
= if(f.isDefinedAt(result)) Success(f(result), next)
else Failure(error(result), next)
@@ -146,7 +146,7 @@ trait Parsers {
lastNoSuccess = this
def map[U](f: Nothing => U) = this
- def mapPartial[U](f: PartialFunction[Nothing, U], error: Nothing => String): ParseResult[U] = this
+ def mapPartial[U](f: Nothing =>? U, error: Nothing => String): ParseResult[U] = this
def flatMapWithNext[U](f: Nothing => Input => ParseResult[U]): ParseResult[U]
= this
@@ -345,7 +345,7 @@ trait Parsers {
* @return a parser that succeeds if the current parser succeeds <i>and</i> `f' is applicable
* to the result. If so, the result will be transformed by `f'.
*/
- def ^? [U](f: PartialFunction[T, U], error: T => String): Parser[U] = Parser{ in =>
+ def ^? [U](f: T =>? U, error: T => String): Parser[U] = Parser{ in =>
this(in).mapPartial(f, error)}.named(toString+"^?")
/** A parser combinator for partial function application
@@ -358,7 +358,7 @@ trait Parsers {
* @return a parser that succeeds if the current parser succeeds <i>and</i> `f' is applicable
* to the result. If so, the result will be transformed by `f'.
*/
- def ^? [U](f: PartialFunction[T, U]): Parser[U] = ^?(f, r => "Constructor function not defined at "+r)
+ def ^? [U](f: T =>? U): Parser[U] = ^?(f, r => "Constructor function not defined at "+r)
/** A parser combinator that parameterises a subsequent parser with the result of this one
@@ -495,7 +495,7 @@ trait Parsers {
* @return A parser that succeeds if `f' is applicable to the first element of the input,
* applying `f' to it to produce the result.
*/
- def accept[U](expected: String, f: PartialFunction[Elem, U]): Parser[U] = acceptMatch(expected, f)
+ def accept[U](expected: String, f: Elem =>? U): Parser[U] = acceptMatch(expected, f)
def acceptIf(p: Elem => Boolean)(err: Elem => String): Parser[Elem] = Parser { in =>
@@ -503,7 +503,7 @@ trait Parsers {
else Failure(err(in.first), in)
}
- def acceptMatch[U](expected: String, f: PartialFunction[Elem, U]): Parser[U] = Parser{ in =>
+ def acceptMatch[U](expected: String, f: Elem =>? U): Parser[U] = Parser{ in =>
if (f.isDefinedAt(in.first)) Success(f(in.first), in.rest)
else Failure(expected+" expected", in)
}
diff --git a/src/scalap/scala/tools/scalap/scalax/rules/Rule.scala b/src/scalap/scala/tools/scalap/scalax/rules/Rule.scala
index 1500b81050..f65c688aa7 100644
--- a/src/scalap/scala/tools/scalap/scalax/rules/Rule.scala
+++ b/src/scalap/scala/tools/scalap/scalax/rules/Rule.scala
@@ -56,9 +56,9 @@ trait Rule[-In, +Out, +A, +X] extends (In => Result[Out, A, X]) {
def ^^[B](fa2b : A => B) = map(fa2b)
- def ^^?[B](pf : PartialFunction[A, B]) = filter (pf.isDefinedAt(_)) ^^ pf
+ def ^^?[B](pf : A =>? B) = filter (pf.isDefinedAt(_)) ^^ pf
- def ??(pf : PartialFunction[A, Any]) = filter (pf.isDefinedAt(_))
+ def ??(pf : A =>? Any) = filter (pf.isDefinedAt(_))
def -^[B](b : B) = map { any => b }
@@ -73,7 +73,7 @@ trait Rule[-In, +Out, +A, +X] extends (In => Result[Out, A, X]) {
def >->[Out2, B, X2 >: X](fa2resultb : A => Result[Out2, B, X2]) = flatMap { a => any => fa2resultb(a) }
- def >>?[Out2, B, X2 >: X](pf : PartialFunction[A, Rule[Out, Out2, B, X2]]) = filter(pf isDefinedAt _) flatMap pf
+ def >>?[Out2, B, X2 >: X](pf : A =>? Rule[Out, Out2, B, X2]) = filter(pf isDefinedAt _) flatMap pf
def >>&[B, X2 >: X](fa2ruleb : A => Out => Result[Any, B, X2]) = flatMap { a => out => fa2ruleb(a)(out) mapOut { any => out } }
diff --git a/src/swing/scala/swing/Reactions.scala b/src/swing/scala/swing/Reactions.scala
index 14d4deb981..a2327d7b18 100644
--- a/src/swing/scala/swing/Reactions.scala
+++ b/src/swing/scala/swing/Reactions.scala
@@ -27,7 +27,7 @@ object Reactions {
}
}
- type Reaction = PartialFunction[Event, Unit]
+ type Reaction = Event =>? Unit
/**
* A Reaction implementing this trait is strongly referenced in the reaction list
diff --git a/test/files/jvm/future-awaitall-zero.check b/test/files/jvm/future-awaitall-zero.check
new file mode 100644
index 0000000000..d86bac9de5
--- /dev/null
+++ b/test/files/jvm/future-awaitall-zero.check
@@ -0,0 +1 @@
+OK
diff --git a/test/files/jvm/future-awaitall-zero.scala b/test/files/jvm/future-awaitall-zero.scala
new file mode 100644
index 0000000000..49c51f2c7e
--- /dev/null
+++ b/test/files/jvm/future-awaitall-zero.scala
@@ -0,0 +1,17 @@
+import scala.actors.Futures._
+import scala.actors.Actor._
+
+object Test {
+ def main(args: Array[String]) {
+ val ft1 = future { reactWithin(1000) {
+ case _ => println("FAIL")
+ } }
+
+ val ft2 = future { reactWithin(2000) {
+ case _ => println("FAIL")
+ } }
+
+ val res = awaitAll(0, ft1, ft2)
+ println("OK")
+ }
+}
diff --git a/test/files/jvm/t1449.check b/test/files/jvm/t1449.check
new file mode 100644
index 0000000000..d81cc0710e
--- /dev/null
+++ b/test/files/jvm/t1449.check
@@ -0,0 +1 @@
+42
diff --git a/test/files/jvm/t1449.scala b/test/files/jvm/t1449.scala
new file mode 100644
index 0000000000..08c153afc0
--- /dev/null
+++ b/test/files/jvm/t1449.scala
@@ -0,0 +1,15 @@
+import scala.actors.Actor._
+import scala.actors.Future
+import scala.actors.Futures._
+object Test {
+ def main(args: Array[String]) {
+ val a = actor {
+ react {
+ case ft: Future[a] =>
+ println(ft())
+ }
+ }
+ val ft = future { 42 }
+ a ! ft
+ }
+}
diff --git a/test/files/neg/names-defaults-neg-ref.check b/test/files/neg/names-defaults-neg-ref.check
index ac37816762..00052c72dc 100644
--- a/test/files/neg/names-defaults-neg-ref.check
+++ b/test/files/neg/names-defaults-neg-ref.check
@@ -2,7 +2,7 @@ names-defaults-neg-ref.scala:3: error: in anonymous class $anon, multiple overlo
The members with defaults are defined in trait B2235 and trait A2235.
new A2235 with B2235
^
-names-defaults-neg-ref.scala:7: error: in class A, multiple overloaded alternatives of method foo define default arguments()
+names-defaults-neg-ref.scala:7: error: in class A, multiple overloaded alternatives of method foo define default arguments.
class A {
^
names-defaults-neg-ref.scala:17: error: in class C, multiple overloaded alternatives of method bar define default arguments.
diff --git a/test/files/pos/t2809.scala b/test/files/pos/t2809.scala
new file mode 100644
index 0000000000..1f68b0b07a
--- /dev/null
+++ b/test/files/pos/t2809.scala
@@ -0,0 +1,20 @@
+package p1 {
+ abstract class T1 {
+ protected def bug(p: Int = 1): Int // without 'protected' compiles fine
+ }
+}
+package p2 { // all being in the same package compiles fine
+ import p1._
+ abstract class T2 extends T1 {
+ class A {
+ bug()
+ }
+ }
+
+ abstract class T3 extends T2 {
+ class A {
+ bug()
+ }
+ }
+}
+
diff --git a/test/files/run/ReverseSeqView.scala b/test/files/run/ReverseSeqView.scala
new file mode 100644
index 0000000000..836e4d6a1f
--- /dev/null
+++ b/test/files/run/ReverseSeqView.scala
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+object Test extends Application {
+
+ val lstv = List(1, 2, 3).view
+ val lstvr = lstv.reverse
+ assert(lstvr.iterator.toList == List(3, 2, 1))
+ assert(lstvr.reverse == List(1, 2, 3))
+ assert(lstvr.reverseIterator.toList == List(1, 2, 3))
+ assert(lstvr.reverseMap(_ + 1) == List(2, 3, 4))
+
+}
+
+
+
+
+
+
+
+
+