From a7276d5976f57d4f182a55f92693de97acf1de64 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Wed, 24 Oct 2012 13:23:54 -0700 Subject: New take on SI-6534, value classes. Don't prohibit equals and hashCode in universal traits; instead, always override them in value classes. --- test/files/neg/t6534.check | 14 ++++++++++++++ test/files/neg/t6534.flags | 1 + test/files/neg/t6534.scala | 7 +++++++ test/files/run/t6534.scala | 14 ++++++++++++++ 4 files changed, 36 insertions(+) create mode 100644 test/files/neg/t6534.check create mode 100644 test/files/neg/t6534.flags create mode 100644 test/files/neg/t6534.scala create mode 100644 test/files/run/t6534.scala (limited to 'test/files') diff --git a/test/files/neg/t6534.check b/test/files/neg/t6534.check new file mode 100644 index 0000000000..bd7dc4b71c --- /dev/null +++ b/test/files/neg/t6534.check @@ -0,0 +1,14 @@ +t6534.scala:4: warning: Implementation of equals inherited from trait Foo overridden in class Bippy1 to enforce value class semantics +class Bippy1(val x: Int) extends AnyVal with Foo { } // warn + ^ +t6534.scala:5: warning: Implementation of hashCode inherited from trait Ding overridden in class Bippy2 to enforce value class semantics +class Bippy2(val x: Int) extends AnyVal with Ding { } // warn + ^ +t6534.scala:6: error: redefinition of equals method. See SIP-15, criterion 4. is not allowed in value class +class Bippy3(val x: Int) extends AnyVal { override def equals(x: Any) = false } // error + ^ +t6534.scala:7: error: redefinition of hashCode method. See SIP-15, criterion 4. is not allowed in value class +class Bippy4(val x: Int) extends AnyVal { override def hashCode = -1 } // error + ^ +two warnings found +two errors found diff --git a/test/files/neg/t6534.flags b/test/files/neg/t6534.flags new file mode 100644 index 0000000000..1008b0a70c --- /dev/null +++ b/test/files/neg/t6534.flags @@ -0,0 +1 @@ +-Xlint diff --git a/test/files/neg/t6534.scala b/test/files/neg/t6534.scala new file mode 100644 index 0000000000..a193179399 --- /dev/null +++ b/test/files/neg/t6534.scala @@ -0,0 +1,7 @@ +trait Foo extends Any { override def equals(x: Any) = false } +trait Ding extends Any { override def hashCode = -1 } + +class Bippy1(val x: Int) extends AnyVal with Foo { } // warn +class Bippy2(val x: Int) extends AnyVal with Ding { } // warn +class Bippy3(val x: Int) extends AnyVal { override def equals(x: Any) = false } // error +class Bippy4(val x: Int) extends AnyVal { override def hashCode = -1 } // error diff --git a/test/files/run/t6534.scala b/test/files/run/t6534.scala new file mode 100644 index 0000000000..33df97e41e --- /dev/null +++ b/test/files/run/t6534.scala @@ -0,0 +1,14 @@ +trait Foo extends Any { override def equals(x: Any) = false } +trait Ding extends Any { override def hashCode = -1 } + +class Bippy1(val x: Int) extends AnyVal with Foo { } // warn +class Bippy2(val x: Int) extends AnyVal with Ding { } // warn + +object Test { + def main(args: Array[String]): Unit = { + val b1 = new Bippy1(71) + val b2 = new Bippy2(71) + assert(b1 == b1 && b1.## == b1.x.##, ((b1, b1.##))) + assert(b2 == b2 && b2.## == b2.x.##, ((b2, b2.##))) + } +} -- cgit v1.2.3 From c7c79c83b5a7560df60ba9b4578bbce02514a22a Mon Sep 17 00:00:00 2001 From: Declan Conlon Date: Wed, 10 Oct 2012 11:34:26 +1100 Subject: SI-6488: Stop I/O threads prior to Process destruction --- src/library/scala/sys/process/ProcessImpl.scala | 5 ++++- test/files/run/t6488.check | 1 + test/files/run/t6488.scala | 11 +++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 test/files/run/t6488.check create mode 100644 test/files/run/t6488.scala (limited to 'test/files') diff --git a/src/library/scala/sys/process/ProcessImpl.scala b/src/library/scala/sys/process/ProcessImpl.scala index cdf7d72caa..84ef5f277b 100644 --- a/src/library/scala/sys/process/ProcessImpl.scala +++ b/src/library/scala/sys/process/ProcessImpl.scala @@ -222,7 +222,10 @@ private[process] trait ProcessImpl { p.exitValue() } override def destroy() = { - try p.destroy() + try{ + outputThreads foreach (_.stop()) + p.destroy() + } finally inputThread.interrupt() } } diff --git a/test/files/run/t6488.check b/test/files/run/t6488.check new file mode 100644 index 0000000000..35821117c8 --- /dev/null +++ b/test/files/run/t6488.check @@ -0,0 +1 @@ +Success diff --git a/test/files/run/t6488.scala b/test/files/run/t6488.scala new file mode 100644 index 0000000000..487614ecfd --- /dev/null +++ b/test/files/run/t6488.scala @@ -0,0 +1,11 @@ +import sys.process._ +object Test { + // Program that prints "Success" if the command was successfully run then destroyed + // It will silently pass if the command "/bin/ls" does not exist + // It will fail due to the uncatchable exception in t6488 race condition + def main(args: Array[String]) { + try Process("/bin/ls").run(ProcessLogger { _ => () }).destroy + catch { case _ => () } + println("Success") + } +} -- cgit v1.2.3 From 0527b2549bcada2fda2201daa630369b377d0877 Mon Sep 17 00:00:00 2001 From: Hubert Plociniczak Date: Sun, 28 Oct 2012 18:57:30 +0100 Subject: Fixes SI-5031 for separate compilation scenario. When you have a conflicting member in package object and normal package that share the same namespace we remove the latter ClassSymbol from the scope. Now, this has an unpleasant consequence that companionClass/companionModule/companionSymbol no longer work correctly as they rely on finding the correspondent symbol using decls of the owner. This fixes the problem of SI-5031 for separate compilation. Why the above change matters for finding foo.bar.Foo? Because when parsing the class we needed information about the static module (and we have the correct module symbol when completing the info). It's just that 043ce6d0565c9d5d960 relied on no longer valid assumptions. So we were getting NoSymbol and sym.exist was failing. Obviously a more complete solution would be better if we didn't rely on the scope but that's too big to change for 2.10.0. --- src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala | 5 +++-- src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala | 5 ++++- test/files/pos/t5031_3/Foo_1.scala | 5 +++++ test/files/pos/t5031_3/Main_2.scala | 6 ++++++ test/files/pos/t5031_3/package.scala | 6 ++++++ 5 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 test/files/pos/t5031_3/Foo_1.scala create mode 100644 test/files/pos/t5031_3/Main_2.scala create mode 100644 test/files/pos/t5031_3/package.scala (limited to 'test/files') diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala index f9eeb41e6d..6d7948f0a9 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala @@ -558,7 +558,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters { def innerClassSymbolFor(s: Symbol): Symbol = if (s.isClass) s else if (s.isModule) s.moduleClass else NoSymbol - /** Return the a name of this symbol that can be used on the Java platform. It removes spaces from names. + /** Return the name of this symbol that can be used on the Java platform. It removes spaces from names. * * Special handling: * scala.Nothing erases to scala.runtime.Nothing$ @@ -607,7 +607,8 @@ abstract class GenASM extends SubComponent with BytecodeWriters { case None => reverseJavaName.put(internalName, trackedSym) case Some(oldsym) => - assert((oldsym == trackedSym) || (oldsym == RuntimeNothingClass) || (oldsym == RuntimeNullClass), // In contrast, neither NothingClass nor NullClass show up bytecode-level. + assert((oldsym == trackedSym) || (oldsym == RuntimeNothingClass) || (oldsym == RuntimeNullClass) || + (oldsym.isModuleClass && (oldsym.sourceModule == trackedSym.sourceModule)), // In contrast, neither NothingClass nor NullClass show up bytecode-level. "how can getCommonSuperclass() do its job if different class symbols get the same bytecode-level internal name: " + internalName) } } diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala index 8fd8dfaf83..9caafe6912 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala @@ -94,7 +94,10 @@ abstract class ClassfileParser { pushBusy(root) { this.in = new AbstractFileReader(file) this.clazz = if (root.isModule) root.companionClass else root - this.staticModule = clazz.companionModule + // WARNING! do no use clazz.companionModule to find staticModule. + // In a situation where root can be defined, but its companionClass not, + // this would give incorrect results (see SI-5031 in separate compilation scenario) + this.staticModule = if (root.isModule) root else root.companionModule this.isScala = false parseHeader diff --git a/test/files/pos/t5031_3/Foo_1.scala b/test/files/pos/t5031_3/Foo_1.scala new file mode 100644 index 0000000000..5934a6ba79 --- /dev/null +++ b/test/files/pos/t5031_3/Foo_1.scala @@ -0,0 +1,5 @@ +package foo.bar + +object Foo { + def bar = 42 +} diff --git a/test/files/pos/t5031_3/Main_2.scala b/test/files/pos/t5031_3/Main_2.scala new file mode 100644 index 0000000000..2079460b83 --- /dev/null +++ b/test/files/pos/t5031_3/Main_2.scala @@ -0,0 +1,6 @@ +package org.example + +object Main extends App { + println(foo.bar.Foo.bar) +} + diff --git a/test/files/pos/t5031_3/package.scala b/test/files/pos/t5031_3/package.scala new file mode 100644 index 0000000000..23fede7d04 --- /dev/null +++ b/test/files/pos/t5031_3/package.scala @@ -0,0 +1,6 @@ +package foo + +package object bar { + type Foo = Int => String +} + -- cgit v1.2.3 From f627d8a51e6b4f9afc017ee4bf02604cd094c9ae Mon Sep 17 00:00:00 2001 From: Vojin Jovanovic Date: Tue, 30 Oct 2012 08:51:33 +0100 Subject: SI-6581 fixed by inlining `Actor.self`. This avoids the necessary type cast that was preventing leakage of internal migration classes. Review by @phaller --- src/actors/scala/actors/remote/NetKernel.scala | 2 +- src/actors/scala/actors/remote/RemoteActor.scala | 10 +++---- test/files/jvm/actmig-remote-actor-self.check | 1 + test/files/jvm/actmig-remote-actor-self.scala | 34 ++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 test/files/jvm/actmig-remote-actor-self.check create mode 100644 test/files/jvm/actmig-remote-actor-self.scala (limited to 'test/files') diff --git a/src/actors/scala/actors/remote/NetKernel.scala b/src/actors/scala/actors/remote/NetKernel.scala index c6b2d8b8cd..8338f9a6a6 100644 --- a/src/actors/scala/actors/remote/NetKernel.scala +++ b/src/actors/scala/actors/remote/NetKernel.scala @@ -60,7 +60,7 @@ private[remote] class NetKernel(service: Service) { send(node, name, msg, 'nosession) def send(node: Node, name: Symbol, msg: AnyRef, session: Symbol) { - val senderLoc = Locator(service.node, getOrCreateName(Actor.self)) + val senderLoc = Locator(service.node, getOrCreateName(Actor.self(Scheduler))) val receiverLoc = Locator(node, name) namedSend(senderLoc, receiverLoc, msg, session) } diff --git a/src/actors/scala/actors/remote/RemoteActor.scala b/src/actors/scala/actors/remote/RemoteActor.scala index 23cbae8532..571cb67e95 100644 --- a/src/actors/scala/actors/remote/RemoteActor.scala +++ b/src/actors/scala/actors/remote/RemoteActor.scala @@ -40,7 +40,7 @@ package remote */ object RemoteActor { - private val kernels = new scala.collection.mutable.HashMap[Actor, NetKernel] + private val kernels = new scala.collection.mutable.HashMap[InternalActor, NetKernel] /* If set to null (default), the default class loader * of java.io.ObjectInputStream is used for deserializing @@ -62,7 +62,7 @@ object RemoteActor { private def createNetKernelOnPort(port: Int): NetKernel = { val serv = TcpService(port, cl) val kern = serv.kernel - val s = Actor.self + val s = Actor.self(Scheduler) kernels += Pair(s, kern) s.onTerminate { @@ -86,10 +86,10 @@ object RemoteActor { * node. */ def register(name: Symbol, a: Actor): Unit = synchronized { - val kernel = kernels.get(Actor.self) match { + val kernel = kernels.get(Actor.self(Scheduler)) match { case None => val serv = TcpService(TcpService.generatePort, cl) - kernels += Pair(Actor.self, serv.kernel) + kernels += Pair(Actor.self(Scheduler), serv.kernel) serv.kernel case Some(k) => k @@ -97,7 +97,7 @@ object RemoteActor { kernel.register(name, a) } - private def selfKernel = kernels.get(Actor.self) match { + private def selfKernel = kernels.get(Actor.self(Scheduler)) match { case None => // establish remotely accessible // return path (sender) diff --git a/test/files/jvm/actmig-remote-actor-self.check b/test/files/jvm/actmig-remote-actor-self.check new file mode 100644 index 0000000000..79d23cb337 --- /dev/null +++ b/test/files/jvm/actmig-remote-actor-self.check @@ -0,0 +1 @@ +registered diff --git a/test/files/jvm/actmig-remote-actor-self.scala b/test/files/jvm/actmig-remote-actor-self.scala new file mode 100644 index 0000000000..2b994f6081 --- /dev/null +++ b/test/files/jvm/actmig-remote-actor-self.scala @@ -0,0 +1,34 @@ +/** + * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change + * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov. + */ +import scala.actors._ +import scala.actors.migration._ +import scala.actors.remote._ +import scala.actors.remote.RemoteActor._ +import scala.concurrent._ +import scala.concurrent.duration._ + +object Test { + val finished = Promise[Boolean] + + def main(args: Array[String]): Unit = { + + // can fail with class cast exception in alive + val myAkkaActor = ActorDSL.actor(new StashingActor { + override def preStart() = { + alive(42013) + println("registered") + finished success true + context.stop(self) + } + + def receive = { + case x: Int => + } + }) + + Await.result(finished.future, Duration.Inf).toString + } + +} -- cgit v1.2.3 From 492cbe5eec2df5d3e3a4310cf0fda5b86855299f Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Wed, 24 Oct 2012 10:59:50 -0400 Subject: Fixes SI-6559 - StringContext not using passed in escape function. As reported by Curtis Stanford, with indication of what to fix. standardInterpolator was not correctly calling the passed in process function, so raw strings were not really raw. --- src/library/scala/StringContext.scala | 2 +- test/files/run/t6559.scala | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 test/files/run/t6559.scala (limited to 'test/files') diff --git a/src/library/scala/StringContext.scala b/src/library/scala/StringContext.scala index fb43d56020..4078168bb3 100644 --- a/src/library/scala/StringContext.scala +++ b/src/library/scala/StringContext.scala @@ -120,7 +120,7 @@ case class StringContext(parts: String*) { val bldr = new java.lang.StringBuilder(process(pi.next())) while (ai.hasNext) { bldr append ai.next - bldr append treatEscapes(pi.next()) + bldr append process(pi.next()) } bldr.toString } diff --git a/test/files/run/t6559.scala b/test/files/run/t6559.scala new file mode 100644 index 0000000000..5c671f7275 --- /dev/null +++ b/test/files/run/t6559.scala @@ -0,0 +1,17 @@ + +object Test { + + def main(args: Array[String]) = { + val one = "1" + val two = "2" + + val raw = raw"\n$one\n$two\n" + val escaped = s"\n$one\n$two\n" + val buggy = "\\n1\n2\n" + val correct = "\\n1\\n2\\n" + + assert(raw != escaped, "Raw strings should not be escaped.") + assert(raw != buggy, "Raw strings after variables should not be escaped.") + assert(raw == correct, "Raw strings should stay raw.") + } +} -- cgit v1.2.3 From c3e2a81b38133f2b997e56ccd85d9bea38896a6b Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Tue, 30 Oct 2012 07:43:03 -0700 Subject: Modification to SI-6534 patch. Only exclude hashCode and equals from being overridden in value classes, not other synthetics which may turn up such as case class methods. --- .../tools/nsc/typechecker/SyntheticMethods.scala | 20 +++++++++++--------- test/files/neg/t6534.check | 5 ++++- test/files/neg/t6534.scala | 3 +++ 3 files changed, 18 insertions(+), 10 deletions(-) (limited to 'test/files') diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala index 0fda025972..903b5904d3 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala @@ -310,17 +310,19 @@ trait SyntheticMethods extends ast.TreeDSL { * so they can appear in universal traits without breaking value semantics. */ def impls = { - if (clazz.isDerivedValueClass) - for ((m, impl) <- methods) yield { - if (settings.lint.value) - (clazz.info nonPrivateMember m.name) filter (m => (m.owner != AnyClass) && (m.owner != clazz) && !m.isDeferred) andAlso { m => - currentUnit.warning(clazz.pos, s"Implementation of ${m.name} inherited from ${m.owner} overridden in $clazz to enforce value class semantics") + def shouldGenerate(m: Symbol) = { + !hasOverridingImplementation(m) || { + clazz.isDerivedValueClass && (m == Any_hashCode || m == Any_equals) && { + if (settings.lint.value) { + (clazz.info nonPrivateMember m.name) filter (m => (m.owner != AnyClass) && (m.owner != clazz) && !m.isDeferred) andAlso { m => + currentUnit.warning(clazz.pos, s"Implementation of ${m.name} inherited from ${m.owner} overridden in $clazz to enforce value class semantics") + } } - - impl() + true + } } - else - for ((m, impl) <- methods ; if !hasOverridingImplementation(m)) yield impl() + } + for ((m, impl) <- methods ; if shouldGenerate(m)) yield impl() } def extras = ( if (needsReadResolve) { diff --git a/test/files/neg/t6534.check b/test/files/neg/t6534.check index bd7dc4b71c..52e70cfa8a 100644 --- a/test/files/neg/t6534.check +++ b/test/files/neg/t6534.check @@ -10,5 +10,8 @@ class Bippy3(val x: Int) extends AnyVal { override def equals(x: Any) = false } t6534.scala:7: error: redefinition of hashCode method. See SIP-15, criterion 4. is not allowed in value class class Bippy4(val x: Int) extends AnyVal { override def hashCode = -1 } // error ^ +t6534.scala:9: error: redefinition of equals method. See SIP-15, criterion 4. is not allowed in value class +case class Bippy6(val x: Int) extends AnyVal { override def productPrefix = "Dingo" ; override def equals(x: Any) = false } // error + ^ two warnings found -two errors found +three errors found diff --git a/test/files/neg/t6534.scala b/test/files/neg/t6534.scala index a193179399..de588b69a7 100644 --- a/test/files/neg/t6534.scala +++ b/test/files/neg/t6534.scala @@ -5,3 +5,6 @@ class Bippy1(val x: Int) extends AnyVal with Foo { } // warn class Bippy2(val x: Int) extends AnyVal with Ding { } // warn class Bippy3(val x: Int) extends AnyVal { override def equals(x: Any) = false } // error class Bippy4(val x: Int) extends AnyVal { override def hashCode = -1 } // error +case class Bippy5(val x: Int) extends AnyVal { override def productPrefix = "Dingo" } // nothing +case class Bippy6(val x: Int) extends AnyVal { override def productPrefix = "Dingo" ; override def equals(x: Any) = false } // error + -- cgit v1.2.3 From 0bb625b7823befafb170ef05f0493dd0a81a217a Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 30 Oct 2012 20:10:56 +0100 Subject: Fixes SI-6500 by making erasure more regular. With the introduction of value classes, erasure uses specialErasure where a value class C with underlying type T is unboxed to an ErasedValueType. ErasedValue types are eliminated on phase later, in post-erasure. This was done everywhere, except in the parameter types of bridge methods. That was a mistale, because that way bridge methods could not do the boxing/unboxing logic triggered by ErasedValueTypes. Note: there is one remaining use of erasure (not specialErasure) in Erasure.scala. I put in a comment why that is OK. --- src/compiler/scala/tools/nsc/transform/Erasure.scala | 6 ++++-- test/files/run/t6500.scala | 13 +++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 test/files/run/t6500.scala (limited to 'test/files') diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index 3ac7dd2a8f..a581c6d734 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -469,7 +469,7 @@ abstract class Erasure extends AddInterfaces } def checkPair(member: Symbol, other: Symbol) { - val otpe = erasure(root)(other.tpe) + val otpe = specialErasure(root)(other.tpe) val bridgeNeeded = afterErasure ( !(other.tpe =:= member.tpe) && !(deconstMap(other.tpe) =:= deconstMap(member.tpe)) && @@ -488,7 +488,7 @@ abstract class Erasure extends AddInterfaces debuglog("generating bridge from %s (%s): %s to %s: %s".format( other, flagsToString(newFlags), otpe + other.locationString, member, - erasure(root)(member.tpe) + member.locationString) + specialErasure(root)(member.tpe) + member.locationString) ) // the parameter symbols need to have the new owner @@ -1118,6 +1118,8 @@ abstract class Erasure extends AddInterfaces } else { // store exact array erasure in map to be retrieved later when we might // need to do the cast in adaptMember + // Note: No specialErasure needed here because we simply cast, on + // elimination of SelectFromArray, no boxing or unboxing is done there. treeCopy.Apply( tree, SelectFromArray(qual, name, erasure(tree.symbol)(qual.tpe)).copyAttrs(fn), diff --git a/test/files/run/t6500.scala b/test/files/run/t6500.scala new file mode 100644 index 0000000000..03a68a3a24 --- /dev/null +++ b/test/files/run/t6500.scala @@ -0,0 +1,13 @@ +object Test extends App { + class Box(val value: Int) extends AnyVal + + trait Foo { + def append(box: Box): Foo + } + + class Bar extends Foo { + override def append(box: Box): Bar = this // produces bad forwarder + } + + ((new Bar): Foo).append(new Box(0)) +} -- cgit v1.2.3 From 557fe9e9d2c14f363918e89056233a981dc5ef5c Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Tue, 30 Oct 2012 15:17:05 -0400 Subject: Removing actors-migration from main repository so it can live on elsewhere. * Removes actors-migration hooks from partest * Removes actors-migration code * removes actors-migration tests * removes actors-migration distribution packaging. --- build.xml | 77 +----- project/Build.scala | 5 +- .../scala/actors/migration/ActorDSL.scala | 56 ----- .../scala/actors/migration/Pattern.scala | 27 --- .../scala/actors/migration/Props.scala | 14 -- .../scala/actors/migration/StashingActor.scala | 257 --------------------- .../scala/actors/migration/Timeout.scala | 40 ---- src/build/bnd/scala-actors-migration.bnd | 5 - src/build/maven/maven-deploy.xml | 3 - src/build/maven/scala-actors-migration-pom.xml | 66 ------ src/build/pack.xml | 5 - src/partest/scala/tools/partest/PartestTask.scala | 11 - .../scala/tools/partest/nest/AntRunner.scala | 1 - .../tools/partest/nest/ConsoleFileManager.scala | 9 - .../scala/tools/partest/nest/DirectRunner.scala | 3 +- .../scala/tools/partest/nest/FileManager.scala | 1 - .../tools/partest/nest/ReflectiveRunner.scala | 4 +- .../scala/tools/partest/nest/SBTRunner.scala | 2 - test/files/jvm/actmig-PinS.check | 19 -- test/files/jvm/actmig-PinS.scala | 116 ---------- test/files/jvm/actmig-PinS_1.check | 19 -- test/files/jvm/actmig-PinS_1.scala | 139 ----------- test/files/jvm/actmig-PinS_2.check | 19 -- test/files/jvm/actmig-PinS_2.scala | 159 ------------- test/files/jvm/actmig-PinS_3.check | 19 -- test/files/jvm/actmig-PinS_3.scala | 164 ------------- test/files/jvm/actmig-hierarchy.check | 2 - test/files/jvm/actmig-hierarchy.scala | 47 ---- test/files/jvm/actmig-hierarchy_1.check | 2 - test/files/jvm/actmig-hierarchy_1.scala | 45 ---- test/files/jvm/actmig-instantiation.check | 8 - test/files/jvm/actmig-instantiation.scala | 95 -------- test/files/jvm/actmig-loop-react.check | 16 -- test/files/jvm/actmig-loop-react.scala | 195 ---------------- test/files/jvm/actmig-public-methods.check | 6 - test/files/jvm/actmig-public-methods.scala | 73 ------ test/files/jvm/actmig-public-methods_1.check | 6 - test/files/jvm/actmig-public-methods_1.scala | 104 --------- test/files/jvm/actmig-react-receive.check | 16 -- test/files/jvm/actmig-react-receive.scala | 115 --------- test/files/jvm/actmig-react-within.check | 2 - test/files/jvm/actmig-react-within.scala | 47 ---- test/files/jvm/actmig-receive.check | 27 --- test/files/jvm/actmig-receive.scala | 119 ---------- 44 files changed, 9 insertions(+), 2156 deletions(-) delete mode 100644 src/actors-migration/scala/actors/migration/ActorDSL.scala delete mode 100644 src/actors-migration/scala/actors/migration/Pattern.scala delete mode 100644 src/actors-migration/scala/actors/migration/Props.scala delete mode 100644 src/actors-migration/scala/actors/migration/StashingActor.scala delete mode 100644 src/actors-migration/scala/actors/migration/Timeout.scala delete mode 100644 src/build/bnd/scala-actors-migration.bnd delete mode 100644 src/build/maven/scala-actors-migration-pom.xml delete mode 100644 test/files/jvm/actmig-PinS.check delete mode 100644 test/files/jvm/actmig-PinS.scala delete mode 100644 test/files/jvm/actmig-PinS_1.check delete mode 100644 test/files/jvm/actmig-PinS_1.scala delete mode 100644 test/files/jvm/actmig-PinS_2.check delete mode 100644 test/files/jvm/actmig-PinS_2.scala delete mode 100644 test/files/jvm/actmig-PinS_3.check delete mode 100644 test/files/jvm/actmig-PinS_3.scala delete mode 100644 test/files/jvm/actmig-hierarchy.check delete mode 100644 test/files/jvm/actmig-hierarchy.scala delete mode 100644 test/files/jvm/actmig-hierarchy_1.check delete mode 100644 test/files/jvm/actmig-hierarchy_1.scala delete mode 100644 test/files/jvm/actmig-instantiation.check delete mode 100644 test/files/jvm/actmig-instantiation.scala delete mode 100644 test/files/jvm/actmig-loop-react.check delete mode 100644 test/files/jvm/actmig-loop-react.scala delete mode 100644 test/files/jvm/actmig-public-methods.check delete mode 100644 test/files/jvm/actmig-public-methods.scala delete mode 100644 test/files/jvm/actmig-public-methods_1.check delete mode 100644 test/files/jvm/actmig-public-methods_1.scala delete mode 100644 test/files/jvm/actmig-react-receive.check delete mode 100644 test/files/jvm/actmig-react-receive.scala delete mode 100644 test/files/jvm/actmig-react-within.check delete mode 100644 test/files/jvm/actmig-react-within.scala delete mode 100644 test/files/jvm/actmig-receive.check delete mode 100644 test/files/jvm/actmig-receive.scala (limited to 'test/files') diff --git a/build.xml b/build.xml index c9027e0985..41a4488a55 100644 --- a/build.xml +++ b/build.xml @@ -1024,7 +1024,6 @@ QUICK BUILD (QUICK) - @@ -1283,33 +1282,7 @@ QUICK BUILD (QUICK) - - - - - - - - - - - - - - - - - - - - - - + @@ -1514,14 +1487,11 @@ PACKED QUICK BUILD (PACK) - + - - - - + @@ -1682,7 +1652,6 @@ PACKED QUICK BUILD (PACK) - @@ -1752,7 +1721,6 @@ OSGi Artifacts - @@ -1773,7 +1741,6 @@ OSGi Artifacts - @@ -2321,7 +2288,6 @@ DOCUMENTATION - @@ -2348,7 +2314,6 @@ DOCUMENTATION rawOutput="${scaladoc.raw.output}" noPrefixes="${scaladoc.no.prefixes}"> - @@ -2547,35 +2512,9 @@ DOCUMENTATION - - - - - - - - - - - - - - - + @@ -2592,7 +2531,6 @@ BOOTRAPING TEST AND TEST SUITE - @@ -2741,7 +2679,6 @@ DISTRIBUTION - @@ -2802,9 +2739,6 @@ DISTRIBUTION - - - @@ -2982,9 +2916,6 @@ POSITIONS - - - diff --git a/project/Build.scala b/project/Build.scala index d8468032ef..a50a572d54 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -24,9 +24,9 @@ object ScalaBuild extends Build with Layers with Packaging with Testing { ) // Collections of projects to run 'compile' on. - lazy val compiledProjects = Seq(quickLib, quickComp, continuationsLibrary, actors, actorsMigration, swing, forkjoin, fjbg) + lazy val compiledProjects = Seq(quickLib, quickComp, continuationsLibrary, actors, swing, forkjoin, fjbg) // Collection of projects to 'package' and 'publish' together. - lazy val packagedBinaryProjects = Seq(scalaLibrary, scalaCompiler, swing, actors, actorsMigration, continuationsPlugin, jline, scalap) + lazy val packagedBinaryProjects = Seq(scalaLibrary, scalaCompiler, swing, actors, continuationsPlugin, jline, scalap) lazy val partestRunProjects = Seq(testsuite, continuationsTestsuite) private def epflPomExtra = ( @@ -205,7 +205,6 @@ object ScalaBuild extends Build with Layers with Packaging with Testing { lazy val dependentProjectSettings = settingOverrides ++ Seq(quickScalaInstance, quickScalaLibraryDependency, addCheaterDependency("scala-library")) lazy val actors = Project("scala-actors", file(".")) settings(dependentProjectSettings:_*) dependsOn(forkjoin % "provided") lazy val swing = Project("scala-swing", file(".")) settings(dependentProjectSettings:_*) dependsOn(actors % "provided") - lazy val actorsMigration = Project("scala-actors-migration", file(".")) settings(dependentProjectSettings:_*) dependsOn(actors % "provided") // This project will generate man pages (in man1 and html) for scala. lazy val manmakerSettings: Seq[Setting[_]] = dependentProjectSettings :+ externalDeps lazy val manmaker = Project("manual", file(".")) settings(manmakerSettings:_*) diff --git a/src/actors-migration/scala/actors/migration/ActorDSL.scala b/src/actors-migration/scala/actors/migration/ActorDSL.scala deleted file mode 100644 index b8cb8ec998..0000000000 --- a/src/actors-migration/scala/actors/migration/ActorDSL.scala +++ /dev/null @@ -1,56 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2005-2011, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.actors -package migration - -import scala.actors.{ Actor, ActorRef, InternalActorRef } -import scala.collection.immutable -import scala.reflect.ClassTag - -object ActorDSL { - - private[migration] val contextStack = new ThreadLocal[immutable.Stack[Boolean]] { - override def initialValue() = immutable.Stack[Boolean]() - } - - private[this] def withCleanContext(block: => ActorRef): ActorRef = { - // push clean marker - val old = contextStack.get - contextStack.set(old.push(true)) - try { - val instance = block - - if (instance eq null) - throw new Exception("ActorRef can't be 'null'") - - instance - } finally { - val stackAfter = contextStack.get - if (stackAfter.nonEmpty) - contextStack.set(if (!stackAfter.head) stackAfter.pop.pop else stackAfter.pop) - } - } - - /** - * Create an actor from the given thunk which must produce an [[scala.actors.Actor]]. - * - * @param ctor is a by-name argument which captures an [[scala.actors.Actor]] - * factory; do not make the generated object accessible to code - * outside and do not return the same object upon subsequent invocations. - */ - def actor[T <: InternalActor: ClassTag](ctor: ⇒ T): ActorRef = { - withCleanContext { - val newActor = ctor - val newRef = new InternalActorRef(newActor) - newActor.start() - newRef - } - } - -} diff --git a/src/actors-migration/scala/actors/migration/Pattern.scala b/src/actors-migration/scala/actors/migration/Pattern.scala deleted file mode 100644 index 25ba191ce7..0000000000 --- a/src/actors-migration/scala/actors/migration/Pattern.scala +++ /dev/null @@ -1,27 +0,0 @@ -package scala.actors.migration - -import scala.actors._ -import scala.concurrent.duration.Duration -import language.implicitConversions - -object pattern { - - implicit def ask(ar: ActorRef): AskableActorRef = - new AskableActorRef(ar) -} - -/** - * ActorRef with support for ask(?) operation. - */ -class AskableActorRef(val ar: ActorRef) extends ActorRef { - - def !(message: Any)(implicit sender: ActorRef = null): Unit = ar.!(message)(sender) - - def ?(message: Any)(implicit timeout: Timeout): scala.concurrent.Future[Any] = ar.?(message, timeout.duration) - - private[actors] def ?(message: Any, timeout: Duration): scala.concurrent.Future[Any] = ar.?(message, timeout) - - def forward(message: Any) = ar.forward(message) - - private[actors] def localActor: AbstractActor = ar.localActor -} diff --git a/src/actors-migration/scala/actors/migration/Props.scala b/src/actors-migration/scala/actors/migration/Props.scala deleted file mode 100644 index 00bc9d93f8..0000000000 --- a/src/actors-migration/scala/actors/migration/Props.scala +++ /dev/null @@ -1,14 +0,0 @@ -package scala.actors.migration - -import scala.actors._ - -/** - * ActorRef configuration object. It represents the minimal subset of Akka Props class. - */ -case class Props(creator: () ⇒ InternalActor, dispatcher: String) { - - /** - * Returns a new Props with the specified creator set - */ - final def withCreator(c: ⇒ InternalActor) = copy(creator = () ⇒ c) -} diff --git a/src/actors-migration/scala/actors/migration/StashingActor.scala b/src/actors-migration/scala/actors/migration/StashingActor.scala deleted file mode 100644 index 12bad2ed1c..0000000000 --- a/src/actors-migration/scala/actors/migration/StashingActor.scala +++ /dev/null @@ -1,257 +0,0 @@ -package scala.actors.migration - -import scala.actors._ -import scala.actors.Actor._ -import scala.collection._ -import scala.concurrent.duration.Duration -import java.util.concurrent.TimeUnit -import scala.language.implicitConversions - -object StashingActor extends Combinators { - implicit def mkBody[A](body: => A) = new InternalActor.Body[A] { - def andThen[B](other: => B): Unit = Actor.rawSelf.seq(body, other) - } -} - -@deprecated("Scala Actors are being removed from the standard library. Please refer to the migration guide.", "2.10.0") -trait StashingActor extends InternalActor { - type Receive = PartialFunction[Any, Unit] - - // checks if StashingActor is created within the actorOf block - creationCheck() - - private[actors] val ref = new InternalActorRef(this) - - val self: ActorRef = ref - - protected[this] val context: ActorContext = new ActorContext(this) - - @volatile - private var myTimeout: Option[Long] = None - - private val stash = new MQueue[Any]("Stash") - - /** - * Migration notes: - * this method replaces receiveWithin, receive and react methods from Scala Actors. - */ - def receive: Receive - - /** - * User overridable callback. - *

- * Is called when an Actor is started by invoking 'actor'. - */ - def preStart() {} - - /** - * User overridable callback. - *

- * Is called when 'actor.stop()' is invoked. - */ - def postStop() {} - - /** - * User overridable callback. - *

- * Is called on a crashed Actor right BEFORE it is restarted to allow clean - * up of resources before Actor is terminated. - * By default it calls postStop() - */ - def preRestart(reason: Throwable, message: Option[Any]) { postStop() } - - /** - * Changes the Actor's behavior to become the new 'Receive' (PartialFunction[Any, Unit]) handler. - * Puts the behavior on top of the hotswap stack. - * If "discardOld" is true, an unbecome will be issued prior to pushing the new behavior to the stack - */ - private def become(behavior: Receive, discardOld: Boolean = true) { - if (discardOld) unbecome() - behaviorStack = behaviorStack.push(wrapWithSystemMessageHandling(behavior)) - } - - /** - * Reverts the Actor behavior to the previous one in the hotswap stack. - */ - private def unbecome() { - // never unbecome the initial behavior - if (behaviorStack.size > 1) - behaviorStack = behaviorStack.pop - } - - /** - * User overridable callback. - *

- * Is called when a message isn't handled by the current behavior of the actor - * by default it does: EventHandler.warning(self, message) - */ - def unhandled(message: Any) { - message match { - case Terminated(dead) ⇒ throw new DeathPactException(dead) - case _ ⇒ System.err.println("Unhandeled message " + message) - } - } - - protected def sender: ActorRef = new OutputChannelRef(internalSender) - - override def act(): Unit = internalAct() - - override def start(): StashingActor = { - super.start() - this - } - - override def receive[R](f: PartialFunction[Any, R]): R - - /* - * Internal implementation. - */ - - private[actors] var behaviorStack = immutable.Stack[PartialFunction[Any, Unit]]() - - /* - * Checks that StashingActor instances can only be created using the ActorDSL. - */ - private[this] def creationCheck(): Unit = { - // creation check (see ActorRef) - val context = ActorDSL.contextStack.get - if (context.isEmpty) - throw new RuntimeException("In order to create a StashingActor one must use the ActorDSL object") - else { - if (!context.head) - throw new RuntimeException("Cannot create more than one actor") - else - ActorDSL.contextStack.set(context.push(false)) - } - - } - - private[actors] override def preAct() { - preStart() - } - - /** - * Adds message to a stash, to be processed later. Stashed messages can be fed back into the $actor's - * mailbox using unstashAll(). - * - * Temporarily stashing away messages that the $actor does not (yet) handle simplifies implementing - * certain messaging protocols. - */ - final def stash(msg: Any): Unit = { - stash.append(msg, null) - } - - final def unstashAll(): Unit = { - mailbox.prepend(stash) - stash.clear() - } - - /** - * Wraps any partial function with Exit message handling. - */ - private[actors] def wrapWithSystemMessageHandling(pf: PartialFunction[Any, Unit]): PartialFunction[Any, Unit] = { - - def swapExitHandler(pf: PartialFunction[Any, Unit]) = new PartialFunction[Any, Unit] { - def swapExit(v: Any) = v match { - case Exit(from, reason) => - Terminated(new InternalActorRef(from.asInstanceOf[InternalActor])) - case v => v - } - - def isDefinedAt(v: Any) = pf.isDefinedAt(swapExit(v)) - def apply(v: Any) = pf(swapExit(v)) - } - - swapExitHandler(pf orElse { - case m => unhandled(m) - }) - } - - /** - * Method that models the behavior of Akka actors. - */ - private[actors] def internalAct() { - trapExit = true - behaviorStack = behaviorStack.push(wrapWithSystemMessageHandling(receive)) - loop { - if (myTimeout.isDefined) - reactWithin(myTimeout.get)(behaviorStack.top) - else - react(behaviorStack.top) - } - } - - private[actors] override def internalPostStop() = postStop() - - // Used for pattern matching statement similar to Akka - lazy val ReceiveTimeout = TIMEOUT - - /** - * Used to simulate Akka context behavior. Should be used only for migration purposes. - */ - protected[actors] class ActorContext(val actr: StashingActor) { - - /** - * Changes the Actor's behavior to become the new 'Receive' (PartialFunction[Any, Unit]) handler. - * Puts the behavior on top of the hotswap stack. - * If "discardOld" is true, an unbecome will be issued prior to pushing the new behavior to the stack - */ - def become(behavior: Receive, discardOld: Boolean = true) = actr.become(behavior, discardOld) - - /** - * Reverts the Actor behavior to the previous one in the hotswap stack. - */ - def unbecome() = actr.unbecome() - - /** - * Shuts down the actor its dispatcher and message queue. - */ - def stop(subject: ActorRef): Nothing = if (subject != ref) - throw new RuntimeException("Only stoping of self is allowed during migration.") - else - actr.exit() - - /** - * Registers this actor as a Monitor for the provided ActorRef. - * @return the provided ActorRef - */ - def watch(subject: ActorRef): ActorRef = { - actr.watch(subject) - subject - } - - /** - * Unregisters this actor as Monitor for the provided ActorRef. - * @return the provided ActorRef - */ - def unwatch(subject: ActorRef): ActorRef = { - actr unwatch subject - subject - } - - /** - * Defines the receiver timeout value. - */ - final def setReceiveTimeout(timeout: Duration): Unit = - actr.myTimeout = Some(timeout.toMillis) - - /** - * Gets the current receiveTimeout - */ - final def receiveTimeout: Option[Duration] = - actr.myTimeout.map(Duration(_, TimeUnit.MILLISECONDS)) - - } -} - -/** - * This message is thrown by default when an Actor does not handle termination. - */ -class DeathPactException(ref: ActorRef = null) extends Exception { - override def fillInStackTrace() = this //Don't waste cycles generating stack trace -} - -/** - * Message that is sent to a watching actor when the watched actor terminates. - */ -case class Terminated(actor: ActorRef) diff --git a/src/actors-migration/scala/actors/migration/Timeout.scala b/src/actors-migration/scala/actors/migration/Timeout.scala deleted file mode 100644 index 32ea5f20fc..0000000000 --- a/src/actors-migration/scala/actors/migration/Timeout.scala +++ /dev/null @@ -1,40 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2005-2011, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.actors.migration - -import scala.concurrent.duration.Duration -import java.util.concurrent.TimeUnit -import scala.language.implicitConversions - -case class Timeout(duration: Duration) { - def this(timeout: Long) = this(Duration(timeout, TimeUnit.MILLISECONDS)) - def this(length: Long, unit: TimeUnit) = this(Duration(length, unit)) -} - -object Timeout { - - /** - * A timeout with zero duration, will cause most requests to always timeout. - */ - val zero = new Timeout(Duration.Zero) - - /** - * A Timeout with infinite duration. Will never timeout. Use extreme caution with this - * as it may cause memory leaks, blocked threads, or may not even be supported by - * the receiver, which would result in an exception. - */ - val never = new Timeout(Duration.Inf) - - def apply(timeout: Long) = new Timeout(timeout) - def apply(length: Long, unit: TimeUnit) = new Timeout(length, unit) - - implicit def durationToTimeout(duration: Duration) = new Timeout(duration) - implicit def intToTimeout(timeout: Int) = new Timeout(timeout) - implicit def longToTimeout(timeout: Long) = new Timeout(timeout) -} diff --git a/src/build/bnd/scala-actors-migration.bnd b/src/build/bnd/scala-actors-migration.bnd deleted file mode 100644 index 2cddfb620a..0000000000 --- a/src/build/bnd/scala-actors-migration.bnd +++ /dev/null @@ -1,5 +0,0 @@ -Bundle-Name: Scala Actors Migration -Bundle-SymbolicName: org.scala-lang.scala-actors-migration -ver: @VERSION@ -Bundle-Version: ${ver} -Export-Package: *;version=${ver} diff --git a/src/build/maven/maven-deploy.xml b/src/build/maven/maven-deploy.xml index 131358f0f3..bd946bf0f3 100644 --- a/src/build/maven/maven-deploy.xml +++ b/src/build/maven/maven-deploy.xml @@ -113,7 +113,6 @@ - @@ -175,7 +174,6 @@ - @@ -244,7 +242,6 @@ - diff --git a/src/build/maven/scala-actors-migration-pom.xml b/src/build/maven/scala-actors-migration-pom.xml deleted file mode 100644 index 93fc34ece9..0000000000 --- a/src/build/maven/scala-actors-migration-pom.xml +++ /dev/null @@ -1,66 +0,0 @@ - - 4.0.0 - org.scala-lang - scala-actors-migration - jar - @VERSION@ - Scala Migration Kit - Migration kit that enables easy transition from the Scala Actors to Akka. - http://www.scala-lang.org/ - 2012 - - LAMP/EPFL - http://lamp.epfl.ch/ - - - - BSD-like - http://www.scala-lang.org/downloads/license.html - - repo - - - - scm:git:git://github.com/scala/scala.git - https://github.com/scala/scala.git - - - JIRA - https://issues.scala-lang.org/ - - - - org.scala-lang - scala-library - @VERSION@ - - - org.scala-lang - scala-actors - @VERSION@ - - - - - scala-tools.org - @RELEASE_REPOSITORY@ - - - scala-tools.org - @SNAPSHOT_REPOSITORY@ - false - - - - - lamp - EPFL LAMP - - - Typesafe - Typesafe, Inc. - - - diff --git a/src/build/pack.xml b/src/build/pack.xml index 1735b93f3f..79611b55a2 100644 --- a/src/build/pack.xml +++ b/src/build/pack.xml @@ -155,7 +155,6 @@ MAIN DISTRIBUTION PACKAGING - @@ -218,10 +217,6 @@ MAIN DISTRIBUTION PACKAGING basedir="${build-docs.dir}/continuations-plugin"> - - - new File(fs) }) find { f => - f.getName match { - case "scala-actors-migration.jar" => true - case "actors-migration" if (f.getParentFile.getName == "classes") => true - case _ => false - } - } - } getOrElse sys.error("Provided classpath does not contain a Scala actors.") - def scalacArgsFlat: Option[Seq[String]] = scalacArgs map (_ flatMap { a => val parts = a.getParts if(parts eq null) Seq[String]() else parts.toSeq @@ -362,7 +352,6 @@ class PartestTask extends Task with CompilationPathProperty { antFileManager.LATEST_COMP = scalaCompiler.getAbsolutePath antFileManager.LATEST_PARTEST = scalaPartest.getAbsolutePath antFileManager.LATEST_ACTORS = scalaActors.getAbsolutePath - antFileManager.LATEST_ACTORS_MIGRATION = scalaActorsMigration.getAbsolutePath javacmd foreach (x => antFileManager.JAVACMD = x.getAbsolutePath) javaccmd foreach (x => antFileManager.JAVAC_CMD = x.getAbsolutePath) diff --git a/src/partest/scala/tools/partest/nest/AntRunner.scala b/src/partest/scala/tools/partest/nest/AntRunner.scala index ee644c5315..8c2d7029ba 100644 --- a/src/partest/scala/tools/partest/nest/AntRunner.scala +++ b/src/partest/scala/tools/partest/nest/AntRunner.scala @@ -24,7 +24,6 @@ class AntRunner extends DirectRunner { var LATEST_COMP: String = _ var LATEST_PARTEST: String = _ var LATEST_ACTORS: String = _ - var LATEST_ACTORS_MIGRATION: String = _ val testRootPath: String = "test" val testRootDir: Directory = Directory(testRootPath) } diff --git a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala index 32f14872ec..442c0e8427 100644 --- a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala +++ b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala @@ -84,7 +84,6 @@ class ConsoleFileManager extends FileManager { latestFile = testClassesDir.parent / "bin" latestLibFile = testClassesDir / "library" latestActorsFile = testClassesDir / "library" / "actors" - latestActMigFile = testClassesDir / "actors-migration" latestReflectFile = testClassesDir / "reflect" latestCompFile = testClassesDir / "compiler" latestPartestFile = testClassesDir / "partest" @@ -96,7 +95,6 @@ class ConsoleFileManager extends FileManager { latestFile = dir / "bin" latestLibFile = dir / "lib/scala-library.jar" latestActorsFile = dir / "lib/scala-actors.jar" - latestActMigFile = dir / "lib/scala-actors-migration.jar" latestReflectFile = dir / "lib/scala-reflect.jar" latestCompFile = dir / "lib/scala-compiler.jar" latestPartestFile = dir / "lib/scala-partest.jar" @@ -108,7 +106,6 @@ class ConsoleFileManager extends FileManager { latestFile = prefixFile("build/quick/bin") latestLibFile = prefixFile("build/quick/classes/library") latestActorsFile = prefixFile("build/quick/classes/library/actors") - latestActMigFile = prefixFile("build/quick/classes/actors-migration") latestReflectFile = prefixFile("build/quick/classes/reflect") latestCompFile = prefixFile("build/quick/classes/compiler") latestPartestFile = prefixFile("build/quick/classes/partest") @@ -120,7 +117,6 @@ class ConsoleFileManager extends FileManager { latestFile = prefixFileWith(p, "bin") latestLibFile = prefixFileWith(p, "lib/scala-library.jar") latestActorsFile = prefixFileWith(p, "lib/scala-actors.jar") - latestActMigFile = prefixFileWith(p, "lib/scala-actors-migration.jar") latestReflectFile = prefixFileWith(p, "lib/scala-reflect.jar") latestCompFile = prefixFileWith(p, "lib/scala-compiler.jar") latestPartestFile = prefixFileWith(p, "lib/scala-partest.jar") @@ -131,7 +127,6 @@ class ConsoleFileManager extends FileManager { latestFile = prefixFile("dists/latest/bin") latestLibFile = prefixFile("dists/latest/lib/scala-library.jar") latestActorsFile = prefixFile("dists/latest/lib/scala-actors.jar") - latestActMigFile = prefixFile("dists/latest/lib/scala-actors-migration.jar") latestReflectFile = prefixFile("dists/latest/lib/scala-reflect.jar") latestCompFile = prefixFile("dists/latest/lib/scala-compiler.jar") latestPartestFile = prefixFile("dists/latest/lib/scala-partest.jar") @@ -142,7 +137,6 @@ class ConsoleFileManager extends FileManager { latestFile = prefixFile("build/pack/bin") latestLibFile = prefixFile("build/pack/lib/scala-library.jar") latestActorsFile = prefixFile("build/pack/lib/scala-actors.jar") - latestActMigFile = prefixFile("build/pack/lib/scala-actors-migration.jar") latestReflectFile = prefixFile("build/pack/lib/scala-reflect.jar") latestCompFile = prefixFile("build/pack/lib/scala-compiler.jar") latestPartestFile = prefixFile("build/pack/lib/scala-partest.jar") @@ -180,7 +174,6 @@ class ConsoleFileManager extends FileManager { LATEST_COMP = latestCompFile.getAbsolutePath LATEST_PARTEST = latestPartestFile.getAbsolutePath LATEST_ACTORS = latestActorsFile.getAbsolutePath - LATEST_ACTORS_MIGRATION = latestActMigFile.getAbsolutePath } var LATEST_LIB: String = "" @@ -188,12 +181,10 @@ class ConsoleFileManager extends FileManager { var LATEST_COMP: String = "" var LATEST_PARTEST: String = "" var LATEST_ACTORS: String = "" - var LATEST_ACTORS_MIGRATION: String = "" var latestFile: File = _ var latestLibFile: File = _ var latestActorsFile: File = _ - var latestActMigFile: File = _ var latestReflectFile: File = _ var latestCompFile: File = _ var latestPartestFile: File = _ diff --git a/src/partest/scala/tools/partest/nest/DirectRunner.scala b/src/partest/scala/tools/partest/nest/DirectRunner.scala index a890a57f14..0f926ee69e 100644 --- a/src/partest/scala/tools/partest/nest/DirectRunner.scala +++ b/src/partest/scala/tools/partest/nest/DirectRunner.scala @@ -49,10 +49,9 @@ trait DirectRunner { val latestLibFile = new File(fileManager.LATEST_LIB) val latestPartestFile = new File(fileManager.LATEST_PARTEST) val latestActorsFile = new File(fileManager.LATEST_ACTORS) - val latestActMigFile = new File(fileManager.LATEST_ACTORS_MIGRATION) val scalacheckURL = PathSettings.scalaCheck.toURL val scalaCheckParentClassLoader = ScalaClassLoader.fromURLs( - scalacheckURL :: (List(latestCompFile, latestReflectFile, latestLibFile, latestActorsFile, latestActMigFile, latestPartestFile).map(_.toURI.toURL)) + scalacheckURL :: (List(latestCompFile, latestReflectFile, latestLibFile, latestActorsFile, latestPartestFile).map(_.toURI.toURL)) ) val kindFiles = onlyValidTestPaths(_kindFiles) diff --git a/src/partest/scala/tools/partest/nest/FileManager.scala b/src/partest/scala/tools/partest/nest/FileManager.scala index 512c718040..b6d89177ca 100644 --- a/src/partest/scala/tools/partest/nest/FileManager.scala +++ b/src/partest/scala/tools/partest/nest/FileManager.scala @@ -64,7 +64,6 @@ trait FileManager extends FileUtil { var LATEST_COMP: String var LATEST_PARTEST: String var LATEST_ACTORS: String - var LATEST_ACTORS_MIGRATION: String var showDiff = false var updateCheck = false diff --git a/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala b/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala index 838bf56d73..99043d8f95 100644 --- a/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala +++ b/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala @@ -48,9 +48,9 @@ class ReflectiveRunner { new ConsoleFileManager import fileManager. - { latestCompFile, latestReflectFile, latestLibFile, latestPartestFile, latestFjbgFile, latestScalapFile, latestActorsFile, latestActMigFile } + { latestCompFile, latestReflectFile, latestLibFile, latestPartestFile, latestFjbgFile, latestScalapFile, latestActorsFile } val files = - Array(latestCompFile, latestReflectFile, latestLibFile, latestPartestFile, latestFjbgFile, latestScalapFile, latestActorsFile, latestActMigFile) map (x => io.File(x)) + Array(latestCompFile, latestReflectFile, latestLibFile, latestPartestFile, latestFjbgFile, latestScalapFile, latestActorsFile) map (x => io.File(x)) val sepUrls = files map (_.toURL) var sepLoader = new URLClassLoader(sepUrls, null) diff --git a/src/partest/scala/tools/partest/nest/SBTRunner.scala b/src/partest/scala/tools/partest/nest/SBTRunner.scala index 206ee19c76..b0ce6579ac 100644 --- a/src/partest/scala/tools/partest/nest/SBTRunner.scala +++ b/src/partest/scala/tools/partest/nest/SBTRunner.scala @@ -17,7 +17,6 @@ object SBTRunner extends DirectRunner { var LATEST_COMP: String = _ var LATEST_PARTEST: String = _ var LATEST_ACTORS: String = _ - var LATEST_ACTORS_MIGRATION: String = _ val testRootPath: String = "test" val testRootDir: Directory = Directory(testRootPath) } @@ -61,7 +60,6 @@ object SBTRunner extends DirectRunner { fileManager.LATEST_COMP = findClasspath("scala-compiler", "scala-compiler") getOrElse sys.error("No scala-compiler found! Classpath = " + fileManager.CLASSPATH) fileManager.LATEST_PARTEST = findClasspath("scala-partest", "partest") getOrElse sys.error("No scala-partest found! Classpath = " + fileManager.CLASSPATH) fileManager.LATEST_ACTORS = findClasspath("scala-actors", "actors") getOrElse sys.error("No scala-actors found! Classpath = " + fileManager.CLASSPATH) - fileManager.LATEST_ACTORS_MIGRATION = findClasspath("scala-actors-migration", "actors-migration") getOrElse sys.error("No scala-actors-migration found! Classpath = " + fileManager.CLASSPATH) // TODO - Do something useful here!!! fileManager.JAVAC_CMD = "javac" diff --git a/test/files/jvm/actmig-PinS.check b/test/files/jvm/actmig-PinS.check deleted file mode 100644 index bdbdf8a692..0000000000 --- a/test/files/jvm/actmig-PinS.check +++ /dev/null @@ -1,19 +0,0 @@ -I'm acting! -I'm acting! -I'm acting! -I'm acting! -I'm acting! -Post stop -To be or not to be. -To be or not to be. -To be or not to be. -To be or not to be. -To be or not to be. -That is the question. -That is the question. -That is the question. -That is the question. -That is the question. -received message: hi there -received message: 15 -Got an Int: 12 diff --git a/test/files/jvm/actmig-PinS.scala b/test/files/jvm/actmig-PinS.scala deleted file mode 100644 index 3f07fab12e..0000000000 --- a/test/files/jvm/actmig-PinS.scala +++ /dev/null @@ -1,116 +0,0 @@ -/** - * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change - * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov. - */ -import scala.actors._ -import scala.concurrent.duration._ -import scala.concurrent.{ Promise, Await } - -import scala.actors.Actor._ - -/* PinS, Listing 32.1: A simple actor - */ -object SillyActor extends Actor { - def act() { - for (i <- 1 to 5) - println("I'm acting!") - - println("Post stop") - } -} - -object SeriousActor extends Actor { - def act() { - for (i <- 1 to 5) - println("To be or not to be.") - } -} - -/* PinS, Listing 32.3: An actor that calls react - */ -object NameResolver extends Actor { - import java.net.{InetAddress, UnknownHostException} - - def act() { - react { - case (name: String, actor: Actor) => - actor ! getIp(name) - act() - case "EXIT" => - println("Name resolver exiting.") - // quit - case msg => - println("Unhandled message: " + msg) - act() - } - } - - def getIp(name: String): Option[InetAddress] = { - try { - Some(InetAddress.getByName(name)) - } catch { - case _: UnknownHostException => None - } - } - -} - -object Test extends App { - /* PinS, Listing 32.2: An actor that calls receive - */ - def makeEchoActor(): Actor = actor { - while (true) { - receive { - case 'stop => - exit() - case msg => - println("received message: " + msg) - } - } - } - - /* PinS, page 696 - */ - def makeIntActor(): Actor = actor { - receive { - case x: Int => // I only want Ints - println("Got an Int: " + x) - } - } - - actor { - self.trapExit = true - self.link(SillyActor) - SillyActor.start() - react { - case Exit(SillyActor, _) => - self.link(SeriousActor) - SeriousActor.start() - react { - case Exit(SeriousActor, _) => - val seriousPromise2 = Promise[Boolean] - // PinS, page 694 - val seriousActor2 = actor { - for (i <- 1 to 5) - println("That is the question.") - seriousPromise2.success(true) - } - - Await.ready(seriousPromise2.future, 5 seconds) - val echoActor = makeEchoActor() - self.link(echoActor) - echoActor ! "hi there" - echoActor ! 15 - echoActor ! 'stop - react { - case Exit(_, _) => - val intActor = makeIntActor() - intActor ! "hello" - intActor ! math.Pi - // only the following send leads to output - intActor ! 12 - } - } - } - } -} diff --git a/test/files/jvm/actmig-PinS_1.check b/test/files/jvm/actmig-PinS_1.check deleted file mode 100644 index bdbdf8a692..0000000000 --- a/test/files/jvm/actmig-PinS_1.check +++ /dev/null @@ -1,19 +0,0 @@ -I'm acting! -I'm acting! -I'm acting! -I'm acting! -I'm acting! -Post stop -To be or not to be. -To be or not to be. -To be or not to be. -To be or not to be. -To be or not to be. -That is the question. -That is the question. -That is the question. -That is the question. -That is the question. -received message: hi there -received message: 15 -Got an Int: 12 diff --git a/test/files/jvm/actmig-PinS_1.scala b/test/files/jvm/actmig-PinS_1.scala deleted file mode 100644 index 495852e812..0000000000 --- a/test/files/jvm/actmig-PinS_1.scala +++ /dev/null @@ -1,139 +0,0 @@ -/** - * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change - * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov. - */ -import scala.actors._ -import scala.actors.migration._ -import scala.concurrent.duration._ -import scala.concurrent.{ Promise, Await } - -object SillyActor { - val startPromise = Promise[Boolean]() - val ref = ActorDSL.actor(new SillyActor) -} - -/* PinS, Listing 32.1: A simple actor - */ -class SillyActor extends Actor { - - def act() { - Await.ready(SillyActor.startPromise.future, 5 seconds) - for (i <- 1 to 5) - println("I'm acting!") - - println("Post stop") - } -} - -object SeriousActor { - val startPromise = Promise[Boolean]() - val ref = ActorDSL.actor(new SeriousActor) -} - -class SeriousActor extends Actor { - def act() { - // used to make this test deterministic - Await.ready(SeriousActor.startPromise.future, 5 seconds) - for (i <- 1 to 5) - println("To be or not to be.") - } -} - -/* PinS, Listing 32.3: An actor that calls react - */ -object NameResolver extends Actor { - import java.net.{ InetAddress, UnknownHostException } - - def act() { - react { - case (name: String, actor: Actor) => - actor ! getIp(name) - act() - case "EXIT" => - println("Name resolver exiting.") - // quit - case msg => - println("Unhandled message: " + msg) - act() - } - } - - def getIp(name: String): Option[InetAddress] = { - try { - Some(InetAddress.getByName(name)) - } catch { - case _: UnknownHostException => None - } - } - -} - -object Test extends App { - - /* PinS, Listing 32.2: An actor that calls receive - */ - def makeEchoActor(): ActorRef = ActorDSL.actor(new Actor { - def act() { - while (true) { - receive { - case 'stop => - exit() - case msg => - println("received message: " + msg) - } - } - } - }) - - /* PinS, page 696 - */ - def makeIntActor(): ActorRef = ActorDSL.actor(new Actor { - def act() { - receive { - case x: Int => // I only want Ints - println("Got an Int: " + x) - } - } - }) - - ActorDSL.actor(new Actor { - def act() { - trapExit = true - link(SillyActor.ref) - SillyActor.startPromise.success(true) - react { - case Exit(_: SillyActor, _) => - link(SeriousActor.ref) - SeriousActor.startPromise.success(true) - react { - case Exit(_: SeriousActor, _) => - val seriousPromise2 = Promise[Boolean]() - // PinS, page 694 - val seriousActor2 = ActorDSL.actor( - new Actor { - def act() { - for (i <- 1 to 5) - println("That is the question.") - seriousPromise2.success(true) - } - }) - - Await.ready(seriousPromise2.future, 5 seconds) - val echoActor = makeEchoActor() - link(echoActor) - echoActor ! "hi there" - echoActor ! 15 - echoActor ! 'stop - react { - case Exit(_, _) => - val intActor = makeIntActor() - intActor ! "hello" - intActor ! math.Pi - // only the following send leads to output - intActor ! 12 - } - } - } - } - }) -} diff --git a/test/files/jvm/actmig-PinS_2.check b/test/files/jvm/actmig-PinS_2.check deleted file mode 100644 index bdbdf8a692..0000000000 --- a/test/files/jvm/actmig-PinS_2.check +++ /dev/null @@ -1,19 +0,0 @@ -I'm acting! -I'm acting! -I'm acting! -I'm acting! -I'm acting! -Post stop -To be or not to be. -To be or not to be. -To be or not to be. -To be or not to be. -To be or not to be. -That is the question. -That is the question. -That is the question. -That is the question. -That is the question. -received message: hi there -received message: 15 -Got an Int: 12 diff --git a/test/files/jvm/actmig-PinS_2.scala b/test/files/jvm/actmig-PinS_2.scala deleted file mode 100644 index 508525463f..0000000000 --- a/test/files/jvm/actmig-PinS_2.scala +++ /dev/null @@ -1,159 +0,0 @@ -/** - * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change - * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov. - */ -import scala.actors._ -import scala.actors.migration._ -import scala.concurrent.duration._ -import scala.concurrent.{ Promise, Await } - -object SillyActor { - val startPromise = Promise[Boolean]() - val ref = ActorDSL.actor(new SillyActor) -} - -/* PinS, Listing 32.1: A simple actor - */ -class SillyActor extends StashingActor { - - def receive = { case _ => println("Nop") } - - override def act() { - Await.ready(SillyActor.startPromise.future, 5 seconds) - for (i <- 1 to 5) - println("I'm acting!") - - println("Post stop") - } -} - -object SeriousActor { - val startPromise = Promise[Boolean]() - val ref = ActorDSL.actor(new SeriousActor) -} - -class SeriousActor extends StashingActor { - def receive = { case _ => println("Nop") } - override def act() { - Await.ready(SeriousActor.startPromise.future, 5 seconds) - for (i <- 1 to 5) - println("To be or not to be.") - } -} - -/* PinS, Listing 32.3: An actor that calls react - */ -object NameResolver { - val ref = ActorDSL.actor(new NameResolver) -} - -class NameResolver extends StashingActor { - import java.net.{ InetAddress, UnknownHostException } - - def receive = { case _ => println("Nop") } - - override def act() { - react { - case (name: String, actor: ActorRef) => - actor ! getIp(name) - act() - case "EXIT" => - println("Name resolver exiting.") - // quit - case msg => - println("Unhandled message: " + msg) - act() - } - } - - def getIp(name: String): Option[InetAddress] = { - try { - Some(InetAddress.getByName(name)) - } catch { - case _: UnknownHostException => None - } - } - -} - -object Test extends App { - - /* PinS, Listing 32.2: An actor that calls receive - */ - def makeEchoActor(): ActorRef = ActorDSL.actor( - new StashingActor { - def receive = { case _ => println("Nop") } - - override def act() { - loop { - react { - case 'stop => - exit() - case msg => - println("received message: " + msg) - } - } - } - }) - - /* PinS, page 696 - */ - def makeIntActor(): ActorRef = ActorDSL.actor(new StashingActor { - - def receive = { case _ => println("Nop") } - - override def act() { - react { - case x: Int => // I only want Ints - println("Got an Int: " + x) - } - } - }) - - ActorDSL.actor(new StashingActor { - - def receive = { case _ => println("Nop") } - - override def act() { - trapExit = true - link(SillyActor.ref) - SillyActor.startPromise.success(true) - react { - case Exit(_: SillyActor, _) => - link(SeriousActor.ref) - SeriousActor.startPromise.success(true) - react { - case Exit(_: SeriousActor, _) => - val seriousPromise2 = Promise[Boolean]() - // PinS, page 694 - val seriousActor2 = ActorDSL.actor( - new StashingActor { - - def receive = { case _ => println("Nop") } - - override def act() { - for (i <- 1 to 5) - println("That is the question.") - seriousPromise2.success(true) - } - }) - - Await.ready(seriousPromise2.future, 5 seconds) - val echoActor = makeEchoActor() - link(echoActor) - echoActor ! "hi there" - echoActor ! 15 - echoActor ! 'stop - react { - case Exit(_, _) => - val intActor = makeIntActor() - intActor ! "hello" - intActor ! math.Pi - // only the following send leads to output - intActor ! 12 - } - } - } - } - }) -} diff --git a/test/files/jvm/actmig-PinS_3.check b/test/files/jvm/actmig-PinS_3.check deleted file mode 100644 index bdbdf8a692..0000000000 --- a/test/files/jvm/actmig-PinS_3.check +++ /dev/null @@ -1,19 +0,0 @@ -I'm acting! -I'm acting! -I'm acting! -I'm acting! -I'm acting! -Post stop -To be or not to be. -To be or not to be. -To be or not to be. -To be or not to be. -To be or not to be. -That is the question. -That is the question. -That is the question. -That is the question. -That is the question. -received message: hi there -received message: 15 -Got an Int: 12 diff --git a/test/files/jvm/actmig-PinS_3.scala b/test/files/jvm/actmig-PinS_3.scala deleted file mode 100644 index 6c6ec6789b..0000000000 --- a/test/files/jvm/actmig-PinS_3.scala +++ /dev/null @@ -1,164 +0,0 @@ -/** - * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change - * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov. - */ -import scala.actors._ -import scala.actors.migration._ -import scala.concurrent.duration._ -import scala.concurrent.{ Promise, Await } - -object SillyActor { - val startPromise = Promise[Boolean]() - val ref = ActorDSL.actor(new SillyActor) -} - -/* PinS, Listing 32.1: A simple actor - */ -class SillyActor extends StashingActor { - def receive = { case _ => println("Why are you not dead"); context.stop(self) } - - override def preStart() { - Await.ready(SillyActor.startPromise.future, 5 seconds) - for (i <- 1 to 5) - println("I'm acting!") - context.stop(self) - } - - override def postStop() { - println("Post stop") - } -} - -object SeriousActor { - val startPromise = Promise[Boolean]() - val ref = ActorDSL.actor(new SeriousActor) -} - -class SeriousActor extends StashingActor { - def receive = { case _ => println("Nop") } - override def preStart() { - Await.ready(SeriousActor.startPromise.future, 5 seconds) - for (i <- 1 to 5) - println("To be or not to be.") - context.stop(self) - } -} - -/* PinS, Listing 32.3: An actor that calls react - */ -object NameResolver { - val ref = ActorDSL.actor(new NameResolver) -} - -class NameResolver extends StashingActor { - import java.net.{ InetAddress, UnknownHostException } - - def receive = { - case (name: String, actor: ActorRef) => - actor ! getIp(name) - case "EXIT" => - println("Name resolver exiting.") - context.stop(self) // quit - case msg => - println("Unhandled message: " + msg) - } - - def getIp(name: String): Option[InetAddress] = { - try { - Some(InetAddress.getByName(name)) - } catch { - case _: UnknownHostException => None - } - } - -} - -object Test extends App { - - /* PinS, Listing 32.2: An actor that calls receive - */ - def makeEchoActor(): ActorRef = ActorDSL.actor(new StashingActor { - - def receive = { // how to handle receive - case 'stop => - context.stop(self) - case msg => - println("received message: " + msg) - } - }) - - /* PinS, page 696 - */ - def makeIntActor(): ActorRef = ActorDSL.actor(new StashingActor { - - def receive = { - case x: Int => // I only want Ints - unstashAll() - println("Got an Int: " + x) - context.stop(self) - case _ => stash() - } - }) - - ActorDSL.actor(new StashingActor { - val silly = SillyActor.ref - - override def preStart() { - context.watch(SillyActor.ref) - SillyActor.startPromise.success(true) - } - - def receive = { - case Terminated(`silly`) => - unstashAll() - val serious = SeriousActor.ref - context.watch(SeriousActor.ref) - SeriousActor.startPromise.success(true) - context.become { - case Terminated(`serious`) => - val seriousPromise2 = Promise[Boolean]() - // PinS, page 694 - val seriousActor2 = ActorDSL.actor( - new StashingActor { - - def receive = { case _ => context.stop(self) } - - override def preStart() = { - for (i <- 1 to 5) - println("That is the question.") - seriousPromise2.success(true) - context.stop(self) - } - }) - - Await.ready(seriousPromise2.future, 5 seconds) - val echoActor = makeEchoActor() - context.watch(echoActor) - echoActor ! "hi there" - echoActor ! 15 - echoActor ! 'stop - context.become { - case Terminated(_) => - unstashAll() - val intActor = makeIntActor() - intActor ! "hello" - intActor ! math.Pi - // only the following send leads to output - intActor ! 12 - context.unbecome() - context.unbecome() - context.stop(self) - case m => - println("Stash 1 " + m) - stash(m) - } - case m => - println("Stash 2 " + m) - stash(m) - } - case m => - println("Stash 3 " + m) - stash(m) - } - }) -} diff --git a/test/files/jvm/actmig-hierarchy.check b/test/files/jvm/actmig-hierarchy.check deleted file mode 100644 index 317e9677c3..0000000000 --- a/test/files/jvm/actmig-hierarchy.check +++ /dev/null @@ -1,2 +0,0 @@ -hello -hello diff --git a/test/files/jvm/actmig-hierarchy.scala b/test/files/jvm/actmig-hierarchy.scala deleted file mode 100644 index 17a44fda7a..0000000000 --- a/test/files/jvm/actmig-hierarchy.scala +++ /dev/null @@ -1,47 +0,0 @@ -/** - * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change - * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov. - */ -import scala.actors._ - - -class ReactorActor extends Reactor[String] { - def act() { - var cond = true - loopWhile(cond) { - react { - case x if x == "hello1" => println("hello") - case "exit" => cond = false - } - } - } -} - -class ReplyActor extends ReplyReactor { - def act() { - var cond = true - loopWhile(cond) { - react { - case "hello" => println("hello") - case "exit" => cond = false; - } - } - } -} - - -object Test { - - def main(args: Array[String]) { - val reactorActor = new ReactorActor - val replyActor = new ReplyActor - reactorActor.start() - replyActor.start() - - reactorActor ! "hello1" - replyActor ! "hello" - - reactorActor ! "exit" - replyActor ! "exit" - } -} \ No newline at end of file diff --git a/test/files/jvm/actmig-hierarchy_1.check b/test/files/jvm/actmig-hierarchy_1.check deleted file mode 100644 index 317e9677c3..0000000000 --- a/test/files/jvm/actmig-hierarchy_1.check +++ /dev/null @@ -1,2 +0,0 @@ -hello -hello diff --git a/test/files/jvm/actmig-hierarchy_1.scala b/test/files/jvm/actmig-hierarchy_1.scala deleted file mode 100644 index 14f03c9d48..0000000000 --- a/test/files/jvm/actmig-hierarchy_1.scala +++ /dev/null @@ -1,45 +0,0 @@ -/** - * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change - * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov. - */ -import scala.actors._ - -class ReactorActor extends Actor { - def act() { - var cond = true - loopWhile(cond) { - react { - case x: String if x == "hello1" => println("hello") - case "exit" => cond = false - } - } - } -} - -class ReplyActor extends Actor { - def act() { - var cond = true - loopWhile(cond) { - react { - case "hello" => println("hello") - case "exit" => cond = false; - } - } - } -} - -object Test { - - def main(args: Array[String]) { - val reactorActor = new ReactorActor - val replyActor = new ReplyActor - reactorActor.start() - replyActor.start() - - reactorActor ! "hello1" - replyActor ! "hello" - - reactorActor ! "exit" - replyActor ! "exit" - } -} \ No newline at end of file diff --git a/test/files/jvm/actmig-instantiation.check b/test/files/jvm/actmig-instantiation.check deleted file mode 100644 index 08ef979794..0000000000 --- a/test/files/jvm/actmig-instantiation.check +++ /dev/null @@ -1,8 +0,0 @@ -OK error: java.lang.RuntimeException: In order to create a StashingActor one must use the ActorDSL object -OK error: java.lang.RuntimeException: Cannot create more than one actor -0 -100 -200 -300 -400 -500 diff --git a/test/files/jvm/actmig-instantiation.scala b/test/files/jvm/actmig-instantiation.scala deleted file mode 100644 index 2e3ffc3c30..0000000000 --- a/test/files/jvm/actmig-instantiation.scala +++ /dev/null @@ -1,95 +0,0 @@ -/** - * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change - * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov. - */ -import scala.actors.migration._ -import scala.actors.Actor._ -import scala.actors._ -import java.util.concurrent.{ TimeUnit, CountDownLatch } -import scala.collection.mutable.ArrayBuffer - -class TestStashingActor extends StashingActor { - - def receive = { case v: Int => Test.append(v); Test.latch.countDown() } - -} - -object Test { - val NUMBER_OF_TESTS = 5 - - // used for sorting non-deterministic output - val buff = ArrayBuffer[Int](0) - val latch = new CountDownLatch(NUMBER_OF_TESTS) - val toStop = ArrayBuffer[ActorRef]() - - def append(v: Int) = synchronized { - buff += v - } - - def main(args: Array[String]) = { - // plain scala actor - val a1 = actor { - react { case v: Int => Test.append(v); Test.latch.countDown() } - } - a1 ! 100 - - // simple instantiation - val a2 = ActorDSL.actor(new TestStashingActor) - a2 ! 200 - toStop += a2 - - // actor of with scala actor - val a3 = ActorDSL.actor(actor { - react { case v: Int => Test.append(v); Test.latch.countDown() } - }) - a3 ! 300 - - // using the manifest - val a4 = ActorDSL.actor(new TestStashingActor) - a4 ! 400 - toStop += a4 - - // deterministic part of a test - // creation without actor - try { - val a3 = new TestStashingActor - a3 ! -1 - } catch { - case e: Throwable => println("OK error: " + e) - } - - // actor double creation - try { - val a3 = ActorDSL.actor({ - new TestStashingActor - new TestStashingActor - }) - a3 ! -1 - } catch { - case e: Throwable => println("OK error: " + e) - } - - // actor nesting - try { - val a5 = ActorDSL.actor({ - val a6 = ActorDSL.actor(new TestStashingActor) - toStop += a6 - new TestStashingActor - }) - - a5 ! 500 - toStop += a5 - } catch { - case e: Throwable => println("Should not throw an exception: " + e) - } - - // output - latch.await(5, TimeUnit.SECONDS) - if (latch.getCount() > 0) { - println("Error: Tasks have not finished!!!") - } - - buff.sorted.foreach(println) - toStop.foreach(_ ! PoisonPill) - } -} diff --git a/test/files/jvm/actmig-loop-react.check b/test/files/jvm/actmig-loop-react.check deleted file mode 100644 index 2474cbe71b..0000000000 --- a/test/files/jvm/actmig-loop-react.check +++ /dev/null @@ -1,16 +0,0 @@ -do task -do task -do task -do task -working -scala got exception -working -akka got exception -do task 1 -do string I am a String -do task 42 -after react -do task 1 -do string I am a String -do task 42 -after react diff --git a/test/files/jvm/actmig-loop-react.scala b/test/files/jvm/actmig-loop-react.scala deleted file mode 100644 index c9a3664526..0000000000 --- a/test/files/jvm/actmig-loop-react.scala +++ /dev/null @@ -1,195 +0,0 @@ -/** - * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change - * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov. - */ -import scala.actors.Actor._ -import scala.actors._ -import scala.actors.migration._ -import java.util.concurrent.{ TimeUnit, CountDownLatch } -import scala.collection.mutable.ArrayBuffer -import scala.concurrent.duration._ -import scala.concurrent.{ Promise, Await } - -object Test { - val finishedLWCR, finishedTNR, finishedEH = Promise[Boolean] - val finishedLWCR1, finishedTNR1, finishedEH1 = Promise[Boolean] - - def testLoopWithConditionReact() = { - // Snippet showing composition of receives - // Loop with Condition Snippet - before - val myActor = actor { - var c = true - loopWhile(c) { - react { - case x: Int => - // do task - println("do task") - if (x == 42) { - c = false - finishedLWCR1.success(true) - } - } - } - } - - myActor.start() - myActor ! 1 - myActor ! 42 - - Await.ready(finishedLWCR1.future, 5 seconds) - - // Loop with Condition Snippet - migrated - val myAkkaActor = ActorDSL.actor(new StashingActor { - - def receive = { - case x: Int => - // do task - println("do task") - if (x == 42) { - finishedLWCR.success(true) - context.stop(self) - } - } - }) - myAkkaActor ! 1 - myAkkaActor ! 42 - } - - def testNestedReact() = { - // Snippet showing composition of receives - // Loop with Condition Snippet - before - val myActor = actor { - var c = true - loopWhile(c) { - react { - case x: Int => - // do task - println("do task " + x) - if (x == 42) { - c = false - } else { - react { - case y: String => - println("do string " + y) - } - } - println("after react") - finishedTNR1.success(true) - } - } - } - myActor.start() - - myActor ! 1 - myActor ! "I am a String" - myActor ! 42 - - Await.ready(finishedTNR1.future, 5 seconds) - - // Loop with Condition Snippet - migrated - val myAkkaActor = ActorDSL.actor(new StashingActor { - - def receive = { - case x: Int => - // do task - println("do task " + x) - if (x == 42) { - println("after react") - finishedTNR.success(true) - context.stop(self) - } else - context.become(({ - case y: String => - println("do string " + y) - }: Receive).andThen(x => { - unstashAll() - context.unbecome() - }).orElse { case x => stash() }) - } - }) - - myAkkaActor ! 1 - myAkkaActor ! "I am a String" - myAkkaActor ! 42 - - } - - def exceptionHandling() = { - // Stashing actor with act and exception handler - val myActor = ActorDSL.actor(new StashingActor { - - def receive = { case _ => println("Dummy method.") } - override def act() = { - loop { - react { - case "fail" => - throw new Exception("failed") - case "work" => - println("working") - case "die" => - finishedEH1.success(true) - exit() - } - } - } - - override def exceptionHandler = { - case x: Exception => println("scala got exception") - } - - }) - - myActor ! "work" - myActor ! "fail" - myActor ! "die" - - Await.ready(finishedEH1.future, 5 seconds) - // Stashing actor in Akka style - val myAkkaActor = ActorDSL.actor(new StashingActor { - def receive = PFCatch({ - case "fail" => - throw new Exception("failed") - case "work" => - println("working") - case "die" => - finishedEH.success(true) - context.stop(self) - }, { case x: Exception => println("akka got exception") }) - }) - - myAkkaActor ! "work" - myAkkaActor ! "fail" - myAkkaActor ! "die" - } - - def main(args: Array[String]): Unit = { - testLoopWithConditionReact() - Await.ready(finishedLWCR.future, 5 seconds) - exceptionHandling() - Await.ready(finishedEH.future, 5 seconds) - testNestedReact() - Await.ready(finishedTNR.future, 5 seconds) - } - -} - -// As per Jim Mcbeath's blog (http://jim-mcbeath.blogspot.com/2008/07/actor-exceptions.html) -class PFCatch(f: PartialFunction[Any, Unit], - handler: PartialFunction[Exception, Unit]) - extends PartialFunction[Any, Unit] { - - def apply(x: Any) = { - try { - f(x) - } catch { - case e: Exception if handler.isDefinedAt(e) => handler(e) - } - } - - def isDefinedAt(x: Any) = f.isDefinedAt(x) -} - -object PFCatch { - def apply(f: PartialFunction[Any, Unit], - handler: PartialFunction[Exception, Unit]) = new PFCatch(f, handler) -} diff --git a/test/files/jvm/actmig-public-methods.check b/test/files/jvm/actmig-public-methods.check deleted file mode 100644 index c861c90e63..0000000000 --- a/test/files/jvm/actmig-public-methods.check +++ /dev/null @@ -1,6 +0,0 @@ -None -Some(bang qmark after 1) -bang -bang bang in the future after 0 -bang qmark after 0 -typed bang bang in the future after 0 diff --git a/test/files/jvm/actmig-public-methods.scala b/test/files/jvm/actmig-public-methods.scala deleted file mode 100644 index 8891c80668..0000000000 --- a/test/files/jvm/actmig-public-methods.scala +++ /dev/null @@ -1,73 +0,0 @@ -/** - * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change - * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov. - */ -import scala.collection.mutable.ArrayBuffer -import scala.actors.Actor._ -import scala.actors._ -import scala.util.continuations._ -import java.util.concurrent.{ TimeUnit, CountDownLatch } - -object Test { - val NUMBER_OF_TESTS = 6 - - // used for sorting non-deterministic output - val buff = ArrayBuffer[String]() - val latch = new CountDownLatch(NUMBER_OF_TESTS) - val toStop = ArrayBuffer[Actor]() - - def append(v: String) = synchronized { - buff += v - } - - def main(args: Array[String]) = { - - val respActor = actor { - loop { - react { - case (x: String, time: Long) => - Thread.sleep(time) - reply(x + " after " + time) - case str: String => - append(str) - latch.countDown() - case _ => exit() - } - } - } - - toStop += respActor - - respActor ! ("bang") - - val res1 = respActor !? (("bang qmark", 0L)) - append(res1.toString) - latch.countDown() - - val res2 = respActor !? (5000, ("bang qmark", 1L)) - append(res2.toString) - latch.countDown() - - // this one should timeout - val res21 = respActor !? (1, ("bang qmark", 5000L)) - append(res21.toString) - latch.countDown() - - val fut1 = respActor !! (("bang bang in the future", 0L)) - append(fut1().toString()) - latch.countDown() - - val fut2 = respActor !! (("typed bang bang in the future", 0L), { case x: String => x }) - append(fut2()) - latch.countDown() - - // output - latch.await(10, TimeUnit.SECONDS) - if (latch.getCount() > 0) { - println("Error: Tasks have not finished!!!") - } - - buff.sorted.foreach(println) - toStop.foreach(_ ! 'stop) - } -} diff --git a/test/files/jvm/actmig-public-methods_1.check b/test/files/jvm/actmig-public-methods_1.check deleted file mode 100644 index c861c90e63..0000000000 --- a/test/files/jvm/actmig-public-methods_1.check +++ /dev/null @@ -1,6 +0,0 @@ -None -Some(bang qmark after 1) -bang -bang bang in the future after 0 -bang qmark after 0 -typed bang bang in the future after 0 diff --git a/test/files/jvm/actmig-public-methods_1.scala b/test/files/jvm/actmig-public-methods_1.scala deleted file mode 100644 index db21ab983c..0000000000 --- a/test/files/jvm/actmig-public-methods_1.scala +++ /dev/null @@ -1,104 +0,0 @@ -/** - * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change - * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov. - */ -import scala.collection.mutable.ArrayBuffer -import scala.actors.Actor._ -import scala.actors._ -import scala.actors.migration._ -import scala.util._ -import scala.concurrent._ -import scala.concurrent.duration._ -import java.util.concurrent.{ TimeUnit, CountDownLatch } -import scala.concurrent.duration._ -import scala.actors.migration.pattern._ -import scala.concurrent.ExecutionContext.Implicits.global - -object Test { - val NUMBER_OF_TESTS = 6 - - // used for sorting non-deterministic output - val buff = ArrayBuffer[String]() - val latch = new CountDownLatch(NUMBER_OF_TESTS) - val toStop = ArrayBuffer[ActorRef]() - - def append(v: String) = synchronized { - buff += v - } - - def main(args: Array[String]) = { - - val respActor = ActorDSL.actor(actor { - loop { - react { - case (x: String, time: Long) => - Thread.sleep(time) - reply(x + " after " + time) - case str: String => - append(str) - latch.countDown() - case x => - exit() - } - } - }) - - toStop += respActor - - respActor ! "bang" - - { - val msg = ("bang qmark", 0L) - val res = respActor.?(msg)(Timeout(Duration.Inf)) - append(Await.result(res, Duration.Inf).toString) - latch.countDown() - } - - { - val msg = ("bang qmark", 1L) - val res = respActor.?(msg)(Timeout(5 seconds)) - - val promise = Promise[Option[Any]]() - res.onComplete(v => promise.success(v.toOption)) - append(Await.result(promise.future, Duration.Inf).toString) - - latch.countDown() - } - - { - val msg = ("bang qmark", 5000L) - val res = respActor.?(msg)(Timeout(1 millisecond)) - val promise = Promise[Option[Any]]() - res.onComplete(v => promise.success(v.toOption)) - append(Await.result(promise.future, Duration.Inf).toString) - latch.countDown() - } - - { - val msg = ("bang bang in the future", 0L) - val fut = respActor.?(msg)(Timeout(Duration.Inf)) - append(Await.result(fut, Duration.Inf).toString) - latch.countDown() - } - - { - val handler: PartialFunction[Any, String] = { - case x: String => x - } - - val msg = ("typed bang bang in the future", 0L) - val fut = (respActor.?(msg)(Timeout(Duration.Inf))) - append((Await.result(fut.map(handler), Duration.Inf)).toString) - latch.countDown() - } - - // output - latch.await(10, TimeUnit.SECONDS) - if (latch.getCount() > 0) { - println("Error: Tasks have not finished!!!") - } - - buff.sorted.foreach(println) - toStop.foreach(_ ! PoisonPill) - } -} diff --git a/test/files/jvm/actmig-react-receive.check b/test/files/jvm/actmig-react-receive.check deleted file mode 100644 index cc2a426e68..0000000000 --- a/test/files/jvm/actmig-react-receive.check +++ /dev/null @@ -1,16 +0,0 @@ -do before -do task -do after -do before -do task -do after -do before -do task -do in between -do string -do after -do before -do task -do in between -do string -do after diff --git a/test/files/jvm/actmig-react-receive.scala b/test/files/jvm/actmig-react-receive.scala deleted file mode 100644 index bf70ce0c46..0000000000 --- a/test/files/jvm/actmig-react-receive.scala +++ /dev/null @@ -1,115 +0,0 @@ -/** - * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change - * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov. - */ -import scala.actors.Actor._ -import scala.actors._ -import scala.actors.migration._ -import java.util.concurrent.{ TimeUnit, CountDownLatch } -import scala.collection.mutable.ArrayBuffer -import scala.concurrent.duration._ -import scala.concurrent.{ Promise, Await } - -object Test { - val finishedRS, finishedRS1, finishedRSC, finishedRSC1 = Promise[Boolean] - def testComposition() = { - // Snippet showing composition of receives - // React Snippet - before - val myActor = actor { - // do before - println("do before") - receive { - case x: Int => - // do task - println("do task") - } - println("do in between") - receive { - case x: String => - // do string now - println("do string") - } - println("do after") - finishedRSC1.success(true) - } - myActor.start() - myActor ! 1 - myActor ! "1" - Await.ready(finishedRSC1.future, 5 seconds) - - // React Snippet - migrated - val myAkkaActor = ActorDSL.actor(new StashingActor { - override def preStart() = { - println("do before") - } - - def receive = ({ - case x: Int => - // do task - println("do task") - }: Receive) andThen { v => - context.become { - case x: String => - //do string - println("do string") - context.stop(self) - } - println("do in between") - } - - override def postStop() = { - println("do after") - finishedRSC.success(true) - } - - }) - myAkkaActor ! 1 - myAkkaActor ! "1" - Await.ready(finishedRSC.future, 5 seconds) - } - - def main(args: Array[String]) = { - // React Snippet - before - val myActor = actor { - // do before - println("do before") - receive { - case x: Int => - // do task - println("do task") - } - println("do after") - finishedRS1.success(true) - } - myActor.start() - myActor ! 1 - - Await.ready(finishedRS1.future, 5 seconds) - - // React Snippet - migrated - val myAkkaActor = ActorDSL.actor(new StashingActor { - override def preStart() = { - println("do before") - } - - def receive = { - case x: Int => - // do task - println("do task") - context.stop(self) - } - - override def postStop() = { - println("do after") - finishedRS.success(true) - } - - }) - myAkkaActor ! 1 - - Await.ready(finishedRS.future, 5 seconds) - // Starting composition test - testComposition() - - } -} diff --git a/test/files/jvm/actmig-react-within.check b/test/files/jvm/actmig-react-within.check deleted file mode 100644 index 57798dbefb..0000000000 --- a/test/files/jvm/actmig-react-within.check +++ /dev/null @@ -1,2 +0,0 @@ -received -received diff --git a/test/files/jvm/actmig-react-within.scala b/test/files/jvm/actmig-react-within.scala deleted file mode 100644 index 3057398cb5..0000000000 --- a/test/files/jvm/actmig-react-within.scala +++ /dev/null @@ -1,47 +0,0 @@ -/** - * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change - * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov. - */ -import scala.actors.Actor._ -import scala.actors._ -import scala.actors.migration._ -import java.util.concurrent.{ TimeUnit, CountDownLatch } -import scala.collection.mutable.ArrayBuffer -import scala.concurrent.duration._ -import scala.concurrent.{ Promise, Await } - -object Test { - val finished = Promise[Boolean] - - def testReactWithin() = { - val sActor = actor { - loop { - reactWithin(1) { - case scala.actors.TIMEOUT => - println("received") - exit() - case _ => - println("Should not occur.") - } - } - } - - val myActor = ActorDSL.actor(new StashingActor { - context.setReceiveTimeout(1 millisecond) - def receive = { - case ReceiveTimeout => - println("received") - finished.success(true) - context.stop(self) - case _ => - println("Should not occur.") - } - }) - } - - def main(args: Array[String]) = { - testReactWithin() - Await.ready(finished.future, 5 seconds) - } - -} diff --git a/test/files/jvm/actmig-receive.check b/test/files/jvm/actmig-receive.check deleted file mode 100644 index 30886140e1..0000000000 --- a/test/files/jvm/actmig-receive.check +++ /dev/null @@ -1,27 +0,0 @@ -Original -do before -receive 1 -do in between -receive 1 -do after -Transformed -do before -receive 1 -do in between -receive 1 -do after -Test Loop Receive -Original -do before body -receive 1 -do after receive -do before body -do after receive -after loop -Transformed -do before body -receive 1 -do after receive -do before body -do after receive -after loop diff --git a/test/files/jvm/actmig-receive.scala b/test/files/jvm/actmig-receive.scala deleted file mode 100644 index 308643cf41..0000000000 --- a/test/files/jvm/actmig-receive.scala +++ /dev/null @@ -1,119 +0,0 @@ -/** - * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change - * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov. - */ -import scala.actors.Actor._ -import scala.actors._ -import scala.actors.migration._ -import java.util.concurrent.{ TimeUnit, CountDownLatch } -import scala.collection.mutable.ArrayBuffer -import scala.concurrent.duration._ -import scala.concurrent.{ Promise, Await } - -object Test { - val finishedSingle, finishedSingle1, finishedLoop, finishedLoop1 = Promise[Boolean] - - def testDoubleReceive() = { - println("Original") - // Snippet that shows how to get rid of receive calls in Scala Actors. - // This snippet is used in the Actors Migration Kit. - val myActor = actor { - println("do before") - receive { - case "hello" => - println("receive 1") - } - println("do in between") - receive { - case "hello" => - println("receive 1") - } - println("do after") - finishedSingle.success(true) - } - - myActor ! "hello" - myActor ! "hello" - - Await.ready(finishedSingle.future, 5 seconds) - println("Transformed") - val myActorReact = actor { - println("do before") - react (({ - case "hello" => - println("receive 1") - }: PartialFunction[Any, Unit]).andThen { x => - println("do in between") - react (({ - case "hello" => - println("receive 1") - }: PartialFunction[Any, Unit]).andThen { x => - println("do after") - finishedSingle1.success(true) - }) - }) - } - - myActorReact ! "hello" - myActorReact ! "hello" - - Await.ready(finishedSingle1.future, 5 seconds) - } - - def testLoopReceive() = { - println("Test Loop Receive") - // Snippet that shows how to get rid of receive calls in loops. - // This snippet is used in the Actors Migration Kit. - println("Original") - val myActor = actor { - var c = true - while (c) { - println("do before body") - receive { - case "hello" => - println("receive 1") - case "exit" => - c = false - } - println("do after receive") - } - println("after loop") - finishedLoop.success(true) - } - - myActor ! "hello" - myActor ! "exit" - Await.ready(finishedLoop.future, 5 seconds) - println("Transformed") - - val myActorReact = actor { - var c = true - loopWhile(c) { - println("do before body") - react (({ - case "hello" => - println("receive 1") - case "exit" => - c = false - }: PartialFunction[Any, Unit]).andThen { x => - println("do after receive") - if (c == false) { - println("after loop") - finishedLoop1.success(true) - } - }) - } - } - - myActorReact ! "hello" - myActorReact ! "exit" - - Await.ready(finishedLoop1.future, 5 seconds) - } - - def main(args: Array[String]) = { - testDoubleReceive() - testLoopReceive() - } - -} -- cgit v1.2.3 From fb6e68713060e7904a7d93012470a946ca7e2375 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 30 Oct 2012 17:34:15 +0100 Subject: SI-6556 no assert for surprising ctor result type Previous fix to value classes uncovered some questionable cases in the backend where result types of constructor signatures are surprising. It's not a big deal because these types will be ignored afterwards anyway. But the method uncovered some questionable situations which we should follow up on. However, breaking 2.9 code because of this is way too harsh. That's why the asserts were converted to warnings. review by @paulp, @adriaanm --- .../scala/reflect/internal/transform/Erasure.scala | 14 +++++++++- test/files/pos/t6556.scala | 32 ++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 test/files/pos/t6556.scala (limited to 'test/files') diff --git a/src/reflect/scala/reflect/internal/transform/Erasure.scala b/src/reflect/scala/reflect/internal/transform/Erasure.scala index 977398909f..52d1657dc3 100644 --- a/src/reflect/scala/reflect/internal/transform/Erasure.scala +++ b/src/reflect/scala/reflect/internal/transform/Erasure.scala @@ -214,6 +214,9 @@ trait Erasure { specialConstructorErasure(clazz, restpe) case ExistentialType(tparams, restpe) => specialConstructorErasure(clazz, restpe) + case RefinedType(parents, decls) => + specialConstructorErasure( + clazz, specialScalaErasure.mergeParents(parents)) case mt @ MethodType(params, restpe) => MethodType( cloneSymbolsAndModify(params, specialScalaErasure), @@ -221,7 +224,16 @@ trait Erasure { case TypeRef(pre, `clazz`, args) => typeRef(pre, clazz, List()) case tp => - assert(clazz == ArrayClass || tp.isError, s"unexpected constructor erasure $tp for $clazz") + if (!(clazz == ArrayClass || tp.isError)) + // See SI-6556. It seems in some cases the result constructor + // type of an anonymous class is a different version of the class. + // This has nothing to do with value classes per se. + // We simply used a less discriminating transform before, that + // did not look at the cases in detail. + // It seems there is a deeper problem here, which needs + // following up to. But we will not risk regressions + // in 2.10 because of it. + log(s"!!! unexpected constructor erasure $tp for $clazz") specialScalaErasure(tp) } } diff --git a/test/files/pos/t6556.scala b/test/files/pos/t6556.scala new file mode 100644 index 0000000000..e1a6f49b86 --- /dev/null +++ b/test/files/pos/t6556.scala @@ -0,0 +1,32 @@ +package nl.ndervorst.commons.scalapimps + +trait Adapter[X] {self => + type This = self.type + val adaptee: X + val adapt: This = self +} + +object Adapter { + implicit def adaptee[Adaptee](adapter: Adapter[Adaptee]) = adapter.adaptee +} + + + +object IterableW { + def zipMerge[E](it1: Iterable[E], it2: Iterable[E])(implicit o: Ordering[E]): Iterable[(Option[E], Option[E])] = null +} + + +class Series[X: Ordering, Y](val adaptee: Iterable[(X, Y)]) extends Adapter[Iterable[(X, Y)]] { + val order = implicitly[Ordering[X]] + def zipMerge(other: Series[X, Y]): Series[X, (Option[Y], Option[Y])] = IterableW.zipMerge(this, other)(new Ordering[(X, Y)] { + def compare(xy1: (X, Y), xy2: (X, Y)) = order.compare(xy1._1, xy2._1) + }).map { + case _ => null + } +} + + +object Series { + implicit def wrap[X: Ordering, Y](itble: Iterable[(X, Y)]): Series[X, Y] = new Series(itble) +} -- cgit v1.2.3 From 1e2328ea6a8b592b5a2abe3557dc633e96f688f2 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Wed, 31 Oct 2012 14:08:29 -0700 Subject: Fix for SI-6597, implicit case class crasher. It seems to me like every call to scope.lookup in the compiler is a latent bug. If a symbol is overloaded, you get one at random. (See the FIXME comment in f5c336d5660 for more on this.) --- src/compiler/scala/tools/nsc/typechecker/Namers.scala | 2 +- test/files/neg/t6597.check | 4 ++++ test/files/neg/t6597.scala | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 test/files/neg/t6597.check create mode 100644 test/files/neg/t6597.scala (limited to 'test/files') diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index 9e9a22d4d1..e1afe153ad 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -398,7 +398,7 @@ trait Namers extends MethodSynthesis { * a module definition or a class definition. */ def enterModuleSymbol(tree : ModuleDef): Symbol = { - var m: Symbol = context.scope.lookup(tree.name) + var m: Symbol = context.scope lookupAll tree.name find (_.isModule) getOrElse NoSymbol val moduleFlags = tree.mods.flags | MODULE if (m.isModule && !m.isPackage && inCurrentScope(m) && (currentRun.canRedefine(m) || m.isSynthetic)) { updatePosFlags(m, tree.pos, moduleFlags) diff --git a/test/files/neg/t6597.check b/test/files/neg/t6597.check new file mode 100644 index 0000000000..1d52519d1d --- /dev/null +++ b/test/files/neg/t6597.check @@ -0,0 +1,4 @@ +t6597.scala:3: error: illegal combination of modifiers: implicit and case for: class Quux + implicit case class Quux(value: Int) extends AnyVal with T + ^ +one error found diff --git a/test/files/neg/t6597.scala b/test/files/neg/t6597.scala new file mode 100644 index 0000000000..dde53bcc89 --- /dev/null +++ b/test/files/neg/t6597.scala @@ -0,0 +1,5 @@ +object Test { + trait T extends Any + implicit case class Quux(value: Int) extends AnyVal with T + object Quux +} -- cgit v1.2.3 From c9efa2f6cf9fcfff00a29aeae5b400aaf5518e32 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Tue, 30 Oct 2012 15:17:05 -0400 Subject: Removing actors-migration from main repository so it can live on elsewhere. * Removes actors-migration hooks from partest * Removes actors-migration code * removes actors-migration tests * removes actors-migration distribution packaging. --- project/Testing.scala | 4 +- src/actors/scala/actors/ActorRef.scala | 74 --------------------------- test/files/jvm/actmig-remote-actor-self.check | 1 - test/files/jvm/actmig-remote-actor-self.scala | 34 ------------ 4 files changed, 2 insertions(+), 111 deletions(-) delete mode 100644 test/files/jvm/actmig-remote-actor-self.check delete mode 100644 test/files/jvm/actmig-remote-actor-self.scala (limited to 'test/files') diff --git a/project/Testing.scala b/project/Testing.scala index cec1d8c60b..5de72116a3 100644 --- a/project/Testing.scala +++ b/project/Testing.scala @@ -29,12 +29,12 @@ trait Testing { self: ScalaBuild.type => val testsuite = ( Project("testsuite", file(".")) settings (testsuiteSettings:_*) - dependsOn (scalaLibrary, scalaCompiler, fjbg, partest, scalacheck, actorsMigration) + dependsOn (scalaLibrary, scalaCompiler, fjbg, partest, scalacheck) ) val continuationsTestsuite = ( Project("continuations-testsuite", file(".")) settings (continuationsTestsuiteSettings:_*) - dependsOn (partest, scalaLibrary, scalaCompiler, fjbg, actorsMigration) + dependsOn (partest, scalaLibrary, scalaCompiler, fjbg) ) } diff --git a/src/actors/scala/actors/ActorRef.scala b/src/actors/scala/actors/ActorRef.scala index cca78b0832..5c1790669b 100644 --- a/src/actors/scala/actors/ActorRef.scala +++ b/src/actors/scala/actors/ActorRef.scala @@ -2,8 +2,6 @@ package scala.actors import java.util.concurrent.TimeoutException import scala.concurrent.duration.Duration -import scala.concurrent.Promise -import scala.concurrent.ExecutionContext.Implicits.global /** * Trait used for migration of Scala actors to Akka. @@ -43,78 +41,6 @@ trait ActorRef { } -private[actors] class OutputChannelRef(val actor: OutputChannel[Any]) extends ActorRef { - - override private[actors] def ?(message: Any, timeout: Duration): scala.concurrent.Future[Any] = - throw new UnsupportedOperationException("Output channel does not support ?") - - /** - * Sends a one-way asynchronous message. E.g. fire-and-forget semantics. - *

- * - *

- *

-   *   actor ! message
-   * 
- *

- */ - def !(message: Any)(implicit sender: ActorRef = null): Unit = - if (sender != null) - actor.send(message, sender.localActor) - else - actor ! message - - override def equals(that: Any) = - that.isInstanceOf[OutputChannelRef] && that.asInstanceOf[OutputChannelRef].actor == this.actor - - private[actors] override def localActor: AbstractActor = - throw new UnsupportedOperationException("Output channel does not have an instance of the actor") - - def forward(message: Any): Unit = throw new UnsupportedOperationException("OutputChannel does not support forward.") - -} - -private[actors] class ReactorRef(override val actor: Reactor[Any]) extends OutputChannelRef(actor) { - - /** - * Forwards the message and passes the original sender actor as the sender. - *

- * Works with '!' and '?'. - */ - override def forward(message: Any) = actor.forward(message) - -} - -private[actors] final class InternalActorRef(override val actor: InternalActor) extends ReactorRef(actor) { - - /** - * Sends a message asynchronously, returning a future which may eventually hold the reply. - */ - override private[actors] def ?(message: Any, timeout: Duration): scala.concurrent.Future[Any] = { - val dur = if (timeout.isFinite()) timeout.toMillis else (java.lang.Long.MAX_VALUE >> 2) - val replyPromise = Promise[Any] - scala.concurrent.future { - scala.concurrent.blocking { - actor !? (dur, message) - } match { - case Some(x) => replyPromise success x - case None => replyPromise failure new AskTimeoutException("? operation timed out.") - } - } - replyPromise.future - } - - override def !(message: Any)(implicit sender: ActorRef = null): Unit = - if (message == PoisonPill) - actor.stop('normal) - else if (sender != null) - actor.send(message, sender.localActor) - else - actor ! message - - private[actors] override def localActor: InternalActor = this.actor -} - /** * This is what is used to complete a Future that is returned from an ask/? call, * when it times out. diff --git a/test/files/jvm/actmig-remote-actor-self.check b/test/files/jvm/actmig-remote-actor-self.check deleted file mode 100644 index 79d23cb337..0000000000 --- a/test/files/jvm/actmig-remote-actor-self.check +++ /dev/null @@ -1 +0,0 @@ -registered diff --git a/test/files/jvm/actmig-remote-actor-self.scala b/test/files/jvm/actmig-remote-actor-self.scala deleted file mode 100644 index 2b994f6081..0000000000 --- a/test/files/jvm/actmig-remote-actor-self.scala +++ /dev/null @@ -1,34 +0,0 @@ -/** - * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change - * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov. - */ -import scala.actors._ -import scala.actors.migration._ -import scala.actors.remote._ -import scala.actors.remote.RemoteActor._ -import scala.concurrent._ -import scala.concurrent.duration._ - -object Test { - val finished = Promise[Boolean] - - def main(args: Array[String]): Unit = { - - // can fail with class cast exception in alive - val myAkkaActor = ActorDSL.actor(new StashingActor { - override def preStart() = { - alive(42013) - println("registered") - finished success true - context.stop(self) - } - - def receive = { - case x: Int => - } - }) - - Await.result(finished.future, Duration.Inf).toString - } - -} -- cgit v1.2.3 From a525d371e10b2bb9b6a2228f67603aa318f97716 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Thu, 25 Oct 2012 08:00:16 +0200 Subject: SI-6562 Fix crash with class nested in @inline method e6b4204604 moved access widenings from ExplicitOuter to SuperAccessors to reflect them in pickled signatures so that the inliner can take advantage of them under separate compilation. The followup discussion [1] determined that this wasn't the right solution: while it enabled new separate compilation inlinings, it failed to widen access of outer pointers and hence prevented certain inlinings. A better solution was proposed: modify the inliner to know that access widening is guaranteed to have happened in ExplicitOuter for any field accessed by an @inline-d method body, rather than relying solely on the pickled types. But this hasn't happened yet. In the meantime 07f94297 / #1121 reinstated the access widening to SuperAccessors, but took a slightly different approach, using `Symbol#enclMethod` rather than `closestEnclMethod`. That deviation triggers SI-6562. This commit goes back to `closestEnclMethod`. [1] https://groups.google.com/forum/#!topic/scala-internals/iPkMCygzws4 --- src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala | 5 ++++- .../scala/tools/nsc/typechecker/SuperAccessors.scala | 12 +++++------- src/reflect/scala/reflect/internal/Symbols.scala | 8 ++++++++ test/files/pos/t6562.scala | 14 ++++++++++++++ 4 files changed, 31 insertions(+), 8 deletions(-) create mode 100644 test/files/pos/t6562.scala (limited to 'test/files') diff --git a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala index 77ad65957d..3ac19650eb 100644 --- a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala +++ b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala @@ -499,8 +499,11 @@ abstract class ExplicitOuter extends InfoTransform case Select(qual, name) => // make not private symbol acessed from inner classes, as well as // symbols accessed from @inline methods + // + // See SI-6552 for an example of why `sym.owner.enclMethod hasAnnotation ScalaInlineClass` + // is not suitable; if we make a method-local class non-private, it mangles outer pointer names. if (currentClass != sym.owner || - (sym.owner.enclMethod hasAnnotation ScalaInlineClass)) + (closestEnclMethod(currentOwner) hasAnnotation ScalaInlineClass)) sym.makeNotPrivate(sym.owner) val qsym = qual.tpe.widen.typeSymbol diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala index 981ba10183..6b9848a1c9 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala @@ -234,14 +234,12 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT case sel @ Select(qual, name) => def transformSelect = { - /** return closest enclosing method, unless shadowed by an enclosing class; - * no use of closures here in the interest of speed. - */ - def closestEnclMethod(from: Symbol): Symbol = - if (from.isSourceMethod) from - else if (from.isClass) NoSymbol - else closestEnclMethod(from.owner) + // FIXME Once Inliners is modified with the "'meta-knowledge' that all fields accessed by @inline will be made public" [1] + // this can be removed; the correct place for this in in ExplicitOuter. + // + // [1] https://groups.google.com/forum/#!topic/scala-internals/iPkMCygzws4 + // if (closestEnclMethod(currentOwner) hasAnnotation definitions.ScalaInlineClass) sym.makeNotPrivate(sym.owner) diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala index a6f156f947..4afebab493 100644 --- a/src/reflect/scala/reflect/internal/Symbols.scala +++ b/src/reflect/scala/reflect/internal/Symbols.scala @@ -3269,6 +3269,14 @@ trait Symbols extends api.Symbols { self: SymbolTable => */ def mapParamss[T](sym: Symbol)(f: Symbol => T): List[List[T]] = mmap(sym.info.paramss)(f) + /** Return closest enclosing method, unless shadowed by an enclosing class. */ + // TODO Move back to ExplicitOuter when the other call site is removed. + // no use of closures here in the interest of speed. + final def closestEnclMethod(from: Symbol): Symbol = + if (from.isSourceMethod) from + else if (from.isClass) NoSymbol + else closestEnclMethod(from.owner) + /** An exception for cyclic references of symbol definitions */ case class CyclicReference(sym: Symbol, info: Type) extends TypeError("illegal cyclic reference involving " + sym) { diff --git a/test/files/pos/t6562.scala b/test/files/pos/t6562.scala new file mode 100644 index 0000000000..eec7aa5199 --- /dev/null +++ b/test/files/pos/t6562.scala @@ -0,0 +1,14 @@ +class Test { + + @inline + def foo { + def it = new {} + (_: Any) => it + } + + @inline + private def bar { + def it = new {} + (_: Any) => it + } +} -- cgit v1.2.3 From 817da386e456be422861ac6e974838e6eb6db836 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Fri, 2 Nov 2012 13:10:54 -0700 Subject: Fix for SI-6600, regression with ScalaNumber. Not much in the end; I divided ScalaNumericConversions into two traits such that the ScalaNumericAnyConversions can be used in value classes, and ScalaNumericConversions can override methods in ScalaNumber (since one trait cannot do both those things.) The fact that ScalaNumber is privileged for equality but a) extends java.lang.Number and therefore b) cannot be a value class is something we will want to revisit real soon. --- src/library/scala/math/ScalaNumericConversions.scala | 15 +++++++++++---- src/library/scala/runtime/ScalaNumberProxy.scala | 6 ++++-- test/files/pos/t6600.scala | 8 ++++++++ 3 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 test/files/pos/t6600.scala (limited to 'test/files') diff --git a/src/library/scala/math/ScalaNumericConversions.scala b/src/library/scala/math/ScalaNumericConversions.scala index edf243e5df..08c4118b00 100644 --- a/src/library/scala/math/ScalaNumericConversions.scala +++ b/src/library/scala/math/ScalaNumericConversions.scala @@ -10,15 +10,22 @@ package scala.math import java.{ lang => jl } +/** A slightly more specific conversion trait for classes which + * extend ScalaNumber (which excludes value classes.) + */ +trait ScalaNumericConversions extends ScalaNumber with ScalaNumericAnyConversions { + def underlying(): Object +} + /** Conversions which present a consistent conversion interface - * across all the numeric types. + * across all the numeric types, suitable for use in value classes. */ -trait ScalaNumericConversions extends Any { +trait ScalaNumericAnyConversions extends Any { def isWhole(): Boolean def underlying(): Any - def byteValue(): Byte = intValue().toByte - def shortValue(): Short = intValue().toShort + def byteValue(): Byte + def shortValue(): Short def intValue(): Int def longValue(): Long def floatValue(): Float diff --git a/src/library/scala/runtime/ScalaNumberProxy.scala b/src/library/scala/runtime/ScalaNumberProxy.scala index df2d209e3e..e461783423 100644 --- a/src/library/scala/runtime/ScalaNumberProxy.scala +++ b/src/library/scala/runtime/ScalaNumberProxy.scala @@ -9,7 +9,7 @@ package scala.runtime import scala.collection.{ mutable, immutable } -import scala.math.ScalaNumericConversions +import scala.math.{ ScalaNumericConversions, ScalaNumericAnyConversions } import immutable.NumericRange import Proxy.Typed @@ -20,7 +20,7 @@ import Proxy.Typed * @version 2.9 * @since 2.9 */ -trait ScalaNumberProxy[T] extends Any with ScalaNumericConversions with Typed[T] with OrderedProxy[T] { +trait ScalaNumberProxy[T] extends Any with ScalaNumericAnyConversions with Typed[T] with OrderedProxy[T] { protected implicit def num: Numeric[T] def underlying() = self.asInstanceOf[AnyRef] @@ -28,6 +28,8 @@ trait ScalaNumberProxy[T] extends Any with ScalaNumericConversions with Typed[T] def floatValue() = num.toFloat(self) def longValue() = num.toLong(self) def intValue() = num.toInt(self) + def byteValue() = intValue.toByte + def shortValue() = intValue.toShort def min(that: T): T = num.min(self, that) def max(that: T): T = num.max(self, that) diff --git a/test/files/pos/t6600.scala b/test/files/pos/t6600.scala new file mode 100644 index 0000000000..1e8137894c --- /dev/null +++ b/test/files/pos/t6600.scala @@ -0,0 +1,8 @@ +final class Natural extends scala.math.ScalaNumber with scala.math.ScalaNumericConversions { + def intValue(): Int = 0 + def longValue(): Long = 0L + def floatValue(): Float = 0.0F + def doubleValue(): Double = 0.0D + def isWhole(): Boolean = false + def underlying() = this +} -- cgit v1.2.3