diff options
Diffstat (limited to 'test/files')
39 files changed, 731 insertions, 56 deletions
diff --git a/test/files/jvm/actmig-PinS.scala b/test/files/jvm/actmig-PinS.scala index 30307f3737..3f07fab12e 100644 --- a/test/files/jvm/actmig-PinS.scala +++ b/test/files/jvm/actmig-PinS.scala @@ -1,3 +1,7 @@ +/** + * 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 } diff --git a/test/files/jvm/actmig-PinS_1.scala b/test/files/jvm/actmig-PinS_1.scala index db3ced3f0e..876688ca75 100644 --- a/test/files/jvm/actmig-PinS_1.scala +++ b/test/files/jvm/actmig-PinS_1.scala @@ -1,3 +1,7 @@ +/** + * 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._ diff --git a/test/files/jvm/actmig-PinS_2.scala b/test/files/jvm/actmig-PinS_2.scala index b2627b4628..7d12578f71 100644 --- a/test/files/jvm/actmig-PinS_2.scala +++ b/test/files/jvm/actmig-PinS_2.scala @@ -1,3 +1,7 @@ +/** + * 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._ diff --git a/test/files/jvm/actmig-PinS_3.scala b/test/files/jvm/actmig-PinS_3.scala index 8a5eded443..c2943008b0 100644 --- a/test/files/jvm/actmig-PinS_3.scala +++ b/test/files/jvm/actmig-PinS_3.scala @@ -1,3 +1,7 @@ +/** + * 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._ diff --git a/test/files/jvm/actmig-hierarchy.scala b/test/files/jvm/actmig-hierarchy.scala new file mode 100644 index 0000000000..17a44fda7a --- /dev/null +++ b/test/files/jvm/actmig-hierarchy.scala @@ -0,0 +1,47 @@ +/** + * 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.scala b/test/files/jvm/actmig-hierarchy_1.scala new file mode 100644 index 0000000000..14f03c9d48 --- /dev/null +++ b/test/files/jvm/actmig-hierarchy_1.scala @@ -0,0 +1,45 @@ +/** + * 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.scala b/test/files/jvm/actmig-instantiation.scala new file mode 100644 index 0000000000..d54dff9558 --- /dev/null +++ b/test/files/jvm/actmig-instantiation.scala @@ -0,0 +1,96 @@ +/** + * 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.MigrationSystem._ +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 = MigrationSystem.actorOf(Props(() => new TestStashingActor, "akka.actor.default-stash-dispatcher")) + a2 ! 200 + toStop += a2 + + // actor of with scala actor + val a3 = MigrationSystem.actorOf(Props(() => actor { + react { case v: Int => Test.append(v); Test.latch.countDown() } + }, "akka.actor.default-stash-dispatcher")) + a3 ! 300 + + // using the manifest + val a4 = MigrationSystem.actorOf(Props(() => new TestStashingActor, "akka.actor.default-stash-dispatcher")) + a4 ! 400 + toStop += a4 + + // deterministic part of a test + // creation without actorOf + try { + val a3 = new TestStashingActor + a3 ! -1 + } catch { + case e => println("OK error: " + e) + } + + // actorOf double creation + try { + val a3 = MigrationSystem.actorOf(Props(() => { + new TestStashingActor + new TestStashingActor + }, "akka.actor.default-stash-dispatcher")) + a3 ! -1 + } catch { + case e => println("OK error: " + e) + } + + // actorOf nesting + try { + val a5 = MigrationSystem.actorOf(Props(() => { + val a6 = MigrationSystem.actorOf(Props(() => new TestStashingActor, "akka.actor.default-stash-dispatcher")) + toStop += a6 + new TestStashingActor + }, "akka.actor.default-stash-dispatcher")) + + a5 ! 500 + toStop += a5 + } catch { + case e => 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) + } +}
\ No newline at end of file diff --git a/test/files/jvm/actmig-loop-react.scala b/test/files/jvm/actmig-loop-react.scala index 2b42dc630e..7f4c6f96dc 100644 --- a/test/files/jvm/actmig-loop-react.scala +++ b/test/files/jvm/actmig-loop-react.scala @@ -1,3 +1,7 @@ +/** + * 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.MigrationSystem._ import scala.actors.Actor._ import scala.actors._ diff --git a/test/files/jvm/actmig-public-methods.check b/test/files/jvm/actmig-public-methods.check index bb6530c926..c861c90e63 100644 --- a/test/files/jvm/actmig-public-methods.check +++ b/test/files/jvm/actmig-public-methods.check @@ -1,6 +1,6 @@ None Some(bang qmark after 1) bang +bang bang in the future after 0 bang qmark after 0 -bang qmark in future after 0 -typed bang qmark in future 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 new file mode 100644 index 0000000000..58d7a1a9d4 --- /dev/null +++ b/test/files/jvm/actmig-public-methods.scala @@ -0,0 +1,74 @@ +/** + * 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.MigrationSystem +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) + } +}
\ No newline at end of file diff --git a/test/files/jvm/actmig-public-methods_1.check b/test/files/jvm/actmig-public-methods_1.check index bb6530c926..c861c90e63 100644 --- a/test/files/jvm/actmig-public-methods_1.check +++ b/test/files/jvm/actmig-public-methods_1.check @@ -1,6 +1,6 @@ None Some(bang qmark after 1) bang +bang bang in the future after 0 bang qmark after 0 -bang qmark in future after 0 -typed bang qmark in future 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 index c28542e86e..15516a5d51 100644 --- a/test/files/jvm/actmig-public-methods_1.scala +++ b/test/files/jvm/actmig-public-methods_1.scala @@ -1,11 +1,18 @@ +/** + * 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.Duration +import scala.concurrent.duration._ import scala.actors.migration.pattern._ +import scala.concurrent.ExecutionContext.Implicits.global object Test { val NUMBER_OF_TESTS = 6 @@ -40,45 +47,53 @@ object Test { respActor ! "bang" - implicit val timeout = Timeout(Duration(500, TimeUnit.MILLISECONDS)) - val msg = ("bang qmark", 0L) - val res1 = respActor.?(msg)(Timeout(Duration.Inf)) - append(res1().toString) - latch.countDown() - - val msg1 = ("bang qmark", 1L) - val res2 = respActor.?(msg1)(Timeout(Duration(500, TimeUnit.MILLISECONDS))) - append((res2() match { - case x: AskTimeoutException => None - case v => Some(v) - }).toString) - latch.countDown() - - // this one should time out - val msg11 = ("bang qmark", 500L) - val res21 = respActor.?(msg11)(Timeout(Duration(1, TimeUnit.MILLISECONDS))) - append((res21() match { - case x: AskTimeoutException => None - case v => Some(v) - }).toString) - latch.countDown() - - val msg2 = ("bang qmark in future", 0L) - val fut1 = respActor.?(msg2)(Duration.Inf) - append(fut1().toString()) - latch.countDown() - - val handler: PartialFunction[Any, String] = { - case x: String => x.toString + { + val msg = ("bang qmark", 0L) + val res = respActor.?(msg)(Timeout(Duration.Inf)) + append(Await.result(res, Duration.Inf).toString) + latch.countDown() } - val msg3 = ("typed bang qmark in future", 0L) - val fut2 = (respActor.?(msg3)(Duration.Inf)) - append(Futures.future { handler.apply(fut2()) }().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(200, TimeUnit.MILLISECONDS) + latch.await(10, TimeUnit.SECONDS) if (latch.getCount() > 0) { println("Error: Tasks have not finished!!!") } diff --git a/test/files/jvm/actmig-react-receive.scala b/test/files/jvm/actmig-react-receive.scala index af36c2ac70..6adeac8b52 100644 --- a/test/files/jvm/actmig-react-receive.scala +++ b/test/files/jvm/actmig-react-receive.scala @@ -1,3 +1,7 @@ +/** + * 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.MigrationSystem._ import scala.actors.Actor._ import scala.actors._ diff --git a/test/files/jvm/actmig-react-within.scala b/test/files/jvm/actmig-react-within.scala index 594548381b..43350ef120 100644 --- a/test/files/jvm/actmig-react-within.scala +++ b/test/files/jvm/actmig-react-within.scala @@ -1,3 +1,7 @@ +/** + * 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.MigrationSystem._ import scala.actors.Actor._ import scala.actors._ diff --git a/test/files/jvm/actmig-receive.scala b/test/files/jvm/actmig-receive.scala index e6c5363c14..03dc1be63b 100644 --- a/test/files/jvm/actmig-receive.scala +++ b/test/files/jvm/actmig-receive.scala @@ -1,3 +1,7 @@ +/** + * 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.MigrationSystem._ import scala.actors.Actor._ import scala.actors._ diff --git a/test/files/run/Meter.scala b/test/files/run/Meter.scala index a0c04cc2a7..a10ad31b4a 100644 --- a/test/files/run/Meter.scala +++ b/test/files/run/Meter.scala @@ -1,4 +1,9 @@ package a { + abstract class BoxingConversions[Boxed, Unboxed] { + def box(x: Unboxed): Boxed + def unbox(x: Boxed): Unboxed + } + class Meter(val underlying: Double) extends AnyVal with _root_.b.Printable { def + (other: Meter): Meter = new Meter(this.underlying + other.underlying) diff --git a/test/files/run/MeterCaseClass.scala b/test/files/run/MeterCaseClass.scala index 18f8e23f89..39d95c2af5 100644 --- a/test/files/run/MeterCaseClass.scala +++ b/test/files/run/MeterCaseClass.scala @@ -1,4 +1,9 @@ package a { + abstract class BoxingConversions[Boxed, Unboxed] { + def box(x: Unboxed): Boxed + def unbox(x: Boxed): Unboxed + } + case class Meter(underlying: Double) extends AnyVal with _root_.b.Printable { def + (other: Meter): Meter = new Meter(this.underlying + other.underlying) diff --git a/test/files/run/constant-type.check b/test/files/run/constant-type.check new file mode 100644 index 0000000000..4eededb8ba --- /dev/null +++ b/test/files/run/constant-type.check @@ -0,0 +1,30 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> + +scala> :power +** Power User mode enabled - BEEP WHIR GYVE ** +** :phase has been set to 'typer'. ** +** scala.tools.nsc._ has been imported ** +** global._, definitions._ also imported ** +** Try :help, :vals, power.<tab> ** + +scala> val s = transformedType(StringClass.toType).asInstanceOf[Type] +s: $r.intp.global.Type = String + +scala> { println(exitingPhase(currentRun.erasurePhase)(ConstantType(Constant(s)))) } +Class[String](classOf[java.lang.String]) + +scala> { exitingPhase(currentRun.erasurePhase)(println(ConstantType(Constant(s)))) } +Class(classOf[java.lang.String]) + +scala> { ConstantType(Constant(s)); println(exitingPhase(currentRun.erasurePhase)(ConstantType(Constant(s)))); } +Class[String](classOf[java.lang.String]) + +scala> { ConstantType(Constant(s)); exitingPhase(currentRun.erasurePhase)(println(ConstantType(Constant(s)))); } +Class(classOf[java.lang.String]) + +scala> + +scala> diff --git a/test/files/run/constant-type.scala b/test/files/run/constant-type.scala new file mode 100644 index 0000000000..373746af4a --- /dev/null +++ b/test/files/run/constant-type.scala @@ -0,0 +1,17 @@ +import scala.tools.partest.ReplTest + +// see the commit message to understand what this stuff is about +// just a quick note: +// transformedType returns an erased version of the type +// as explained in the commit message, Type.erasure won't do for this test +// because it does some postprocessing to the result of transformedType +object Test extends ReplTest { + def code = """ +:power +val s = transformedType(StringClass.toType).asInstanceOf[Type] +{ println(exitingPhase(currentRun.erasurePhase)(ConstantType(Constant(s)))) } +{ exitingPhase(currentRun.erasurePhase)(println(ConstantType(Constant(s)))) } +{ ConstantType(Constant(s)); println(exitingPhase(currentRun.erasurePhase)(ConstantType(Constant(s)))); } +{ ConstantType(Constant(s)); exitingPhase(currentRun.erasurePhase)(println(ConstantType(Constant(s)))); } + """ +} diff --git a/test/files/run/existentials3-new.check b/test/files/run/existentials3-new.check index bb6fe1a5e3..00614b19db 100644 --- a/test/files/run/existentials3-new.check +++ b/test/files/run/existentials3-new.check @@ -3,8 +3,8 @@ Bar, t=TypeRef, s=type Bar Test.ToS, t=RefinedType, s=f3 Test.ToS, t=RefinedType, s=f4 Test.ToS, t=RefinedType, s=f5 -() => Test.ToS, t=TypeRef, s=class Function0 -() => Test.ToS, t=TypeRef, s=class Function0 +() => Test.ToS, t=TypeRef, s=trait Function0 +() => Test.ToS, t=TypeRef, s=trait Function0 $anon, t=TypeRef, s=type $anon $anon, t=TypeRef, s=type $anon List[java.lang.Object{type T1}#T1], t=TypeRef, s=class List @@ -15,8 +15,8 @@ Bar, t=TypeRef, s=type Bar Test.ToS, t=RefinedType, s=g3 Test.ToS, t=RefinedType, s=g4 Test.ToS, t=RefinedType, s=g5 -() => Test.ToS, t=TypeRef, s=class Function0 -() => Test.ToS, t=TypeRef, s=class Function0 +() => Test.ToS, t=TypeRef, s=trait Function0 +() => Test.ToS, t=TypeRef, s=trait Function0 $anon, t=TypeRef, s=type $anon $anon, t=TypeRef, s=type $anon List[java.lang.Object{type T1}#T1], t=TypeRef, s=class List diff --git a/test/files/run/reflection-java-annotations.scala b/test/files/run/reflection-java-annotations.scala index 0b16c0d103..2e3fed48ce 100644 --- a/test/files/run/reflection-java-annotations.scala +++ b/test/files/run/reflection-java-annotations.scala @@ -2,6 +2,6 @@ object Test extends App { import scala.reflect.runtime.universe._ val sym = typeOf[JavaAnnottee].typeSymbol sym.typeSignature - sym.getAnnotations foreach (_.javaArgs) - println(sym.getAnnotations) + sym.annotations foreach (_.javaArgs) + println(sym.annotations) }
\ No newline at end of file diff --git a/test/files/run/reflection-magicsymbols-invoke.check b/test/files/run/reflection-magicsymbols-invoke.check index 520dc2bfbe..f5258efeb7 100644 --- a/test/files/run/reflection-magicsymbols-invoke.check +++ b/test/files/run/reflection-magicsymbols-invoke.check @@ -90,7 +90,7 @@ method $asInstanceOf: [T0]()T0 method $isInstanceOf: [T0]()Boolean method ==: (x$1: Any)Boolean method ==: (x$1: AnyRef)Boolean -method apply: (i: <?>)T +method apply: (i: Int)T method asInstanceOf: [T0]=> T0 method clone: ()Array[T] method eq: (x$1: AnyRef)Boolean @@ -105,7 +105,7 @@ method notify: ()Unit method notifyAll: ()Unit method synchronized: [T0](x$1: T0)T0 method toString: ()java.lang.String -method update: (i: <?>, x: <?>)Unit +method update: (i: Int, x: T)Unit method wait: ()Unit method wait: (x$1: Long)Unit method wait: (x$1: Long, x$2: Int)Unit diff --git a/test/files/run/reflection-mem-glbs.scala b/test/files/run/reflection-mem-glbs.scala new file mode 100644 index 0000000000..3f29a914bc --- /dev/null +++ b/test/files/run/reflection-mem-glbs.scala @@ -0,0 +1,13 @@ +import scala.tools.partest.MemoryTest + +trait A { type T <: A } +trait B { type T <: B } + +object Test extends MemoryTest { + override def maxDelta = 10 + override def calcsPerIter = 50000 + override def calc() { + import scala.reflect.runtime.universe._ + glb(List(typeOf[A], typeOf[B])) + } +}
\ No newline at end of file diff --git a/test/files/run/reflection-mem-tags.scala b/test/files/run/reflection-mem-tags.scala new file mode 100644 index 0000000000..8815e7dcd8 --- /dev/null +++ b/test/files/run/reflection-mem-tags.scala @@ -0,0 +1,17 @@ +import scala.tools.partest.MemoryTest + +trait A { type T <: A } +trait B { type T <: B } + +object Test extends MemoryTest { + override def maxDelta = 10 + override def calcsPerIter = 100000 + override def calc() { + import scala.reflect.runtime.universe._ + def foo = { + class A { def x = 2; def y: A = new A } + weakTypeOf[A { def z: Int }] + } + foo + } +}
\ No newline at end of file diff --git a/test/files/run/reflection-mem-typecheck.scala b/test/files/run/reflection-mem-typecheck.scala new file mode 100644 index 0000000000..a312c2c893 --- /dev/null +++ b/test/files/run/reflection-mem-typecheck.scala @@ -0,0 +1,26 @@ +import scala.tools.partest.MemoryTest + +trait A { type T <: A } +trait B { type T <: B } + +object Test extends MemoryTest { + lazy val tb = { + import scala.reflect.runtime.universe._ + import scala.reflect.runtime.{currentMirror => cm} + import scala.tools.reflect.ToolBox + cm.mkToolBox() + } + + override def maxDelta = 10 + override def calcsPerIter = 8 + override def calc() { + var snippet = """ + trait A { type T <: A } + trait B { type T <: B } + def foo[T](x: List[T]) = x + foo(List(new A {}, new B {})) + """.trim + snippet = snippet + "\n" + (List.fill(50)(snippet.split("\n").last) mkString "\n") + tb.typeCheck(tb.parse(snippet)) + } +}
\ No newline at end of file diff --git a/test/files/run/reify_ann1a.scala b/test/files/run/reify_ann1a.scala index 88b4191195..c23048e463 100644 --- a/test/files/run/reify_ann1a.scala +++ b/test/files/run/reify_ann1a.scala @@ -21,7 +21,6 @@ object Test extends App { // test 2: import and typecheck val toolbox = cm.mkToolBox() val ttree = toolbox.typeCheck(tree) - ttree.foreach(sub => if (sub.hasSymbol) sub.symbol.typeSignature) println(ttree.toString) // test 3: import and compile diff --git a/test/files/run/reify_ann1b.scala b/test/files/run/reify_ann1b.scala index a8fb876023..29ce6021a2 100644 --- a/test/files/run/reify_ann1b.scala +++ b/test/files/run/reify_ann1b.scala @@ -21,7 +21,6 @@ object Test extends App { // test 2: import and typecheck val toolbox = cm.mkToolBox() val ttree = toolbox.typeCheck(tree) - ttree.foreach(sub => if (sub.hasSymbol) sub.symbol.typeSignature) println(ttree.toString) // test 3: import and compile diff --git a/test/files/run/reify_ann2a.scala b/test/files/run/reify_ann2a.scala index b7e5833584..53423e12c3 100644 --- a/test/files/run/reify_ann2a.scala +++ b/test/files/run/reify_ann2a.scala @@ -21,7 +21,6 @@ object Test extends App { // test 2: import and typecheck val toolbox = cm.mkToolBox() val ttree = toolbox.typeCheck(tree) - ttree.foreach(sub => if (sub.hasSymbol) sub.symbol.typeSignature) println(ttree.toString) // test 3: import and compile diff --git a/test/files/run/reify_ann3.scala b/test/files/run/reify_ann3.scala index 662d58aaf3..4162fa532f 100644 --- a/test/files/run/reify_ann3.scala +++ b/test/files/run/reify_ann3.scala @@ -15,7 +15,6 @@ object Test extends App { // test 2: import and typecheck val toolbox = cm.mkToolBox() val ttree = toolbox.typeCheck(tree) - ttree.foreach(sub => if (sub.hasSymbol) sub.symbol.typeSignature) println(ttree.toString) // test 3: import and compile diff --git a/test/files/run/reify_ann4.scala b/test/files/run/reify_ann4.scala index a85e5e3625..0aedb77b5e 100644 --- a/test/files/run/reify_ann4.scala +++ b/test/files/run/reify_ann4.scala @@ -19,7 +19,6 @@ object Test extends App { // test 2: import and typecheck val toolbox = cm.mkToolBox() val ttree = toolbox.typeCheck(tree) - ttree.foreach(sub => if (sub.hasSymbol) sub.symbol.typeSignature) println(ttree.toString) // test 3: import and compile diff --git a/test/files/run/reify_ann5.scala b/test/files/run/reify_ann5.scala index 877360180c..d27be3b6d5 100644 --- a/test/files/run/reify_ann5.scala +++ b/test/files/run/reify_ann5.scala @@ -16,7 +16,6 @@ object Test extends App { // test 2: import and typecheck val toolbox = cm.mkToolBox() val ttree = toolbox.typeCheck(tree) - ttree.foreach(sub => if (sub.hasSymbol) sub.symbol.typeSignature) println(ttree.toString) // test 3: import and compile diff --git a/test/files/run/t5423.scala b/test/files/run/t5423.scala index 9b8ba090fa..c1632126b2 100644 --- a/test/files/run/t5423.scala +++ b/test/files/run/t5423.scala @@ -7,5 +7,5 @@ final class table extends annotation.StaticAnnotation object Test extends App { val s = cm.classSymbol(classOf[A]) - println(s.getAnnotations) + println(s.annotations) }
\ No newline at end of file diff --git a/test/files/run/t6277.check b/test/files/run/t6277.check new file mode 100644 index 0000000000..f32a5804e2 --- /dev/null +++ b/test/files/run/t6277.check @@ -0,0 +1 @@ +true
\ No newline at end of file diff --git a/test/files/run/t6277.scala b/test/files/run/t6277.scala new file mode 100644 index 0000000000..41feee8a8a --- /dev/null +++ b/test/files/run/t6277.scala @@ -0,0 +1,9 @@ +import scala.reflect.runtime.universe._ + +object Test extends App { + locally { + val sym = typeOf[List[_]].typeSymbol.asClass + val q = sym.isSealed + println(q) + } +}
\ No newline at end of file diff --git a/test/files/run/t6344.check b/test/files/run/t6344.check new file mode 100644 index 0000000000..5ac04d0320 --- /dev/null +++ b/test/files/run/t6344.check @@ -0,0 +1,132 @@ +C0 +public int C0.v1(int) +public <A> int C0.v1(int) +public int C0.v3() +public <A> int C0.v3() +public int C0.v4(int,scala.collection.immutable.List) +public <A> int C0.v4(int,scala.collection.immutable.List<Val<A>>) +public scala.collection.immutable.List C0.v2() +public <A> scala.collection.immutable.List<Val<A>> C0.v2() + +C1 +public java.lang.Object C1.v1(java.lang.Object) +public <A> java.lang.Object C1.v1(java.lang.Object) +public java.lang.Object C1.v3() +public <A> java.lang.Object C1.v3() +public java.lang.Object C1.v4(java.lang.Object,scala.collection.immutable.List) +public <A> java.lang.Object C1.v4(java.lang.Object,scala.collection.immutable.List<java.lang.Object>) +public scala.collection.immutable.List C1.v2() +public <A> scala.collection.immutable.List<java.lang.Object> C1.v2() + +C2 +public java.lang.String C2.v1(java.lang.String) +public <A> java.lang.String C2.v1(java.lang.String) +public java.lang.String C2.v3() +public <A> java.lang.String C2.v3() +public java.lang.String C2.v4(java.lang.String,scala.collection.immutable.List) +public <A> java.lang.String C2.v4(java.lang.String,scala.collection.immutable.List<java.lang.String>) +public scala.collection.immutable.List C2.v2() +public <A> scala.collection.immutable.List<java.lang.String> C2.v2() + +C3 +public java.lang.Object C3.v1(java.lang.Object) +public A C3.v1(A) +public java.lang.Object C3.v3() +public A C3.v3() +public java.lang.Object C3.v4(java.lang.Object,scala.collection.immutable.List) +public A C3.v4(A,scala.collection.immutable.List<A>) +public java.lang.Object C3.x() +public A C3.x() +public scala.collection.immutable.List C3.v2() +public scala.collection.immutable.List<A> C3.v2() + +C4 +public java.lang.Integer C4.v1(java.lang.Integer) +public int C4.v1(int) +public java.lang.Integer C4.v3() +public int C4.v3() +public java.lang.Integer C4.v4(java.lang.Integer,scala.collection.immutable.List) +public int C4.v4(int,scala.collection.immutable.List<ValA<java.lang.Object>>) +public scala.collection.immutable.List C4.v2() +public scala.collection.immutable.List<ValA<java.lang.Object>> C4.v2() + +C4B +public java.lang.String C4B.v1(java.lang.String) +public java.lang.String C4B.v1(java.lang.String) +public java.lang.String C4B.v3() +public java.lang.String C4B.v3() +public java.lang.String C4B.v4(java.lang.String,scala.collection.immutable.List) +public java.lang.String C4B.v4(java.lang.String,scala.collection.immutable.List<java.lang.String>) +public scala.collection.immutable.List C4B.v2() +public scala.collection.immutable.List<java.lang.String> C4B.v2() + +C5 +public double C5.f2(int,java.lang.Object,java.lang.String,double) +public double C5.f2(int,java.lang.Object,java.lang.String,double) +public int C5.f3(java.lang.Integer) +public int C5.f3(int) +public int C5.f4(java.lang.Integer) +public int C5.f4(int) +public int C5.f5(java.lang.Integer) +public int C5.f5(int) +public java.lang.Object C5.f1(int,java.lang.Object,java.lang.String,java.lang.Object) +public <A> A C5.f1(int,java.lang.Object,java.lang.String,A) + +C6 +public java.lang.Object C6.f1(int,java.lang.Object,java.lang.String,java.lang.Object) +public A C6.f1(int,java.lang.Object,java.lang.String,A) + +C7 +public java.lang.Integer C7.f1(int,java.lang.Object,java.lang.String,java.lang.Integer) +public int C7.f1(int,java.lang.Object,java.lang.String,int) +public java.lang.Object C7.f1(int,java.lang.Object,java.lang.String,java.lang.Object) +public java.lang.Object C7.f1(int,java.lang.Object,java.lang.String,java.lang.Object) + +Gen +public abstract Gen Gen.plus(Gen,Gen) +public abstract Gen<A> Gen.plus(Gen<A>,Gen<A>) +public abstract java.lang.Object Gen.x() +public abstract A Gen.x() + +ValueInt +public Gen ValueInt.plus(Gen,Gen) +public Gen<java.lang.Object> ValueInt.plus(Gen<java.lang.Object>,Gen<java.lang.Object>) +public boolean ValueInt.equals(java.lang.Object) +public boolean ValueInt.equals(java.lang.Object) +public int ValueInt.hashCode() +public int ValueInt.hashCode() +public int ValueInt.iplus(int,int) +public int ValueInt.iplus(int,int) +public int ValueInt.x() +public int ValueInt.x() +public java.lang.Object ValueInt.x() +public java.lang.Object ValueInt.x() +public static Gen ValueInt.extension$plus(int,Gen,Gen) +public static Gen<java.lang.Object> ValueInt.extension$plus(int,Gen<java.lang.Object>,Gen<java.lang.Object>) +public static boolean ValueInt.extension$equals(int,java.lang.Object) +public static boolean ValueInt.extension$equals(int,java.lang.Object) +public static int ValueInt.extension$hashCode(int) +public static int ValueInt.extension$hashCode(int) +public static int ValueInt.extension$iplus(int,int,int) +public static int ValueInt.extension$iplus(int,int,int) + +RefInt +public Gen RefInt.plus(Gen,Gen) +public Gen<java.lang.Object> RefInt.plus(Gen<java.lang.Object>,Gen<java.lang.Object>) +public RefInt RefInt.rplus(RefInt,RefInt) +public RefInt RefInt.rplus(RefInt,RefInt) +public int RefInt.x() +public int RefInt.x() +public java.lang.Object RefInt.x() +public java.lang.Object RefInt.x() + +RefInteger +public Gen RefInteger.plus(Gen,Gen) +public Gen<java.lang.Integer> RefInteger.plus(Gen<java.lang.Integer>,Gen<java.lang.Integer>) +public RefInteger RefInteger.bplus(RefInteger,RefInteger) +public RefInteger RefInteger.bplus(RefInteger,RefInteger) +public java.lang.Integer RefInteger.x() +public java.lang.Integer RefInteger.x() +public java.lang.Object RefInteger.x() +public java.lang.Object RefInteger.x() + diff --git a/test/files/run/t6344.scala b/test/files/run/t6344.scala new file mode 100644 index 0000000000..6f82e4ba51 --- /dev/null +++ b/test/files/run/t6344.scala @@ -0,0 +1,106 @@ +import scala.reflect.{ClassTag, classTag} +import java.lang.Integer + +trait Gen[A] extends Any { + def x: A + def plus(x1: Gen[A], x2: Gen[A]): Gen[A] +} +class ValueInt(val x: Int) extends AnyVal with Gen[Int] { + // Gen<java.lang.Object> ValueInt.extension$plus(int,Gen<java.lang.Object>,Gen<java.lang.Object>) + def plus(x1: Gen[Int], x2: Gen[Int]): Gen[Int] = new ValueInt(x + x1.x + x2.x) + // int ValueInt.extension$iplus(int,int,int) + def iplus(x1: ValueInt, x2: ValueInt): ValueInt = new ValueInt(x + x1.x + x2.x) +} +class RefInt(val x: Int) extends AnyRef with Gen[Int] { + def plus(x1: Gen[Int], x2: Gen[Int]): Gen[Int] = new RefInt(x + x1.x + x2.x) + def rplus(x1: RefInt, x2: RefInt): RefInt = new RefInt(x + x1.x + x2.x) +} +class RefInteger(val x: java.lang.Integer) extends AnyRef with Gen[Integer] { + def plus(x1: Gen[Integer], x2: Gen[Integer]): Gen[Integer] = new RefInteger(x + x1.x + x2.x) + def bplus(x1: RefInteger, x2: RefInteger): RefInteger = new RefInteger(x + x1.x + x2.x) +} + +class Val[Q](val value: Int) extends AnyVal +class ValAny[Q](val value: Any) extends AnyVal +class ValStr[Q](val value: String) extends AnyVal +class ValA[Q](val value: Q) extends AnyVal { + def f: Q = ??? +} +class ValB[Q, Q0 <: Q](val value: Q) extends AnyVal { + def f: Q0 = ??? +} + +class C0 { + def v1[A](in: Val[A]) = in + def v2[A]: List[Val[A]] = Nil + def v3[A]: Val[A] = new Val[A](0) + def v4[A <: String](x: Val[A], ys: List[Val[A]]) = ys.head +} +class C1 { + def v1[A](in: ValAny[A]) = in + def v2[A]: List[ValAny[A]] = Nil + def v3[A]: ValAny[A] = new ValAny[A]("") + def v4[A <: String](x: ValAny[A], ys: List[ValAny[A]]) = ys.head +} +class C2 { + def v1[A](in: ValStr[A]) = in + def v2[A]: List[ValStr[A]] = Nil + def v3[A]: ValStr[A] = new ValStr[A]("") + def v4[A <: String](x: ValStr[A], ys: List[ValStr[A]]) = ys.head +} +class C3[A](val x: A) { + def v1(in: ValA[A]) = in + def v2: List[ValA[A]] = Nil + def v3: ValA[A] = new ValA[A](x) + def v4(x: ValA[A], ys: List[ValA[A]]) = ys.head +} +class C4 { + def v1(in: ValA[Int]) = in + def v2: List[ValA[Int]] = Nil + def v3: ValA[Int] = new ValA(1) + def v4(x: ValA[Int], ys: List[ValA[Int]]) = ys.head +} +class C4B { + def v1(in: ValA[String]) = in + def v2: List[ValA[String]] = Nil + def v3: ValA[String] = new ValA("") + def v4(x: ValA[String], ys: List[ValA[String]]) = ys.head +} +class C5 { + def f1[A](x1: Val[A], x2: ValAny[A], x3: ValStr[A], x4: ValA[A]) = x4 + def f2(x1: Int, x2: Any, x3: String, x4: Double) = x4 + def f3(x: ValA[Int]) = x.f + def f4(x: ValB[Int, Int]) = x.f + def f5(x: ValB[Int, _ <: Int]) = x.f +} +class C6[A] { + def f1(x1: Val[A], x2: ValAny[A], x3: ValStr[A], x4: ValA[A]) = x4 +} +class C7 extends C6[Int] { + override def f1(x1: Val[Int], x2: ValAny[Int], x3: ValStr[Int], x4: ValA[Int]) = + super.f1(x1, x2, x3, x4) +} + +object Test { + def show[A: ClassTag] = { + println(classTag[A].runtimeClass.getName) + classTag[A].runtimeClass.getDeclaredMethods.toList.sortBy(_.toString).flatMap(m => List(m.toString, m.toGenericString)) foreach println + println("") + } + + def main(args: Array[String]): Unit = { + show[C0] + show[C1] + show[C2] + show[C3[_]] + show[C4] + show[C4B] + show[C5] + show[C6[_]] + show[C7] + show[Gen[_]] + show[ValueInt] + show[RefInt] + show[RefInteger] + } +} diff --git a/test/files/run/t6410.check b/test/files/run/t6410.check new file mode 100644 index 0000000000..051fe4995a --- /dev/null +++ b/test/files/run/t6410.check @@ -0,0 +1,2 @@ +ParMap(0 -> 4, 1 -> 5) +ParMap(0 -> 4, 1 -> 5)
\ No newline at end of file diff --git a/test/files/run/t6410.scala b/test/files/run/t6410.scala new file mode 100644 index 0000000000..2a001b47ab --- /dev/null +++ b/test/files/run/t6410.scala @@ -0,0 +1,9 @@ + + + +object Test extends App { + val x = collection.parallel.mutable.ParArray.range(1,10) groupBy { _ % 2 } mapValues { _.size } + println(x) + val y = collection.parallel.immutable.ParVector.range(1,10) groupBy { _ % 2 } mapValues { _.size } + println(y) +}
\ No newline at end of file diff --git a/test/files/run/typetags_without_scala_reflect_manifest_lookup.scala b/test/files/run/typetags_without_scala_reflect_manifest_lookup.scala index 37047e7884..6fd3d2dc2b 100644 --- a/test/files/run/typetags_without_scala_reflect_manifest_lookup.scala +++ b/test/files/run/typetags_without_scala_reflect_manifest_lookup.scala @@ -2,7 +2,7 @@ import scala.tools.partest._ import scala.tools.nsc.Settings object Test extends DirectTest { - override def extraSettings = "-cp " + sys.props("partest.lib") + override def extraSettings = "-cp " + sys.props("partest.lib") + " -d \"" + testOutput.path + "\"" def code = """ object Test extends App { |