diff options
Diffstat (limited to 'test/files')
939 files changed, 12427 insertions, 3571 deletions
diff --git a/test/files/buildmanager/t2556_3/t2556_3.check b/test/files/buildmanager/t2556_3/t2556_3.check index 37808d2b31..34f90f7f9b 100644 --- a/test/files/buildmanager/t2556_3/t2556_3.check +++ b/test/files/buildmanager/t2556_3/t2556_3.check @@ -9,10 +9,10 @@ invalidate B.scala because it references invalid (no longer inherited) definitio compiling Set(B.scala, C.scala) B.scala:3: error: type mismatch; found : C - required: ?{val x: ?} + required: ?{def x: ?} Note that implicit conversions are not applicable because they are ambiguous: both method any2Ensuring in object Predef of type [A](x: A)Ensuring[A] and method any2ArrowAssoc in object Predef of type [A](x: A)ArrowAssoc[A] - are possible conversion functions from C to ?{val x: ?} + are possible conversion functions from C to ?{def x: ?} println( (new C).x ) ^ diff --git a/test/files/buildmanager/t2559/D.scala b/test/files/buildmanager/t2559/D.scala index 906b69a3e7..62dc5427f9 100644 --- a/test/files/buildmanager/t2559/D.scala +++ b/test/files/buildmanager/t2559/D.scala @@ -1,8 +1,4 @@ object D { - def x(a: A) = - a match { - case _: B => () - case _: C => () - } + def x(a: A) = if (a.isInstanceOf[B] || a.isInstanceOf[C]) () } diff --git a/test/files/buildmanager/t2559/t2559.check b/test/files/buildmanager/t2559/t2559.check index 752278fbe8..4d43838cf5 100644 --- a/test/files/buildmanager/t2559/t2559.check +++ b/test/files/buildmanager/t2559/t2559.check @@ -6,9 +6,4 @@ compiling Set(A.scala) Changes: Map(class B -> List(), class C -> List(), class E -> List(Changed(Class(A))[class E extends a sealed trait A]), trait A -> List()) invalidate D.scala because it references changed class [Changed(Class(A))[class E extends a sealed trait A]] compiling Set(D.scala) -D.scala:3: warning: match is not exhaustive! -missing combination E - - a match { - ^ Changes: Map(object D -> List()) diff --git a/test/files/buildmanager/t2650_1/t2650_1.check b/test/files/buildmanager/t2650_1/t2650_1.check index ecddb33620..f1e4b1b8bc 100644 --- a/test/files/buildmanager/t2650_1/t2650_1.check +++ b/test/files/buildmanager/t2650_1/t2650_1.check @@ -1,5 +1,6 @@ builder > A.scala B.scala compiling Set(A.scala, B.scala) +warning: there were 1 feature warnings; re-run with -feature for details Changes: Map() builder > A.scala compiling Set(A.scala) diff --git a/test/files/buildmanager/t2657/t2657.check b/test/files/buildmanager/t2657/t2657.check index 74ba87a21d..cd0357599c 100644 --- a/test/files/buildmanager/t2657/t2657.check +++ b/test/files/buildmanager/t2657/t2657.check @@ -1,5 +1,6 @@ builder > A.scala B.scala compiling Set(A.scala, B.scala) +warning: there were 1 feature warnings; re-run with -feature for details Changes: Map() builder > A.scala compiling Set(A.scala) diff --git a/test/files/buildmanager/t2792/t2792.check b/test/files/buildmanager/t2792/t2792.check index 68e14c6386..00a2b83469 100644 --- a/test/files/buildmanager/t2792/t2792.check +++ b/test/files/buildmanager/t2792/t2792.check @@ -9,3 +9,6 @@ compiling Set(A2.scala) A2.scala:2: error: stable identifier required, but A.x found. import A.x.y ^ +A2.scala:3: error: not found: value y + val z = y + ^ diff --git a/test/files/continuations-neg/t3718.check b/test/files/continuations-neg/t3718.check new file mode 100644 index 0000000000..659104c1c6 --- /dev/null +++ b/test/files/continuations-neg/t3718.check @@ -0,0 +1,4 @@ +t3718.scala:2: error: cannot cps-transform malformed (possibly in shift/reset placement) expression + scala.util.continuations.reset((_: Any).##) + ^ +one error found diff --git a/test/files/continuations-neg/t3718.scala b/test/files/continuations-neg/t3718.scala new file mode 100644 index 0000000000..a0fcb9d869 --- /dev/null +++ b/test/files/continuations-neg/t3718.scala @@ -0,0 +1,3 @@ +object Test { + scala.util.continuations.reset((_: Any).##) +} diff --git a/test/files/continuations-run/match2.scala b/test/files/continuations-run/match2.scala index 8b0fb946df..5092ce3abe 100644 --- a/test/files/continuations-run/match2.scala +++ b/test/files/continuations-run/match2.scala @@ -18,7 +18,7 @@ object Test { } - def main(args: Array[String]): Any = { + def main(args: Array[String]): Unit = { println(reset(test1())) println(reset(test2())) } diff --git a/test/files/continuations-run/t5472.check b/test/files/continuations-run/t5472.check new file mode 100644 index 0000000000..d42e80c18e --- /dev/null +++ b/test/files/continuations-run/t5472.check @@ -0,0 +1 @@ +List(23, 23) diff --git a/test/files/continuations-run/t5472.scala b/test/files/continuations-run/t5472.scala new file mode 100644 index 0000000000..3e3c76b32a --- /dev/null +++ b/test/files/continuations-run/t5472.scala @@ -0,0 +1,90 @@ +import scala.annotation._ +import scala.util.continuations._ +import java.util.concurrent.atomic._ + +object Test { + def main(args: Array[String]) { + val map = Map("foo" -> 1, "bar" -> 2) + reset { + val mapped = + for { + (location, accessors) <- new ContinuationizedParallelIterable(map) + } yield { + shiftUnit0[Int, Unit](23) + } + println(mapped.toList) + } + } +} + +final class ContinuationizedParallelIterable[+A](protected val underline: Iterable[A]) { + def toList = underline.toList.sortBy(_.toString) + + final def filter(p: A => Boolean @suspendable): ContinuationizedParallelIterable[A] @suspendable = + shift( + new AtomicInteger(1) with ((ContinuationizedParallelIterable[A] => Unit) => Unit) { + private val results = new AtomicReference[List[A]](Nil) + + @tailrec + private def add(element: A) { + val old = results.get + if (!results.compareAndSet(old, element :: old)) { + add(element) + } + } + + override final def apply(continue: ContinuationizedParallelIterable[A] => Unit) { + for (element <- underline) { + super.incrementAndGet() + reset { + val pass = p(element) + if (pass) { + add(element) + } + if (super.decrementAndGet() == 0) { + continue(new ContinuationizedParallelIterable(results.get)) + } + } + } + if (super.decrementAndGet() == 0) { + continue(new ContinuationizedParallelIterable(results.get)) + } + } + }) + + final def foreach[U](f: A => U @suspendable): Unit @suspendable = + shift( + new AtomicInteger(1) with ((Unit => Unit) => Unit) { + override final def apply(continue: Unit => Unit) { + for (element <- underline) { + super.incrementAndGet() + reset { + f(element) + if (super.decrementAndGet() == 0) { + continue() + } + } + } + if (super.decrementAndGet() == 0) { + continue() + } + } + }) + + final def map[B: Manifest](f: A => B @suspendable): ContinuationizedParallelIterable[B] @suspendable = + shift( + new AtomicInteger(underline.size) with ((ContinuationizedParallelIterable[B] => Unit) => Unit) { + override final def apply(continue: ContinuationizedParallelIterable[B] => Unit) { + val results = new Array[B](super.get) + for ((element, i) <- underline.view zipWithIndex) { + reset { + val result = f(element) + results(i) = result + if (super.decrementAndGet() == 0) { + continue(new ContinuationizedParallelIterable(results)) + } + } + } + } + }) +} diff --git a/test/files/jvm/annotations.scala b/test/files/jvm/annotations.scala index b1c3c8ba40..66ebde592b 100644 --- a/test/files/jvm/annotations.scala +++ b/test/files/jvm/annotations.scala @@ -193,7 +193,9 @@ object Test6 { val c = new C("bob") c.setText("dylan") println(c.getText()) - if (new D(true).isProp()) { + val d = new D(true) + d.setProp(false) + if (!d.isProp()) { println(new D(false).getM()) } } diff --git a/test/files/jvm/future-spec/FutureTests.scala b/test/files/jvm/future-spec/FutureTests.scala new file mode 100644 index 0000000000..e5e01a5954 --- /dev/null +++ b/test/files/jvm/future-spec/FutureTests.scala @@ -0,0 +1,511 @@ + + + +import scala.concurrent._ +import scala.concurrent.util.duration._ +import scala.concurrent.util.Duration.Inf +import scala.collection._ +import scala.runtime.NonLocalReturnControl + + + +object FutureTests extends MinimalScalaTest { + + /* some utils */ + + def testAsync(s: String): Future[String] = s match { + case "Hello" => future { "World" } + case "Failure" => Promise.failed(new RuntimeException("Expected exception; to test fault-tolerance")).future + case "NoReply" => Promise[String]().future + } + + val defaultTimeout = 5 seconds + + /* future specification */ + + "A future" should { + + "compose with for-comprehensions" in { + def async(x: Int) = future { (x * 2).toString } + val future0 = future[Any] { + "five!".length + } + + val future1 = for { + a <- future0.mapTo[Int] // returns 5 + b <- async(a) // returns "10" + c <- async(7) // returns "14" + } yield b + "-" + c + + val future2 = for { + a <- future0.mapTo[Int] + b <- (future { (a * 2).toString }).mapTo[Int] + c <- future { (7 * 2).toString } + } yield b + "-" + c + + Await.result(future1, defaultTimeout) mustBe ("10-14") + assert(checkType(future1, manifest[String])) + intercept[ClassCastException] { Await.result(future2, defaultTimeout) } + } + + "support pattern matching within a for-comprehension" in { + case class Req[T](req: T) + case class Res[T](res: T) + def async[T](req: Req[T]) = req match { + case Req(s: String) => future { Res(s.length) } + case Req(i: Int) => future { Res((i * 2).toString) } + } + + val future1 = for { + Res(a: Int) <- async(Req("Hello")) + Res(b: String) <- async(Req(a)) + Res(c: String) <- async(Req(7)) + } yield b + "-" + c + + val future2 = for { + Res(a: Int) <- async(Req("Hello")) + Res(b: Int) <- async(Req(a)) + Res(c: Int) <- async(Req(7)) + } yield b + "-" + c + + Await.result(future1, defaultTimeout) mustBe ("10-14") + intercept[NoSuchElementException] { Await.result(future2, defaultTimeout) } + } + + "recover from exceptions" in { + val future1 = Future(5) + val future2 = future1 map (_ / 0) + val future3 = future2 map (_.toString) + + val future4 = future1 recover { + case e: ArithmeticException => 0 + } map (_.toString) + + val future5 = future2 recover { + case e: ArithmeticException => 0 + } map (_.toString) + + val future6 = future2 recover { + case e: MatchError => 0 + } map (_.toString) + + val future7 = future3 recover { + case e: ArithmeticException => "You got ERROR" + } + + val future8 = testAsync("Failure") + val future9 = testAsync("Failure") recover { + case e: RuntimeException => "FAIL!" + } + val future10 = testAsync("Hello") recover { + case e: RuntimeException => "FAIL!" + } + val future11 = testAsync("Failure") recover { + case _ => "Oops!" + } + + Await.result(future1, defaultTimeout) mustBe (5) + intercept[ArithmeticException] { Await.result(future2, defaultTimeout) } + intercept[ArithmeticException] { Await.result(future3, defaultTimeout) } + Await.result(future4, defaultTimeout) mustBe ("5") + Await.result(future5, defaultTimeout) mustBe ("0") + intercept[ArithmeticException] { Await.result(future6, defaultTimeout) } + Await.result(future7, defaultTimeout) mustBe ("You got ERROR") + intercept[RuntimeException] { Await.result(future8, defaultTimeout) } + Await.result(future9, defaultTimeout) mustBe ("FAIL!") + Await.result(future10, defaultTimeout) mustBe ("World") + Await.result(future11, defaultTimeout) mustBe ("Oops!") + } + + "recoverWith from exceptions" in { + val o = new IllegalStateException("original") + val r = new IllegalStateException("recovered") + + intercept[IllegalStateException] { + val failed = Promise.failed[String](o).future recoverWith { + case _ if false == true => Promise.successful("yay!").future + } + Await.result(failed, defaultTimeout) + } mustBe (o) + + val recovered = Promise.failed[String](o).future recoverWith { + case _ => Promise.successful("yay!").future + } + Await.result(recovered, defaultTimeout) mustBe ("yay!") + + intercept[IllegalStateException] { + val refailed = Promise.failed[String](o).future recoverWith { + case _ => Promise.failed[String](r).future + } + Await.result(refailed, defaultTimeout) + } mustBe (r) + } + + "andThen like a boss" in { + val q = new java.util.concurrent.LinkedBlockingQueue[Int] + for (i <- 1 to 1000) { + val chained = future { + q.add(1); 3 + } andThen { + case _ => q.add(2) + } andThen { + case Right(0) => q.add(Int.MaxValue) + } andThen { + case _ => q.add(3); + } + Await.result(chained, defaultTimeout) mustBe (3) + q.poll() mustBe (1) + q.poll() mustBe (2) + q.poll() mustBe (3) + q.clear() + } + } + + "firstCompletedOf" in { + def futures = Vector.fill[Future[Int]](10) { + Promise[Int]().future + } :+ Promise.successful[Int](5).future + + Await.result(Future.firstCompletedOf(futures), defaultTimeout) mustBe (5) + Await.result(Future.firstCompletedOf(futures.iterator), defaultTimeout) mustBe (5) + } + + "find" in { + val futures = for (i <- 1 to 10) yield future { + i + } + + val result = Future.find[Int](futures)(_ == 3) + Await.result(result, defaultTimeout) mustBe (Some(3)) + + val notFound = Future.find[Int](futures.iterator)(_ == 11) + Await.result(notFound, defaultTimeout) mustBe (None) + } + + "zip" in { + val timeout = 10000 millis + val f = new IllegalStateException("test") + intercept[IllegalStateException] { + val failed = Promise.failed[String](f).future zip Promise.successful("foo").future + Await.result(failed, timeout) + } mustBe (f) + + intercept[IllegalStateException] { + val failed = Promise.successful("foo").future zip Promise.failed[String](f).future + Await.result(failed, timeout) + } mustBe (f) + + intercept[IllegalStateException] { + val failed = Promise.failed[String](f).future zip Promise.failed[String](f).future + Await.result(failed, timeout) + } mustBe (f) + + val successful = Promise.successful("foo").future zip Promise.successful("foo").future + Await.result(successful, timeout) mustBe (("foo", "foo")) + } + + "fold" in { + val timeout = 10000 millis + def async(add: Int, wait: Int) = future { + Thread.sleep(wait) + add + } + + val futures = (0 to 9) map { + idx => async(idx, idx * 200) + } + val folded = Future.fold(futures)(0)(_ + _) + Await.result(folded, timeout) mustBe (45) + + val futuresit = (0 to 9) map { + idx => async(idx, idx * 200) + } + val foldedit = Future.fold(futures)(0)(_ + _) + Await.result(foldedit, timeout) mustBe (45) + } + + "fold by composing" in { + val timeout = 10000 millis + def async(add: Int, wait: Int) = future { + Thread.sleep(wait) + add + } + def futures = (0 to 9) map { + idx => async(idx, idx * 200) + } + val folded = futures.foldLeft(Future(0)) { + case (fr, fa) => for (r <- fr; a <- fa) yield (r + a) + } + Await.result(folded, timeout) mustBe (45) + } + + "fold with an exception" in { + val timeout = 10000 millis + def async(add: Int, wait: Int) = future { + Thread.sleep(wait) + if (add == 6) throw new IllegalArgumentException("shouldFoldResultsWithException: expected") + add + } + def futures = (0 to 9) map { + idx => async(idx, idx * 100) + } + val folded = Future.fold(futures)(0)(_ + _) + intercept[IllegalArgumentException] { + Await.result(folded, timeout) + }.getMessage mustBe ("shouldFoldResultsWithException: expected") + } + + "fold mutable zeroes safely" in { + import scala.collection.mutable.ArrayBuffer + def test(testNumber: Int) { + val fs = (0 to 1000) map (i => Future(i)) + val f = Future.fold(fs)(ArrayBuffer.empty[AnyRef]) { + case (l, i) if i % 2 == 0 => l += i.asInstanceOf[AnyRef] + case (l, _) => l + } + val result = Await.result(f.mapTo[ArrayBuffer[Int]], 10000 millis).sum + + assert(result == 250500) + } + + (1 to 100) foreach test //Make sure it tries to provoke the problem + } + + "return zero value if folding empty list" in { + val zero = Future.fold(List[Future[Int]]())(0)(_ + _) + Await.result(zero, defaultTimeout) mustBe (0) + } + + "shouldReduceResults" in { + def async(idx: Int) = future { + Thread.sleep(idx * 200) + idx + } + val timeout = 10000 millis + + val futures = (0 to 9) map { async } + val reduced = Future.reduce(futures)(_ + _) + Await.result(reduced, timeout) mustBe (45) + + val futuresit = (0 to 9) map { async } + val reducedit = Future.reduce(futuresit)(_ + _) + Await.result(reducedit, timeout) mustBe (45) + } + + "shouldReduceResultsWithException" in { + def async(add: Int, wait: Int) = future { + Thread.sleep(wait) + if (add == 6) throw new IllegalArgumentException("shouldFoldResultsWithException: expected") + else add + } + val timeout = 10000 millis + def futures = (1 to 10) map { + idx => async(idx, idx * 100) + } + val failed = Future.reduce(futures)(_ + _) + intercept[IllegalArgumentException] { + Await.result(failed, timeout) + }.getMessage mustBe ("shouldFoldResultsWithException: expected") + } + + "shouldReduceThrowNSEEOnEmptyInput" in { + intercept[java.util.NoSuchElementException] { + val emptyreduced = Future.reduce(List[Future[Int]]())(_ + _) + Await.result(emptyreduced, defaultTimeout) + } + } + + "shouldTraverseFutures" in { + object counter { + var count = -1 + def incAndGet() = counter.synchronized { + count += 2 + count + } + } + + val oddFutures = List.fill(100)(future { counter.incAndGet() }).iterator + val traversed = Future.sequence(oddFutures) + Await.result(traversed, defaultTimeout).sum mustBe (10000) + + val list = (1 to 100).toList + val traversedList = Future.traverse(list)(x => Future(x * 2 - 1)) + Await.result(traversedList, defaultTimeout).sum mustBe (10000) + + val iterator = (1 to 100).toList.iterator + val traversedIterator = Future.traverse(iterator)(x => Future(x * 2 - 1)) + Await.result(traversedIterator, defaultTimeout).sum mustBe (10000) + } + + "shouldHandleThrowables" in { + val ms = new mutable.HashSet[Throwable] with mutable.SynchronizedSet[Throwable] + implicit val ec = scala.concurrent.ExecutionContext.fromExecutor(new scala.concurrent.forkjoin.ForkJoinPool(), { + t => + ms += t + }) + + class ThrowableTest(m: String) extends Throwable(m) + + val f1 = future[Any] { + throw new ThrowableTest("test") + } + + intercept[ThrowableTest] { + Await.result(f1, defaultTimeout) + } + + val latch = new TestLatch + val f2 = future { + Await.ready(latch, 5 seconds) + "success" + } + val f3 = f2 map { s => s.toUpperCase } + + f2 foreach { _ => throw new ThrowableTest("dispatcher foreach") } + f2 onSuccess { case _ => throw new ThrowableTest("dispatcher receive") } + + latch.open() + + Await.result(f2, defaultTimeout) mustBe ("success") + + f2 foreach { _ => throw new ThrowableTest("current thread foreach") } + f2 onSuccess { case _ => throw new ThrowableTest("current thread receive") } + + Await.result(f3, defaultTimeout) mustBe ("SUCCESS") + + val waiting = future { + Thread.sleep(1000) + } + Await.ready(waiting, 2000 millis) + + ms.size mustBe (4) + } + + "shouldBlockUntilResult" in { + val latch = new TestLatch + + val f = future { + Await.ready(latch, 5 seconds) + 5 + } + val f2 = future { + val res = Await.result(f, Inf) + res + 9 + } + + intercept[TimeoutException] { + Await.ready(f2, 100 millis) + } + + latch.open() + + Await.result(f2, defaultTimeout) mustBe (14) + + val f3 = future { + Thread.sleep(100) + 5 + } + + intercept[TimeoutException] { + Await.ready(f3, 0 millis) + } + } + + "run callbacks async" in { + val latch = Vector.fill(10)(new TestLatch) + + val f1 = future { + latch(0).open() + Await.ready(latch(1), TestLatch.DefaultTimeout) + "Hello" + } + val f2 = f1 map { + s => + latch(2).open() + Await.ready(latch(3), TestLatch.DefaultTimeout) + s.length + } + for (_ <- f2) latch(4).open() + + Await.ready(latch(0), TestLatch.DefaultTimeout) + + f1.isCompleted mustBe (false) + f2.isCompleted mustBe (false) + + latch(1).open() + Await.ready(latch(2), TestLatch.DefaultTimeout) + + f1.isCompleted mustBe (true) + f2.isCompleted mustBe (false) + + val f3 = f1 map { + s => + latch(5).open() + Await.ready(latch(6), TestLatch.DefaultTimeout) + s.length * 2 + } + for (_ <- f3) latch(3).open() + + Await.ready(latch(5), TestLatch.DefaultTimeout) + + f3.isCompleted mustBe (false) + + latch(6).open() + Await.ready(latch(4), TestLatch.DefaultTimeout) + + f2.isCompleted mustBe (true) + f3.isCompleted mustBe (true) + + val p1 = Promise[String]() + val f4 = p1.future map { + s => + latch(7).open() + Await.ready(latch(8), TestLatch.DefaultTimeout) + s.length + } + for (_ <- f4) latch(9).open() + + p1.future.isCompleted mustBe (false) + f4.isCompleted mustBe (false) + + p1 complete Right("Hello") + + Await.ready(latch(7), TestLatch.DefaultTimeout) + + p1.future.isCompleted mustBe (true) + f4.isCompleted mustBe (false) + + latch(8).open() + Await.ready(latch(9), TestLatch.DefaultTimeout) + + Await.ready(f4, defaultTimeout).isCompleted mustBe (true) + } + + "should not deadlock with nested await (ticket 1313)" in { + val simple = Future() map { + _ => + val unit = Future(()) + val umap = unit map { _ => () } + Await.result(umap, Inf) + } + Await.ready(simple, Inf).isCompleted mustBe (true) + + val l1, l2 = new TestLatch + val complex = Future() map { + _ => + blocking { + val nested = Future(()) + for (_ <- nested) l1.open() + Await.ready(l1, TestLatch.DefaultTimeout) // make sure nested is completed + for (_ <- nested) l2.open() + Await.ready(l2, TestLatch.DefaultTimeout) + } + } + Await.ready(complex, defaultTimeout).isCompleted mustBe (true) + } + + } + +} + + diff --git a/test/files/jvm/future-spec/PromiseTests.scala b/test/files/jvm/future-spec/PromiseTests.scala new file mode 100644 index 0000000000..bf9d9b39d7 --- /dev/null +++ b/test/files/jvm/future-spec/PromiseTests.scala @@ -0,0 +1,244 @@ + + + +import scala.concurrent._ +import scala.concurrent.util.duration._ +import scala.concurrent.util.Duration.Inf +import scala.collection._ +import scala.runtime.NonLocalReturnControl + + + +object PromiseTests extends MinimalScalaTest { + + val defaultTimeout = Inf + + /* promise specification */ + + "An empty Promise" should { + + "not be completed" in { + val p = Promise() + p.future.isCompleted mustBe (false) + } + + "have no value" in { + val p = Promise() + p.future.value mustBe (None) + } + + "return supplied value on timeout" in { + val failure = Promise.failed[String](new RuntimeException("br0ken")).future + val otherFailure = Promise.failed[String](new RuntimeException("last")).future + val empty = Promise[String]().future + val timedOut = Promise.successful[String]("Timedout").future + + Await.result(failure fallbackTo timedOut, defaultTimeout) mustBe ("Timedout") + Await.result(timedOut fallbackTo empty, defaultTimeout) mustBe ("Timedout") + Await.result(failure fallbackTo failure fallbackTo timedOut, defaultTimeout) mustBe ("Timedout") + intercept[RuntimeException] { + Await.result(failure fallbackTo otherFailure, defaultTimeout) + }.getMessage mustBe ("last") + } + + } + + "A successful Promise" should { + val result = "test value" + val future = Promise[String]().complete(Right(result)).future + futureWithResult(_(future, result)) + } + + "A failed Promise" should { + val message = "Expected Exception" + val future = Promise[String]().complete(Left(new RuntimeException(message))).future + futureWithException[RuntimeException](_(future, message)) + } + + "An interrupted Promise" should { + val message = "Boxed InterruptedException" + val future = Promise[String]().complete(Left(new InterruptedException(message))).future + futureWithException[ExecutionException](_(future, message)) + } + + "A NonLocalReturnControl failed Promise" should { + val result = "test value" + val future = Promise[String]().complete(Left(new NonLocalReturnControl[String]("test", result))).future + futureWithResult(_(future, result)) + } + + def futureWithResult(f: ((Future[Any], Any) => Unit) => Unit) { + + "be completed" in { f((future, _) => future.isCompleted mustBe (true)) } + + "contain a value" in { f((future, result) => future.value mustBe (Some(Right(result)))) } + + "return result with 'blocking'" in { f((future, result) => blocking(future, defaultTimeout) mustBe (result)) } + + "return result with 'Await.result'" in { f((future, result) => Await.result(future, defaultTimeout) mustBe (result)) } + + "not timeout" in { f((future, _) => Await.ready(future, 0 millis)) } + + "filter result" in { + f { + (future, result) => + Await.result((future filter (_ => true)), defaultTimeout) mustBe (result) + intercept[NoSuchElementException] { + Await.result((future filter (_ => false)), defaultTimeout) + } + } + } + + "transform result with map" in { f((future, result) => Await.result((future map (_.toString.length)), defaultTimeout) mustBe (result.toString.length)) } + + "compose result with flatMap" in { + f { (future, result) => + val r = for (r <- future; p <- Promise.successful("foo").future) yield r.toString + p + Await.result(r, defaultTimeout) mustBe (result.toString + "foo") + } + } + + "perform action with foreach" in { + f { + (future, result) => + val p = Promise[Any]() + future foreach p.success + Await.result(p.future, defaultTimeout) mustBe (result) + } + } + + "zip properly" in { + f { + (future, result) => + Await.result(future zip Promise.successful("foo").future, defaultTimeout) mustBe ((result, "foo")) + intercept[RuntimeException] { + Await.result(future zip Promise.failed(new RuntimeException("ohnoes")).future, defaultTimeout) + }.getMessage mustBe ("ohnoes") + } + } + + "not recover from exception" in { f((future, result) => Await.result(future.recover({ case _ => "pigdog" }), defaultTimeout) mustBe (result)) } + + "perform action on result" in { + f { + (future, result) => + val p = Promise[Any]() + future.onSuccess { case x => p.success(x) } + Await.result(p.future, defaultTimeout) mustBe (result) + } + } + + "not project a failure" in { + f { + (future, result) => + intercept[NoSuchElementException] { + Await.result(future.failed, defaultTimeout) + }.getMessage mustBe ("Future.failed not completed with a throwable.") + } + } + + "cast using mapTo" in { + f { + (future, result) => + Await.result(future.mapTo[Boolean].recover({ case _: ClassCastException ⇒ false }), defaultTimeout) mustBe (false) + } + } + + } + + def futureWithException[E <: Throwable: Manifest](f: ((Future[Any], String) => Unit) => Unit) { + + "be completed" in { + f((future, _) => future.isCompleted mustBe (true)) + } + + "contain a value" in { + f((future, message) => { + future.value.get.left.get.getMessage mustBe (message) + }) + } + + "throw exception with 'blocking'" in { + f { + (future, message) => + intercept[E] { + blocking(future, defaultTimeout) + }.getMessage mustBe (message) + } + } + + "throw exception with 'Await.result'" in { + f { + (future, message) => + intercept[E] { + Await.result(future, defaultTimeout) + }.getMessage mustBe (message) + } + } + + "retain exception with filter" in { + f { + (future, message) => + intercept[E] { Await.result(future filter (_ => true), defaultTimeout) }.getMessage mustBe (message) + intercept[E] { Await.result(future filter (_ => false), defaultTimeout) }.getMessage mustBe (message) + } + } + + "retain exception with map" in { + f { + (future, message) => + intercept[E] { Await.result(future map (_.toString.length), defaultTimeout) }.getMessage mustBe (message) + } + } + + "retain exception with flatMap" in { + f { + (future, message) => + intercept[E] { Await.result(future flatMap (_ => Promise.successful("foo").future), defaultTimeout) }.getMessage mustBe (message) + } + } + + "zip properly" in { + f { + (future, message) => + intercept[E] { + Await.result(future zip Promise.successful("foo").future, defaultTimeout) + }.getMessage mustBe (message) + } + } + + "recover from exception" in { + f { + (future, message) => + Await.result(future.recover({ case e if e.getMessage == message ⇒ "pigdog" }), defaultTimeout) mustBe ("pigdog") + } + } + + "project a failure" in { + f((future, message) => Await.result(future.failed, defaultTimeout).getMessage mustBe (message)) + } + + "perform action on exception" in { + f { + (future, message) => + val p = Promise[Any]() + future.onFailure { case _ => p.success(message) } + Await.result(p.future, defaultTimeout) mustBe (message) + } + } + + "always cast successfully using mapTo" in { + f { + (future, message) => + intercept[E] { Await.result(future.mapTo[java.lang.Thread], defaultTimeout) }.getMessage mustBe (message) + } + } + } +} + + + + + + + diff --git a/test/files/jvm/future-spec/main.scala b/test/files/jvm/future-spec/main.scala new file mode 100644 index 0000000000..45b59d5d20 --- /dev/null +++ b/test/files/jvm/future-spec/main.scala @@ -0,0 +1,108 @@ + + + +import scala.collection._ +import scala.concurrent._ +import scala.concurrent.util.Duration +import java.util.concurrent.{ TimeoutException, CountDownLatch, TimeUnit } + + +object Test { + + def main(args: Array[String]) { + FutureTests.check() + PromiseTests.check() + } + +} + + +trait Output { + val buffer = new StringBuilder + + def bufferPrintln(a: Any) = buffer.synchronized { + buffer.append(a.toString + "\n") + } +} + + +trait MinimalScalaTest extends Output { + + val throwables = mutable.ArrayBuffer[Throwable]() + + def check() { + if (throwables.nonEmpty) println(buffer.toString) + } + + implicit def stringops(s: String) = new { + + def should[U](snippets: =>U) = { + bufferPrintln(s + " should:") + snippets + } + + def in[U](snippet: =>U) = { + try { + bufferPrintln("- " + s) + snippet + bufferPrintln("[OK] Test passed.") + } catch { + case e => + bufferPrintln("[FAILED] " + e) + bufferPrintln(e.getStackTrace().mkString("\n")) + throwables += e + } + } + + } + + implicit def objectops(obj: Any) = new { + + def mustBe(other: Any) = assert(obj == other, obj + " is not " + other) + + } + + def intercept[T <: Throwable: Manifest](body: =>Any): T = { + try { + body + throw new Exception("Exception of type %s was not thrown".format(manifest[T])) + } catch { + case t: Throwable => + if (manifest[T].erasure != t.getClass) throw t + else t.asInstanceOf[T] + } + } + + def checkType[T: Manifest, S](in: Future[T], refmanifest: Manifest[S]): Boolean = manifest[T] == refmanifest +} + + +object TestLatch { + val DefaultTimeout = Duration(5, TimeUnit.SECONDS) + + def apply(count: Int = 1) = new TestLatch(count) +} + + +class TestLatch(count: Int = 1) extends Awaitable[Unit] { + private var latch = new CountDownLatch(count) + + def countDown() = latch.countDown() + def isOpen: Boolean = latch.getCount == 0 + def open() = while (!isOpen) countDown() + def reset() = latch = new CountDownLatch(count) + + @throws(classOf[TimeoutException]) + def ready(atMost: Duration)(implicit permit: CanAwait) = { + val opened = latch.await(atMost.toNanos, TimeUnit.NANOSECONDS) + if (!opened) throw new TimeoutException("Timeout of %s." format (atMost.toString)) + this + } + + @throws(classOf[Exception]) + def result(atMost: Duration)(implicit permit: CanAwait): Unit = { + ready(atMost) + } + +} + diff --git a/test/files/jvm/interpreter.check b/test/files/jvm/interpreter.check index d93e314d8e..dc835bf8b6 100755..100644 --- a/test/files/jvm/interpreter.check +++ b/test/files/jvm/interpreter.check @@ -97,6 +97,7 @@ scala> case class Bar(n: Int) defined class Bar
scala> implicit def foo2bar(foo: Foo) = Bar(foo.n)
+warning: there were 1 feature warnings; re-run with -feature for details
foo2bar: (foo: Foo)Bar
scala> val bar: Bar = Foo(3)
@@ -267,9 +268,11 @@ scala> xs map (_ => "abc") res5: Array[String] = Array(abc, abc)
scala> xs map (x => x)
-res6: scala.collection.mutable.ArraySeq[_] = ArraySeq(1, 2)
+res6: Array[_] = Array(1, 2)
scala> xs map (x => (x, x))
+warning: there were 1 feature warnings; re-run with -feature for details
+warning: there were 1 feature warnings; re-run with -feature for details
res7: Array[(_$1, _$1)] forSome { type _$1 } = Array((1,1), (2,2))
scala>
@@ -313,9 +316,8 @@ scala> /* */
*/
-scala>
-scala>
+You typed two blank lines. Starting a new command.
scala> // multi-line string
@@ -323,7 +325,7 @@ scala> """ hello
there
"""
-res9: String =
+res12: String =
"
hello
there
diff --git a/test/files/jvm/interpreter.scala b/test/files/jvm/interpreter.scala index 1f289d9335..f45eb034a9 100644 --- a/test/files/jvm/interpreter.scala +++ b/test/files/jvm/interpreter.scala @@ -2,7 +2,7 @@ import scala.tools.nsc._ import scala.tools.partest.ReplTest object Test extends ReplTest { - override def extraSettings = "-deprecation" + override def extraSettings = "-deprecation -Xoldpatmat" def code = <code> // basics 3+4 @@ -147,7 +147,7 @@ def f(e: Exp) = e match {{ // non-exhaustive warning here def appendix() = { val settings = new Settings settings.classpath.value = sys.props("java.class.path") - val interp = new Interpreter(settings) + val interp = new interpreter.IMain(settings) interp.interpret("def plusOne(x: Int) = x + 1") interp.interpret("plusOne(5)") interp.reset() diff --git a/test/files/jvm/manifests-new.check b/test/files/jvm/manifests-new.check new file mode 100644 index 0000000000..896a5c1cef --- /dev/null +++ b/test/files/jvm/manifests-new.check @@ -0,0 +1,58 @@ +x=(), t=ConcreteTypeTag[Unit], k=TypeRef, s=class Unit +x=true, t=ConcreteTypeTag[Boolean], k=TypeRef, s=class Boolean +x=a, t=ConcreteTypeTag[Char], k=TypeRef, s=class Char +x=1, t=ConcreteTypeTag[Int], k=TypeRef, s=class Int +x=abc, t=ConcreteTypeTag[String], k=TypeRef, s=class String +x='abc, t=ConcreteTypeTag[Symbol], k=TypeRef, s=class Symbol + +x=List(()), t=ConcreteTypeTag[List[Unit]], k=TypeRef, s=class List +x=List(true), t=ConcreteTypeTag[List[Boolean]], k=TypeRef, s=class List +x=List(1), t=ConcreteTypeTag[List[Int]], k=TypeRef, s=class List +x=List(abc), t=ConcreteTypeTag[List[String]], k=TypeRef, s=class List +x=List('abc), t=ConcreteTypeTag[List[Symbol]], k=TypeRef, s=class List + +x=[Z, t=ConcreteTypeTag[Array[Boolean]], k=TypeRef, s=class Array +x=[C, t=ConcreteTypeTag[Array[Char]], k=TypeRef, s=class Array +x=[I, t=ConcreteTypeTag[Array[Int]], k=TypeRef, s=class Array +x=[Ljava.lang.String;, t=ConcreteTypeTag[Array[String]], k=TypeRef, s=class Array +x=[Lscala.Symbol;, t=ConcreteTypeTag[Array[Symbol]], k=TypeRef, s=class Array + +x=((),()), t=ConcreteTypeTag[(Unit, Unit)], k=TypeRef, s=class Tuple2 +x=(true,false), t=ConcreteTypeTag[(Boolean, Boolean)], k=TypeRef, s=class Tuple2 +x=(1,2), t=ConcreteTypeTag[(Int, Int)], k=TypeRef, s=class Tuple2 +x=(abc,xyz), t=ConcreteTypeTag[(String, String)], k=TypeRef, s=class Tuple2 +x=('abc,'xyz), t=ConcreteTypeTag[(Symbol, Symbol)], k=TypeRef, s=class Tuple2 + +x=Test$, t=ConcreteTypeTag[Test.type], k=SingleType, s=object Test +x=scala.collection.immutable.List$, t=ConcreteTypeTag[scala.collection.immutable.List.type], k=SingleType, s=object List + +x=Foo, t=ConcreteTypeTag[Foo[Int]], k=TypeRef, s=class Foo +x=Foo, t=ConcreteTypeTag[Foo[List[Int]]], k=TypeRef, s=class Foo +x=Foo, t=ConcreteTypeTag[Foo[Foo[Int]]], k=TypeRef, s=class Foo +x=Foo, t=ConcreteTypeTag[Foo[List[Foo[Int]]]], k=TypeRef, s=class Foo + +x=Test1$$anon$1, t=ConcreteTypeTag[Bar[String]], k=RefinedType, s=<local Test1> +x=Test1$$anon$2, t=ConcreteTypeTag[Bar[String]], k=RefinedType, s=<local Test1> + +()=() +true=true +a=a +1=1 +'abc='abc + +List(())=List(()) +List(true)=List(true) +List('abc)=List('abc) + +Array()=Array() +Array(true)=Array(true) +Array(a)=Array(a) +Array(1)=Array(1) + +((),())=((),()) +(true,false)=(true,false) + +List(List(1), List(2))=List(List(1), List(2)) + +Array(Array(1), Array(2))=Array(Array(1), Array(2)) + diff --git a/test/files/jvm/manifests-new.scala b/test/files/jvm/manifests-new.scala new file mode 100644 index 0000000000..d02f6ee608 --- /dev/null +++ b/test/files/jvm/manifests-new.scala @@ -0,0 +1,109 @@ +object Test extends App { + Test1 + Test2 +} + +class Foo[T](x: T) +trait Bar[T] { def f: T } + +object Test1 extends TestUtil { + print(()) + print(true) + print('a') + print(1) + print("abc") + print('abc) + println() + + print(List(())) + print(List(true)) + print(List(1)) + print(List("abc")) + print(List('abc)) + println() + + //print(Array(())) //Illegal class name "[V" in class file Test$ + print(Array(true)) + print(Array('a')) + print(Array(1)) + print(Array("abc")) + print(Array('abc)) + println() + + print(((), ())) + print((true, false)) + print((1, 2)) + print(("abc", "xyz")) + print(('abc, 'xyz)) + println() + + print(Test) + print(List) + println() + + print(new Foo(2)) + print(new Foo(List(2))) + print(new Foo(new Foo(2))) + print(new Foo(List(new Foo(2)))) + println() + + print(new Bar[String] { def f = "abc" }); + {print(new Bar[String] { def f = "abc" })} + println() +} + +object Test2 { + import scala.util.Marshal._ + println("()="+load[Unit](dump(()))) + println("true="+load[Boolean](dump(true))) + println("a="+load[Char](dump('a'))) + println("1="+load[Int](dump(1))) + println("'abc="+load[Symbol](dump('abc))) + println() + + println("List(())="+load[List[Unit]](dump(List(())))) + println("List(true)="+load[List[Boolean]](dump(List(true)))) + println("List('abc)="+load[List[Symbol]](dump(List('abc)))) + println() + + def loadArray[T](x: Array[Byte])(implicit t: reflect.ClassTag[Array[T]]) = + load[Array[T]](x)(t).deep.toString + println("Array()="+loadArray[Int](dump(Array(): Array[Int]))) + println("Array(true)="+loadArray[Boolean](dump(Array(true)))) + println("Array(a)="+loadArray[Char](dump(Array('a')))) + println("Array(1)="+loadArray[Int](dump(Array(1)))) + println() + + println("((),())="+load[(Unit, Unit)](dump(((), ())))) + println("(true,false)="+load[(Boolean, Boolean)](dump((true, false)))) + println() + + println("List(List(1), List(2))="+load[List[List[Int]]](dump(List(List(1), List(2))))) + println() + + println("Array(Array(1), Array(2))="+loadArray[Array[Int]](dump(Array(Array(1), Array(2))))) + println() +} + +trait TestUtil { + import java.io._ + def write[A](o: A): Array[Byte] = { + val ba = new ByteArrayOutputStream(512) + val out = new ObjectOutputStream(ba) + out.writeObject(o) + out.close() + ba.toByteArray() + } + def read[A](buffer: Array[Byte]): A = { + val in = new ObjectInputStream(new ByteArrayInputStream(buffer)) + in.readObject().asInstanceOf[A] + } + import scala.reflect._ + def print[T](x: T)(implicit t: ConcreteTypeTag[T]) { + // todo. type tags are not yet serializable +// val t1: ConcreteTypeTag[T] = read(write(t)) + val t1: ConcreteTypeTag[T] = t + val x1 = x.toString.replaceAll("@[0-9a-z]+$", "") + println("x="+x1+", t="+t1+", k="+t1.tpe.kind+", s="+t1.sym.toString) + } +} diff --git a/test/files/jvm/manifests.check.temporarily.disabled b/test/files/jvm/manifests-old.check index 54f504b929..54f504b929 100644 --- a/test/files/jvm/manifests.check.temporarily.disabled +++ b/test/files/jvm/manifests-old.check diff --git a/test/files/jvm/manifests.scala.temporarily.disabled b/test/files/jvm/manifests-old.scala index 241966fd9d..241966fd9d 100644 --- a/test/files/jvm/manifests.scala.temporarily.disabled +++ b/test/files/jvm/manifests-old.scala diff --git a/test/files/jvm/scala-concurrent-tck.scala b/test/files/jvm/scala-concurrent-tck.scala index f0ca438774..012460147a 100644 --- a/test/files/jvm/scala-concurrent-tck.scala +++ b/test/files/jvm/scala-concurrent-tck.scala @@ -64,7 +64,7 @@ trait FutureCallbacks extends TestBase { } } } - + def testOnSuccessWhenFailed(): Unit = once { done => val f = future[Unit] { @@ -94,7 +94,7 @@ trait FutureCallbacks extends TestBase { assert(x == 1) } } - + def testOnFailureWhenSpecialThrowable(num: Int, cause: Throwable): Unit = once { done => val f = future[Unit] { @@ -139,7 +139,8 @@ trait FutureCallbacks extends TestBase { testOnFailure() testOnFailureWhenSpecialThrowable(5, new Error) testOnFailureWhenSpecialThrowable(6, new scala.util.control.ControlThrowable { }) - testOnFailureWhenSpecialThrowable(7, new InterruptedException) + //TODO: this test is currently problematic, because NonFatal does not match InterruptedException + //testOnFailureWhenSpecialThrowable(7, new InterruptedException) testOnFailureWhenTimeoutException() } @@ -181,6 +182,72 @@ trait FutureCombinators extends TestBase { } } + def testMapSuccessPF(): Unit = once { + done => + val f = future { 5 } + val g = f map { case r => "result: " + r } + g onSuccess { + case s => + done() + assert(s == "result: 5") + } + g onFailure { + case _ => + done() + assert(false) + } + } + + def testTransformSuccess(): Unit = once { + done => + val f = future { 5 } + val g = f.transform(r => "result: " + r, identity) + g onSuccess { + case s => + done() + assert(s == "result: 5") + } + g onFailure { + case _ => + done() + assert(false) + } + } + + def testTransformSuccessPF(): Unit = once { + done => + val f = future { 5 } + val g = f.transform( { case r => "result: " + r }, identity) + g onSuccess { + case s => + done() + assert(s == "result: 5") + } + g onFailure { + case _ => + done() + assert(false) + } + } + + def testFoldFailure(): Unit = once { + done => + val f = future { + throw new Exception("exception message") + } + val g = f.transform(r => "result: " + r, identity) + g onSuccess { + case _ => + done() + assert(false) + } + g onFailure { + case t => + done() + assert(t.getMessage() == "exception message") + } + } + def testFlatMapSuccess(): Unit = once { done => val f = future { 5 } @@ -289,6 +356,9 @@ trait FutureCombinators extends TestBase { } } + /* TODO: Test for NonFatal in collect (more of a regression test at this point). + */ + def testForeachSuccess(): Unit = once { done => val p = promise[Int]() @@ -336,14 +406,17 @@ trait FutureCombinators extends TestBase { } recover { case re: RuntimeException => "recovered" - } onSuccess { + } + f onSuccess { case x => done() assert(x == "recovered") - } onFailure { case any => + } + f onFailure { case any => done() assert(false) } + f } def testRecoverFailure(): Unit = once { @@ -353,11 +426,13 @@ trait FutureCombinators extends TestBase { throw cause } recover { case te: TimeoutException => "timeout" - } onSuccess { + } + f onSuccess { case x => done() assert(false) - } onFailure { case any => + } + f onFailure { case any => done() assert(any == cause) } @@ -371,11 +446,13 @@ trait FutureCombinators extends TestBase { } recoverWith { case re: RuntimeException => future { "recovered" } - } onSuccess { + } + f onSuccess { case x => done() assert(x == "recovered") - } onFailure { case any => + } + f onFailure { case any => done() assert(false) } @@ -389,11 +466,13 @@ trait FutureCombinators extends TestBase { } recoverWith { case te: TimeoutException => future { "timeout" } - } onSuccess { + } + f onSuccess { case x => done() assert(false) - } onFailure { case any => + } + f onFailure { case any => done() assert(any == cause) } @@ -473,8 +552,8 @@ trait FutureCombinators extends TestBase { def testFallbackToFailure(): Unit = once { done => val cause = new Exception - val f = future { throw cause } - val g = future { sys.error("failed") } + val f = future { sys.error("failed") } + val g = future { throw cause } val h = f fallbackTo g h onSuccess { @@ -631,11 +710,12 @@ trait Promises extends TestBase { val p = promise[Int]() val f = p.future - f.onSuccess { + f onSuccess { case x => done() assert(x == 5) - } onFailure { + } + f onFailure { case any => done() assert(false) @@ -728,6 +808,126 @@ trait TryEitherExtractor extends TestBase { testLeftMatch() } +trait CustomExecutionContext extends TestBase { + import scala.concurrent.{ ExecutionContext, Awaitable } + + def defaultEC = ExecutionContext.defaultExecutionContext + + val inEC = new java.lang.ThreadLocal[Int]() { + override def initialValue = 0 + } + + def enterEC() = inEC.set(inEC.get + 1) + def leaveEC() = inEC.set(inEC.get - 1) + def assertEC() = assert(inEC.get > 0) + def assertNoEC() = assert(inEC.get == 0) + + class CountingExecutionContext extends ExecutionContext { + val _count = new java.util.concurrent.atomic.AtomicInteger(0) + def count = _count.get + + def delegate = ExecutionContext.defaultExecutionContext + + override def execute(runnable: Runnable) = { + _count.incrementAndGet() + val wrapper = new Runnable() { + override def run() = { + enterEC() + try { + runnable.run() + } finally { + leaveEC() + } + } + } + delegate.execute(wrapper) + } + + override def internalBlockingCall[T](awaitable: Awaitable[T], atMost: Duration): T = + delegate.internalBlockingCall(awaitable, atMost) + + override def reportFailure(t: Throwable): Unit = { + System.err.println("Failure: " + t.getClass.getSimpleName + ": " + t.getMessage) + delegate.reportFailure(t) + } + } + + def countExecs(block: (ExecutionContext) => Unit): Int = { + val context = new CountingExecutionContext() + block(context) + context.count + } + + def testOnSuccessCustomEC(): Unit = { + val count = countExecs { implicit ec => + once { done => + val f = future({ assertNoEC() })(defaultEC) + f onSuccess { + case _ => + assertEC() + done() + } + assertNoEC() + } + } + + // should be onSuccess, but not future body + assert(count == 1) + } + + def testKeptPromiseCustomEC(): Unit = { + val count = countExecs { implicit ec => + once { done => + val f = Promise.successful(10).future + f onSuccess { + case _ => + assertEC() + done() + } + } + } + + // should be onSuccess called once in proper EC + assert(count == 1) + } + + def testCallbackChainCustomEC(): Unit = { + val count = countExecs { implicit ec => + once { done => + assertNoEC() + val addOne = { x: Int => assertEC(); x + 1 } + val f = Promise.successful(10).future + f.map(addOne).filter { x => + assertEC() + x == 11 + } flatMap { x => + Promise.successful(x + 1).future.map(addOne).map(addOne) + } onComplete { + case Left(t) => + try { + throw new AssertionError("error in test: " + t.getMessage, t) + } finally { + done() + } + case Right(x) => + assertEC() + assert(x == 14) + done() + } + assertNoEC() + } + } + + // the count is not defined (other than >=1) + // due to the batching optimizations. + assert(count >= 1) + } + + testOnSuccessCustomEC() + testKeptPromiseCustomEC() + testCallbackChainCustomEC() +} + object Test extends App with FutureCallbacks @@ -736,6 +936,7 @@ with FutureProjections with Promises with Exceptions with TryEitherExtractor +with CustomExecutionContext { System.exit(0) } diff --git a/test/files/jvm/serialization-new.check b/test/files/jvm/serialization-new.check new file mode 100644 index 0000000000..fa51c6a879 --- /dev/null +++ b/test/files/jvm/serialization-new.check @@ -0,0 +1,313 @@ +a1 = Array[1,2,3] +_a1 = Array[1,2,3] +arrayEquals(a1, _a1): true + +e1 = Left(1) +_e1 = Left(1) +e1 eq _e1: false, _e1 eq e1: false +e1 equals _e1: true, _e1 equals e1: true + +x7 = RoundingMode +y7 = RoundingMode +x7 eq y7: true, y7 eq x7: true +x7 equals y7: true, y7 equals x7: true + +x8 = WeekDay +y8 = WeekDay +x8 eq y8: true, y8 eq x8: true +x8 equals y8: true, y8 equals x8: true + +x9 = UP +y9 = UP +x9 eq y9: true, y9 eq x9: true +x9 equals y9: true, y9 equals x9: true + +x10 = Monday +y10 = Monday +x10 eq y10: true, y10 eq x10: true +x10 equals y10: true, y10 equals x10: true + +x9 eq x10: false, x10 eq x9: false +x9 equals x10: false, x10 equals x9: false +x9 eq y10: false, y10 eq x9: false +x9 equals y10: false, y10 equals x9: false + +f1 = <na> +_f1 = <na> +f1(2): 4, _f1(2): 4 + +xs0 = List(1, 2, 3) +_xs0 = List(1, 2, 3) +xs0 eq _xs0: false, _xs0 eq xs0: false +xs0 equals _xs0: true, _xs0 equals xs0: true + +xs1 = List() +_xs1 = List() +xs1 eq _xs1: true, _xs1 eq xs1: true + +o1 = None +_o1 = None +o1 eq _o1: true, _o1 eq o1: true + +o2 = Some(1) +_o2 = Some(1) +o2 eq _o2: false, _o2 eq o2: false +o2 equals _o2: true, _o2 equals o2: true + +s1 = 'hello +_s1 = 'hello +s1 eq _s1: true, _s1 eq s1: true +s1 equals _s1: true, _s1 equals s1: true + +t1 = (BannerLimit,12345) +_t1 = (BannerLimit,12345) +t1 eq _t1: false, _t1 eq t1: false +t1 equals _t1: true, _t1 equals t1: true + +x = BitSet(1, 2) +y = BitSet(1, 2) +x equals y: true, y equals x: true + +x = BitSet(2, 3) +y = BitSet(2, 3) +x equals y: true, y equals x: true + +x = Map(1 -> A, 2 -> B, 3 -> C) +y = Map(1 -> A, 2 -> B, 3 -> C) +x equals y: true, y equals x: true + +x = Set(1, 2) +y = Set(1, 2) +x equals y: true, y equals x: true + +x = List((buffers,20), (layers,2), (title,3)) +y = List((buffers,20), (layers,2), (title,3)) +x equals y: true, y equals x: true + +x = Map(buffers -> 20, layers -> 2, title -> 3) +y = Map(buffers -> 20, layers -> 2, title -> 3) +x equals y: true, y equals x: true + +x = ListSet(5, 3) +y = ListSet(5, 3) +x equals y: true, y equals x: true + +x = Queue(a, b, c) +y = Queue(a, b, c) +x equals y: true, y equals x: true + +x = Range(0, 1, 2, 3, 4, 5, 6, 7, 8, 9) +y = Range(0, 1, 2, 3, 4, 5, 6, 7, 8, 9) +x equals y: true, y equals x: true + +x = NumericRange(0, 1, 2, 3, 4, 5, 6, 7, 8, 9) +y = NumericRange(0, 1, 2, 3, 4, 5, 6, 7, 8, 9) +x equals y: true, y equals x: true + +x = Map(1 -> A, 2 -> B, 3 -> C) +y = Map(1 -> A, 2 -> B, 3 -> C) +x equals y: true, y equals x: true + +x = TreeSet(1, 2, 3) +y = TreeSet(1, 2, 3) +x equals y: true, y equals x: true + +x = Stack(c, b, a) +y = Stack(c, b, a) +x equals y: true, y equals x: true + +x = Stream(0, ?) +y = Stream(0, ?) +x equals y: true, y equals x: true + +x = Map(42 -> FortyTwo) +y = Map(42 -> FortyTwo) +x equals y: true, y equals x: true + +x = TreeSet(0, 2) +y = TreeSet(0, 2) +x equals y: true, y equals x: true + +x = Vector('a, 'b, 'c) +y = Vector('a, 'b, 'c) +x equals y: true, y equals x: true + +x = ArrayBuffer(one, two) +y = ArrayBuffer(one, two) +x equals y: true, y equals x: true + +x = ArrayBuilder.ofLong +y = ArrayBuilder.ofLong +x equals y: true, y equals x: true + +x = ArrayBuilder.ofFloat +y = ArrayBuilder.ofFloat +x equals y: true, y equals x: true + +x = ArraySeq(1, 2, 3) +y = ArraySeq(1, 2, 3) +x equals y: true, y equals x: true + +x = ArrayStack(3, 2, 20) +y = ArrayStack(3, 2, 20) +x equals y: true, y equals x: true + +x = BitSet(0, 8, 9) +y = BitSet(0, 8, 9) +x equals y: true, y equals x: true + +x = Map(A -> 1, C -> 3, B -> 2) +y = Map(A -> 1, C -> 3, B -> 2) +x equals y: true, y equals x: true + +x = Set(buffers, title, layers) +y = Set(buffers, title, layers) +x equals y: true, y equals x: true + +x = History() +y = History() +x equals y: true, y equals x: true + +x = ListBuffer(white, black) +y = ListBuffer(white, black) +x equals y: true, y equals x: true + +x = Queue(20, 2, 3) +y = Queue(20, 2, 3) +x equals y: true, y equals x: true + +x = Stack(3, 2, 20) +y = Stack(3, 2, 20) +x equals y: true, y equals x: true + +x = abc +y = abc +x equals y: true, y equals x: true + +x = WrappedArray(1, 2, 3) +y = WrappedArray(1, 2, 3) +x equals y: true, y equals x: true + +x = TreeSet(1, 2, 3) +y = TreeSet(1, 2, 3) +x equals y: true, y equals x: true + +x = TrieMap(1 -> one, 2 -> two, 3 -> three) +y = TrieMap(1 -> one, 2 -> two, 3 -> three) +x equals y: true, y equals x: true + +x = xml:src="hello" +y = xml:src="hello" +x equals y: true, y equals x: true + +x = <title></title> +y = <title></title> +x equals y: true, y equals x: true + +x = <html><title>title</title><body></body></html> +y = <html><title>title</title><body></body></html> +x equals y: true, y equals x: true + +x = <html> + <body> + <table cellpadding="2" cellspacing="0"> + <tr> + <th>Last Name</th> + <th>First Name</th> + </tr> + <tr> + <td> Tom </td> + <td> 20 </td> + </tr><tr> + <td> Bob </td> + <td> 22 </td> + </tr><tr> + <td> James </td> + <td> 19 </td> + </tr> + </table> + </body> + </html> +y = <html> + <body> + <table cellpadding="2" cellspacing="0"> + <tr> + <th>Last Name</th> + <th>First Name</th> + </tr> + <tr> + <td> Tom </td> + <td> 20 </td> + </tr><tr> + <td> Bob </td> + <td> 22 </td> + </tr><tr> + <td> James </td> + <td> 19 </td> + </tr> + </table> + </body> + </html> +x equals y: true, y equals x: true + +x = Tim +y = Tim +x equals y: true, y equals x: true + +x = Bob +y = Bob +x equals y: true, y equals x: true + +x = John +y = John +x equals y: true, y equals x: true + +x = Bill +y = Bill +x equals y: true, y equals x: true + +x = Paul +y = Paul +x equals y: true, y equals x: true + +1 +2 +1 +2 + +x = UnrolledBuffer(one, two) +y = UnrolledBuffer(one, two) +x equals y: true, y equals x: true + +x = ParArray(abc, def, etc) +y = ParArray(abc, def, etc) +x equals y: true, y equals x: true + +x = ParHashMap(2 -> 4, 1 -> 2) +y = ParHashMap(2 -> 4, 1 -> 2) +x equals y: true, y equals x: true + +x = ParTrieMap(1 -> 2, 2 -> 4) +y = ParTrieMap(1 -> 2, 2 -> 4) +x equals y: true, y equals x: true + +x = ParHashSet(1, 2, 3) +y = ParHashSet(1, 2, 3) +x equals y: true, y equals x: true + +x = ParRange(0, 1, 2, 3, 4) +y = ParRange(0, 1, 2, 3, 4) +x equals y: true, y equals x: true + +x = ParRange(0, 1, 2, 3) +y = ParRange(0, 1, 2, 3) +x equals y: true, y equals x: true + +x = ParMap(5 -> 1, 10 -> 2) +y = ParMap(5 -> 1, 10 -> 2) +x equals y: true, y equals x: true + +x = ParSet(two, one) +y = ParSet(two, one) +x equals y: true, y equals x: true + diff --git a/test/files/jvm/serialization-new.scala b/test/files/jvm/serialization-new.scala new file mode 100644 index 0000000000..bb971fdf36 --- /dev/null +++ b/test/files/jvm/serialization-new.scala @@ -0,0 +1,651 @@ +//############################################################################ +// Serialization +//############################################################################ + +object Serialize { + @throws(classOf[java.io.IOException]) + def write[A](o: A): Array[Byte] = { + val ba = new java.io.ByteArrayOutputStream(512) + val out = new java.io.ObjectOutputStream(ba) + out.writeObject(o) + out.close() + ba.toByteArray() + } + @throws(classOf[java.io.IOException]) + @throws(classOf[ClassNotFoundException]) + def read[A](buffer: Array[Byte]): A = { + val in = + new java.io.ObjectInputStream(new java.io.ByteArrayInputStream(buffer)) + in.readObject().asInstanceOf[A] + } + def check[A, B](x: A, y: B) { + println("x = " + x) + println("y = " + y) + println("x equals y: " + (x equals y) + ", y equals x: " + (y equals x)) + assert((x equals y) && (y equals x)) + println() + } +} +import Serialize._ + +//############################################################################ +// Test classes in package "scala" + +object Test1_scala { + + private def arrayToString[A](arr: Array[A]): String = + arr.mkString("Array[",",","]") + + private def arrayEquals[A, B](a1: Array[A], a2: Array[B]): Boolean = + (a1.length == a2.length) && + (Iterator.range(0, a1.length) forall { i => a1(i) == a2(i) }) + + object WeekDay extends Enumeration { + type WeekDay = Value + val Monday, Tuesday, Wednesday, Thusday, Friday, Saturday, Sunday = Value + } + import WeekDay._, BigDecimal._, RoundingMode._ + + // in alphabetic order + try { + // Array + val a1 = Array(1, 2, 3) + val _a1: Array[Int] = read(write(a1)) + println("a1 = " + arrayToString(a1)) + println("_a1 = " + arrayToString(_a1)) + println("arrayEquals(a1, _a1): " + arrayEquals(a1, _a1)) + println() + + // Either + val e1 = Left(1) + val _e1: Either[Int, String] = read(write(e1)) + println("e1 = " + e1) + println("_e1 = " + _e1) + println("e1 eq _e1: " + (e1 eq _e1) + ", _e1 eq e1: " + (_e1 eq e1)) + println("e1 equals _e1: " + (e1 equals _e1) + ", _e1 equals e1: " + (_e1 equals e1)) + println() + + // Enumeration + val x7 = BigDecimal.RoundingMode + val y7: RoundingMode.type = read(write(x7)) + println("x7 = " + x7) + println("y7 = " + y7) + println("x7 eq y7: " + (x7 eq y7) + ", y7 eq x7: " + (y7 eq x7)) + println("x7 equals y7: " + (x7 equals y7) + ", y7 equals x7: " + (y7 equals x7)) + println() + + val x8 = WeekDay + val y8: WeekDay.type = read(write(x8)) + println("x8 = " + x8) + println("y8 = " + y8) + println("x8 eq y8: " + (x8 eq y8) + ", y8 eq x8: " + (y8 eq x8)) + println("x8 equals y8: " + (x8 equals y8) + ", y8 equals x8: " + (y8 equals x8)) + println() + + val x9 = UP + val y9: RoundingMode = read(write(x9)) + println("x9 = " + x9) + println("y9 = " + y9) + println("x9 eq y9: " + (x9 eq y9) + ", y9 eq x9: " + (y9 eq x9)) + println("x9 equals y9: " + (x9 equals y9) + ", y9 equals x9: " + (y9 equals x9)) + println() + + val x10 = Monday + val y10: WeekDay = read(write(x10)) + println("x10 = " + x10) + println("y10 = " + y10) + println("x10 eq y10: " + (x10 eq y10) + ", y10 eq x10: " + (y10 eq x10)) + println("x10 equals y10: " + (x10 equals y10) + ", y10 equals x10: " + (y10 equals x10)) + println() + + println("x9 eq x10: " + (x9 eq x10) + ", x10 eq x9: " + (x10 eq x9)) + println("x9 equals x10: " + (x9 equals x10) + ", x10 equals x9: " + (x10 equals x9)) + println("x9 eq y10: " + (x9 eq y10) + ", y10 eq x9: " + (y10 eq x9)) + println("x9 equals y10: " + (x9 equals y10) + ", y10 equals x9: " + (y10 equals x9)) + println() + + // Function + val f1 = { x: Int => 2 * x } + val _f1: Function[Int, Int] = read(write(f1)) + println("f1 = <na>") + println("_f1 = <na>") + println("f1(2): " + f1(2) + ", _f1(2): " + _f1(2)) + println() + + // List + val xs0 = List(1, 2, 3) + val _xs0: List[Int] = read(write(xs0)) + println("xs0 = " + xs0) + println("_xs0 = " + _xs0) + println("xs0 eq _xs0: " + (xs0 eq _xs0) + ", _xs0 eq xs0: " + (_xs0 eq xs0)) + println("xs0 equals _xs0: " + (xs0 equals _xs0) + ", _xs0 equals xs0: " + (_xs0 equals xs0)) + println() + + val xs1 = Nil + val _xs1: List[Nothing] = read(write(xs1)) + println("xs1 = " + xs1) + println("_xs1 = " + _xs1) + println("xs1 eq _xs1: " + (xs1 eq _xs1) + ", _xs1 eq xs1: " + (_xs1 eq xs1)) + println() + + // Option + val o1 = None + val _o1: Option[Nothing] = read(write(o1)) + println("o1 = " + o1) + println("_o1 = " + _o1) + println("o1 eq _o1: " + (o1 eq _o1) + ", _o1 eq o1: " + (_o1 eq o1)) + println() + + val o2 = Some(1) + val _o2: Option[Int] = read(write(o2)) + println("o2 = " + o2) + println("_o2 = " + _o2) + println("o2 eq _o2: " + (o2 eq _o2) + ", _o2 eq o2: " + (_o2 eq o2)) + println("o2 equals _o2: " + (o2 equals _o2) + ", _o2 equals o2: " + (_o2 equals o2)) + println() +/* + // Responder + val r1 = Responder.constant("xyz") + val _r1: Responder[String] = read(write(r1)) + check(r1, _r1) +*/ + // Symbol + val s1 = 'hello + val _s1: Symbol = read(write(s1)) + println("s1 = " + s1) + println("_s1 = " + _s1) + println("s1 eq _s1: " + (s1 eq _s1) + ", _s1 eq s1: " + (_s1 eq s1)) + println("s1 equals _s1: " + (s1 equals _s1) + ", _s1 equals s1: " + (_s1 equals s1)) + println() + + // Tuple + val t1 = ("BannerLimit", 12345) + val _t1: (String, Int) = read(write(t1)) + println("t1 = " + t1) + println("_t1 = " + _t1) + println("t1 eq _t1: " + (t1 eq _t1) + ", _t1 eq t1: " + (_t1 eq t1)) + println("t1 equals _t1: " + (t1 equals _t1) + ", _t1 equals t1: " + (_t1 equals t1)) + println() + } + catch { + case e: Exception => + println("Error in Test1_scala: " + e) + throw e + } +} + +//############################################################################ +// Test classes in package "scala.collection.immutable" + +object Test2_immutable { + import scala.collection.immutable.{ + BitSet, HashMap, HashSet, ListMap, ListSet, Queue, Range, SortedMap, + SortedSet, Stack, Stream, TreeMap, TreeSet, Vector} + + // in alphabetic order + try { + // BitSet + val bs1 = BitSet.empty + 1 + 2 + val _bs1: BitSet = read(write(bs1)) + check(bs1, _bs1) + + val bs2 = { + val bs = new collection.mutable.BitSet() + bs += 2; bs += 3 + bs.toImmutable + } + val _bs2: BitSet = read(write(bs2)) + check(bs2, _bs2) + + // HashMap + val hm1 = new HashMap[Int, String] + (1 -> "A", 2 -> "B", 3 -> "C") + val _hm1: HashMap[Int, String] = read(write(hm1)) + check(hm1, _hm1) + + // HashSet + val hs1 = new HashSet[Int] + 1 + 2 + val _hs1: HashSet[Int] = read(write(hs1)) + check(hs1, _hs1) + + // List + val xs1 = List(("buffers", 20), ("layers", 2), ("title", 3)) + val _xs1: List[(String, Int)] = read(write(xs1)) + check(xs1, _xs1) + + // ListMap + val lm1 = new ListMap[String, Int] + ("buffers" -> 20, "layers" -> 2, "title" -> 3) + val _lm1: ListMap[String, Int] = read(write(lm1)) + check(lm1, _lm1) + + // ListSet + val ls1 = new ListSet[Int] + 3 + 5 + val _ls1: ListSet[Int] = read(write(ls1)) + check(ls1, _ls1) + + // Queue + val q1 = Queue("a", "b", "c") + val _q1: Queue[String] = read(write(q1)) + check(q1, _q1) + + // Range + val r1 = 0 until 10 + val _r1: Range = read(write(r1)) + check(r1, _r1) + + val r2 = Range.Long(0L, 10L, 1) + val _r2: r2.type = read(write(r2)) + check(r2, _r2) + + // SortedMap + val sm1 = SortedMap.empty[Int, String] + (2 -> "B", 3 -> "C", 1 -> "A") + val _sm1: SortedMap[Int, String] = read(write(sm1)) + check(sm1, _sm1) + + // SortedSet + val ss1 = SortedSet.empty[Int] + 2 + 3 + 1 + val _ss1: SortedSet[Int] = read(write(ss1)) + check(ss1, _ss1) + + // Stack + val s1 = new Stack().push("a", "b", "c") + val _s1: Stack[String] = read(write(s1)) + check(s1, _s1) + + // Stream + val st1 = Stream.range(0, 10) + val _st1: Stream[Int] = read(write(st1)) + check(st1, _st1) + + // TreeMap + val tm1 = new TreeMap[Int, String] + (42 -> "FortyTwo") + val _tm1: TreeMap[Int, String] = read(write(tm1)) + check(tm1, _tm1) + + // TreeSet + val ts1 = new TreeSet[Int]() + 2 + 0 + val _ts1: TreeSet[Int] = read(write(ts1)) + check(ts1, _ts1) + + // Vector + val v1 = Vector('a, 'b, 'c) + val _v1: Vector[Symbol] = read(write(v1)) + check(v1, _v1) + } + catch { + case e: Exception => + println("Error in Test2_immutable: " + e) + throw e + } +} + +//############################################################################ +// Test classes in package "scala.collection.mutable" + +object Test3_mutable { + import scala.reflect.ArrayTag + import scala.collection.mutable.{ + ArrayBuffer, ArrayBuilder, ArraySeq, ArrayStack, BitSet, DoubleLinkedList, + HashMap, HashSet, History, LinkedList, ListBuffer, Publisher, Queue, + Stack, StringBuilder, WrappedArray, TreeSet} + import scala.collection.concurrent.TrieMap + + // in alphabetic order + try { + // ArrayBuffer + val ab1 = new ArrayBuffer[String] + ab1 ++= List("one", "two") + val _ab1: ArrayBuffer[String] = read(write(ab1)) + check(ab1, _ab1) + + // ArrayBuilder + val abu1 = ArrayBuilder.make[Long] + val _abu1: ArrayBuilder[ArrayTag[Long]] = read(write(abu1)) + check(abu1, _abu1) + + val abu2 = ArrayBuilder.make[Float] + val _abu2: ArrayBuilder[ArrayTag[Float]] = read(write(abu2)) + check(abu2, _abu2) + + // ArraySeq + val aq1 = ArraySeq(1, 2, 3) + val _aq1: ArraySeq[Int] = read(write(aq1)) + check(aq1, _aq1) + + // ArrayStack + val as1 = new ArrayStack[Int] + as1 ++= List(20, 2, 3).iterator + val _as1: ArrayStack[Int] = read(write(as1)) + check(as1, _as1) + + // BitSet + val bs1 = new BitSet() + bs1 += 0 + bs1 += 8 + bs1 += 9 + val _bs1: BitSet = read(write(bs1)) + check(bs1, _bs1) +/* + // DoubleLinkedList + val dl1 = new DoubleLinkedList[Int](2, null) + dl1.append(new DoubleLinkedList(3, null)) + val _dl1: DoubleLinkedList[Int] = read(write(dl1)) + check(dl1, _dl1) +*/ + // HashMap + val hm1 = new HashMap[String, Int] + hm1 ++= List(("A", 1), ("B", 2), ("C", 3)).iterator + val _hm1: HashMap[String, Int] = read(write(hm1)) + check(hm1, _hm1) + + // HashSet + val hs1 = new HashSet[String] + hs1 ++= List("layers", "buffers", "title").iterator + val _hs1: HashSet[String] = read(write(hs1)) + check(hs1, _hs1) + + val h1 = new History[String, Int] + val _h1: History[String, Int] = read(write(h1)) + check(h1, _h1) +/* + // LinkedList + val ll1 = new LinkedList[Int](2, null) + ll1.append(new LinkedList(3, null)) + val _ll1: LinkedList[Int] = read(write(ll1)) + check(ll1, _ll1) +*/ + // ListBuffer + val lb1 = new ListBuffer[String] + lb1 ++= List("white", "black") + val _lb1: ListBuffer[String] = read(write(lb1)) + check(lb1, _lb1) + + // Queue + val q1 = new Queue[Int] + q1 ++= List(20, 2, 3).iterator + val _q1: Queue[Int] = read(write(q1)) + check(q1, _q1) + + // Stack + val s1 = new Stack[Int] + s1 pushAll q1 + val _s1: Stack[Int] = read(write(s1)) + check(s1, _s1) + + // StringBuilder + val sb1 = new StringBuilder + sb1 append "abc" + val _sb1: StringBuilder = read(write(sb1)) + check(sb1, _sb1) + + // WrappedArray + val wa1 = WrappedArray.make(Array(1, 2, 3)) + val _wa1: WrappedArray[Int] = read(write(wa1)) + check(wa1, _wa1) + + // TreeSet + val ts1 = TreeSet[Int]() ++= Array(1, 2, 3) + val _ts1: TreeSet[Int] = read(write(ts1)) + check(ts1, _ts1) + + // concurrent.TrieMap + val ct1 = TrieMap[Int, String]() ++= Array(1 -> "one", 2 -> "two", 3 -> "three") + val _ct1: TrieMap[Int, String] = read(write(ct1)) + check(ct1, _ct1) + } + catch { + case e: Exception => + println("Error in Test3_mutable: " + e) + throw e + } +} + + +//############################################################################ +// Test classes in package "scala.xml" + +object Test4_xml { + import scala.xml.{Attribute, Document, Elem, Null, PrefixedAttribute, Text} + + case class Person(name: String, age: Int) + + try { + // Attribute + val a1 = new PrefixedAttribute("xml", "src", Text("hello"), Null) + val _a1: Attribute = read(write(a1)) + check(a1, _a1) + + // Document + val d1 = new Document + d1.docElem = <title></title> + d1.encoding = Some("UTF-8") + val _d1: Document = read(write(d1)) + check(d1, _d1) + + // Elem + val e1 = <html><title>title</title><body></body></html>; + val _e1: Elem = read(write(e1)) + check(e1, _e1) + + class AddressBook(a: Person*) { + private val people: List[Person] = a.toList + def toXHTML = + <table cellpadding="2" cellspacing="0"> + <tr> + <th>Last Name</th> + <th>First Name</th> + </tr> + { for (p <- people) yield + <tr> + <td> { p.name } </td> + <td> { p.age.toString() } </td> + </tr> } + </table>; + } + + val people = new AddressBook( + Person("Tom", 20), + Person("Bob", 22), + Person("James", 19)) + + val e2 = + <html> + <body> + { people.toXHTML } + </body> + </html>; + val _e2: Elem = read(write(e2)) + check(e2, _e2) + } + catch { + case e: Exception => + println("Error in Test4_xml: " + e) + throw e + } +} + +//############################################################################ +// Test user-defined classes WITHOUT nesting + +class Person(_name: String) extends Serializable { + private var name = _name + override def toString() = name + override def equals(that: Any): Boolean = + that.isInstanceOf[Person] && + (name == that.asInstanceOf[Person].name) +} + +class Employee(_name: String) extends Serializable { + private var name = _name + override def toString() = name +} + +object bob extends Employee("Bob") + +object Test5 { + val x1 = new Person("Tim") + val x2 = bob + + try { + val y1: Person = read(write(x1)) + val y2: Employee = read(write(x2)) + + check(x1, y1) + check(x2, y2) + } + catch { + case e: Exception => + println("Error in Test5: " + e) + } +} + +//############################################################################ +// Test user-defined classes WITH nesting + +object Test6 { + object bill extends Employee("Bill") { + val x = paul + } + object paul extends Person("Paul") { + val x = 4 // bill; => StackOverflowException !!! + } + val x1 = new Person("John") + val x2 = bill + val x3 = paul + + try { + val y1: Person = read(write(x1)) + val y2: Employee = read(write(x2)) + val y3: Person = read(write(x3)) + + check(x1, y1) + check(x2, y2) + check(x3, y3) + } + catch { + case e: Exception => + println("Error in Test6: " + e) + } +} + +//############################################################################ +// Nested objects cannot get readresolve automatically because after deserialization +// they would be null (they are treated as lazy vals) +class Outer extends Serializable { + object Inner extends Serializable +} + +object Test7 { + val x = new Outer + x.Inner // initialize + val y:Outer = read(write(x)) + if (y.Inner == null) + println("Inner object is null") +} + +// Verify that transient lazy vals don't get serialized +class WithTransient extends Serializable { + @transient lazy val a1 = 1 + @transient private lazy val a2 = 2 + @transient object B extends Serializable + @transient private object C extends Serializable + + def test = { + println(a1) + println(a2) + if (B == null || C == null) + println("Transient nested object failed to serialize properly") + } +} + +object Test8 { + val x = new WithTransient + x.test + try { + val y:WithTransient = read(write(x)) + y.test + } + catch { + case e: Exception => + println("Error in Test8: " + e) + } +} + +//############################################################################ +// Test code + +object Test { + def main(args: Array[String]) { + Test1_scala + Test2_immutable + Test3_mutable + Test4_xml + Test5 + Test6 + Test7 + Test8 + Test9_parallel + } +} + +//############################################################################ + + +//############################################################################ +// Test classes in package "scala.collection.parallel" and subpackages +object Test9_parallel { + import scala.collection.parallel._ + + try { + println() + + // UnrolledBuffer + val ub = new collection.mutable.UnrolledBuffer[String] + ub ++= List("one", "two") + val _ub: collection.mutable.UnrolledBuffer[String] = read(write(ub)) + check(ub, _ub) + + // mutable.ParArray + val pa = mutable.ParArray("abc", "def", "etc") + val _pa: mutable.ParArray[String] = read(write(pa)) + check(pa, _pa) + + // mutable.ParHashMap + val mpm = mutable.ParHashMap(1 -> 2, 2 -> 4) + val _mpm: mutable.ParHashMap[Int, Int] = read(write(mpm)) + check(mpm, _mpm) + + // mutable.ParTrieMap + val mpc = mutable.ParTrieMap(1 -> 2, 2 -> 4) + val _mpc: mutable.ParTrieMap[Int, Int] = read(write(mpc)) + check(mpc, _mpc) + + // mutable.ParHashSet + val mps = mutable.ParHashSet(1, 2, 3) + val _mps: mutable.ParHashSet[Int] = read(write(mps)) + check(mps, _mps) + + // immutable.ParRange + val pr1 = immutable.ParRange(0, 4, 1, true) + val _pr1: immutable.ParRange = read(write(pr1)) + check(pr1, _pr1) + + val pr2 = immutable.ParRange(0, 4, 1, false) + val _pr2: immutable.ParRange = read(write(pr2)) + check(pr2, _pr2) + + // immutable.ParHashMap + val ipm = immutable.ParHashMap(5 -> 1, 10 -> 2) + val _ipm: immutable.ParHashMap[Int, Int] = read(write(ipm)) + check(ipm, _ipm) + + // immutable.ParHashSet + val ips = immutable.ParHashSet("one", "two") + val _ips: immutable.ParHashSet[String] = read(write(ips)) + check(ips, _ips) + + } catch { + case e: Exception => + println("Error in Test5_parallel: " + e) + throw e + } +} diff --git a/test/files/jvm/si5471.check b/test/files/jvm/si5471.check new file mode 100644 index 0000000000..bb101b641b --- /dev/null +++ b/test/files/jvm/si5471.check @@ -0,0 +1,2 @@ +true +true diff --git a/test/files/jvm/si5471.scala b/test/files/jvm/si5471.scala new file mode 100644 index 0000000000..2c8c4205c5 --- /dev/null +++ b/test/files/jvm/si5471.scala @@ -0,0 +1,17 @@ + +object Test { + + def main(args: Array[String]) { + import scala.math.Numeric + import scala.math.Numeric.Implicits._ + + val b = BigInt(Long.MaxValue) + 1 + + def dbl[N :Numeric](n: N) = n.toDouble + def flt[N :Numeric](n: N) = n.toFloat + + println(dbl(b) == b.toDouble) + println(flt(b) == b.toFloat) + } + +} diff --git a/test/files/jvm/signum.scala b/test/files/jvm/signum.scala index feb28d3e43..76602a6641 100644 --- a/test/files/jvm/signum.scala +++ b/test/files/jvm/signum.scala @@ -11,5 +11,11 @@ object Test { assert(math.signum(0) == 0) assert(math.signum(-1) == -1) assert(math.signum(Int.MinValue) == -1) + + assert(java.lang.Float.floatToIntBits(math.signum(0f)) == 0x0) + assert(java.lang.Float.floatToIntBits(math.signum(-0f)) == 0x80000000) + + assert(java.lang.Double.doubleToLongBits(math.signum(0d)) == 0x0L) + assert(java.lang.Double.doubleToLongBits(math.signum(-0d)) == 0x8000000000000000L) } } diff --git a/test/files/jvm/t1652.check b/test/files/jvm/t1652.check deleted file mode 100644 index dfa480ce6e..0000000000 --- a/test/files/jvm/t1652.check +++ /dev/null @@ -1,2 +0,0 @@ -OK1 -OK2 diff --git a/test/files/neg/annot-nonconst.check b/test/files/neg/annot-nonconst.check index e4166e08b6..b43e58a0ca 100644 --- a/test/files/neg/annot-nonconst.check +++ b/test/files/neg/annot-nonconst.check @@ -1,12 +1,12 @@ annot-nonconst.scala:1: warning: Implementation restriction: subclassing Classfile does not make your annotation visible at runtime. If that is what you want, you must write the annotation class in Java. -class Length(value: Int) extends ClassfileAnnotation +class Length(value: Int) extends annotation.ClassfileAnnotation ^ annot-nonconst.scala:2: warning: Implementation restriction: subclassing Classfile does not make your annotation visible at runtime. If that is what you want, you must write the annotation class in Java. -class Ann2(value: String) extends ClassfileAnnotation +class Ann2(value: String) extends annotation.ClassfileAnnotation ^ annot-nonconst.scala:6: error: annotation argument needs to be a constant; found: n @Length(n) def foo = "foo" diff --git a/test/files/neg/annot-nonconst.scala b/test/files/neg/annot-nonconst.scala index 69bb60d34e..1b5856f8b2 100644 --- a/test/files/neg/annot-nonconst.scala +++ b/test/files/neg/annot-nonconst.scala @@ -1,5 +1,5 @@ -class Length(value: Int) extends ClassfileAnnotation -class Ann2(value: String) extends ClassfileAnnotation +class Length(value: Int) extends annotation.ClassfileAnnotation +class Ann2(value: String) extends annotation.ClassfileAnnotation object Test { def n = 15 diff --git a/test/files/neg/applydynamic_sip.check b/test/files/neg/applydynamic_sip.check new file mode 100644 index 0000000000..8845f68a52 --- /dev/null +++ b/test/files/neg/applydynamic_sip.check @@ -0,0 +1,10 @@ +applydynamic_sip.scala:7: error: applyDynamic does not support passing a vararg parameter + qual.sel(a, a2: _*) + ^ +applydynamic_sip.scala:8: error: applyDynamicNamed does not support passing a vararg parameter + qual.sel(arg = a, a2: _*) + ^ +applydynamic_sip.scala:9: error: applyDynamicNamed does not support passing a vararg parameter + qual.sel(arg, arg2 = "a2", a2: _*) + ^ +three errors found diff --git a/test/files/neg/applydynamic_sip.scala b/test/files/neg/applydynamic_sip.scala new file mode 100644 index 0000000000..362461577b --- /dev/null +++ b/test/files/neg/applydynamic_sip.scala @@ -0,0 +1,10 @@ +object Test extends App { + val qual: Dynamic = ??? + val expr = "expr" + val a = "a" + val a2 = "a2" + + qual.sel(a, a2: _*) + qual.sel(arg = a, a2: _*) + qual.sel(arg, arg2 = "a2", a2: _*) +}
\ No newline at end of file diff --git a/test/files/neg/array-not-seq.check b/test/files/neg/array-not-seq.check index c16ecdad72..a3a639e772 100644 --- a/test/files/neg/array-not-seq.check +++ b/test/files/neg/array-not-seq.check @@ -1,7 +1,13 @@ array-not-seq.scala:2: error: An Array will no longer match as Seq[_]. def f1(x: Any) = x.isInstanceOf[Seq[_]] ^ -error: An Array will no longer match as Seq[_]. -error: An Array will no longer match as Seq[_]. -error: An Array will no longer match as Seq[_]. +array-not-seq.scala:4: error: An Array will no longer match as Seq[_]. + case _: Seq[_] => true + ^ +array-not-seq.scala:16: error: An Array will no longer match as Seq[_]. + case (Some(_: Seq[_]), Nil, _) => 1 + ^ +array-not-seq.scala:17: error: An Array will no longer match as Seq[_]. + case (None, List(_: List[_], _), _) => 2 + ^ four errors found diff --git a/test/files/neg/classtags_contextbound_a.check b/test/files/neg/classtags_contextbound_a.check index f4b6ff5af1..a4fd37506d 100644 --- a/test/files/neg/classtags_contextbound_a.check +++ b/test/files/neg/classtags_contextbound_a.check @@ -1,4 +1,4 @@ -classtags_contextbound_a.scala:2: error: No ClassTag available for T
+classtags_contextbound_a.scala:2: error: No ArrayTag available for T
def foo[T] = Array[T]()
^
one error found
diff --git a/test/files/neg/classtags_contextbound_c.check b/test/files/neg/classtags_contextbound_c.check index 54f630862a..a1c5eddfe1 100644 --- a/test/files/neg/classtags_contextbound_c.check +++ b/test/files/neg/classtags_contextbound_c.check @@ -1,4 +1,4 @@ -classtags_contextbound_c.scala:2: error: No ClassTag available for T
+classtags_contextbound_c.scala:2: error: No ArrayTag available for T
def mkArray[T] = Array[T]()
^
one error found
diff --git a/test/files/neg/classtags_dont_use_typetags.check b/test/files/neg/classtags_dont_use_typetags.check new file mode 100644 index 0000000000..c7d2fba35b --- /dev/null +++ b/test/files/neg/classtags_dont_use_typetags.check @@ -0,0 +1,4 @@ +classtags_dont_use_typetags.scala:2: error: No ArrayTag available for T
+ def foo[T: TypeTag] = Array[T]()
+ ^
+one error found
diff --git a/test/files/neg/classtags_dont_use_typetags.scala b/test/files/neg/classtags_dont_use_typetags.scala new file mode 100644 index 0000000000..0f675f71aa --- /dev/null +++ b/test/files/neg/classtags_dont_use_typetags.scala @@ -0,0 +1,3 @@ +object Test extends App { + def foo[T: TypeTag] = Array[T]() +}
\ No newline at end of file diff --git a/test/files/neg/dbldef.check b/test/files/neg/dbldef.check new file mode 100644 index 0000000000..3ee63475e4 --- /dev/null +++ b/test/files/neg/dbldef.check @@ -0,0 +1,14 @@ +dbldef.scala:1: error: x is already defined as value x +case class test0(x: Int, x: Float) + ^ +dbldef.scala:1: error: type mismatch; + found : Float + required: Int +case class test0(x: Int, x: Float) + ^ +dbldef.scala:1: error: type mismatch; + found : Float + required: Int +case class test0(x: Int, x: Float) + ^ +three errors found diff --git a/test/files/neg/dbldef.scala b/test/files/neg/dbldef.scala new file mode 100644 index 0000000000..c70fb97b2c --- /dev/null +++ b/test/files/neg/dbldef.scala @@ -0,0 +1 @@ +case class test0(x: Int, x: Float) diff --git a/test/files/neg/exhausting.check b/test/files/neg/exhausting.check index 0bef21e077..7140b99428 100644 --- a/test/files/neg/exhausting.check +++ b/test/files/neg/exhausting.check @@ -1,29 +1,25 @@ -exhausting.scala:20: error: match is not exhaustive! -missing combination * Nil - +exhausting.scala:21: error: match may not be exhaustive. +It would fail on the following input: List(_, _, _) def fail1[T](xs: List[T]) = xs match { ^ -exhausting.scala:24: error: match is not exhaustive! -missing combination Nil - +exhausting.scala:27: error: match may not be exhaustive. +It would fail on the following input: Nil def fail2[T](xs: List[T]) = xs match { ^ -exhausting.scala:27: error: match is not exhaustive! -missing combination Bar3 - +exhausting.scala:32: error: match may not be exhaustive. +It would fail on the following input: List(<not in (1, 2)>) + def fail3a(xs: List[Int]) = xs match { + ^ +exhausting.scala:39: error: match may not be exhaustive. +It would fail on the following input: Bar3 def fail3[T](x: Foo[T]) = x match { ^ -exhausting.scala:31: error: match is not exhaustive! -missing combination Bar2 Bar2 - +exhausting.scala:47: error: match may not be exhaustive. +It would fail on the following inputs: (Bar1, Bar2), (Bar1, Bar3), (Bar2, Bar1), (Bar2, Bar2) def fail4[T <: AnyRef](xx: (Foo[T], Foo[T])) = xx match { ^ -exhausting.scala:36: error: match is not exhaustive! -missing combination Bar1 Bar2 -missing combination Bar1 Bar3 -missing combination Bar2 Bar1 -missing combination Bar2 Bar2 - +exhausting.scala:56: error: match may not be exhaustive. +It would fail on the following inputs: (Bar1, Bar2), (Bar1, Bar3), (Bar2, Bar1), (Bar2, Bar2) def fail5[T](xx: (Foo[T], Foo[T])) = xx match { ^ -5 errors found +6 errors found diff --git a/test/files/neg/exhausting.flags b/test/files/neg/exhausting.flags index e8fb65d50c..85d8eb2ba2 100644 --- a/test/files/neg/exhausting.flags +++ b/test/files/neg/exhausting.flags @@ -1 +1 @@ --Xfatal-warnings
\ No newline at end of file +-Xfatal-warnings diff --git a/test/files/neg/exhausting.scala b/test/files/neg/exhausting.scala index 14b05695aa..5554ee2671 100644 --- a/test/files/neg/exhausting.scala +++ b/test/files/neg/exhausting.scala @@ -16,30 +16,46 @@ object Test { def ex3[T](xx: (Foo[T], Foo[T])) = xx match { case (_: Foo[_], _: Foo[_]) => () } - + + // fails for: ::(_, ::(_, ::(_, _))) def fail1[T](xs: List[T]) = xs match { case Nil => "ok" case x :: y :: Nil => "ok" } + + // fails for: Nil def fail2[T](xs: List[T]) = xs match { case _ :: _ => "ok" } + + // fails for: ::(<not in (2, 1)>, _) + def fail3a(xs: List[Int]) = xs match { + case 1 :: _ => + case 2 :: _ => + case Nil => + } + + // fails for: Bar3 def fail3[T](x: Foo[T]) = x match { case Bar1 => "ok" case Bar2 => "ok" } + // fails for: (Bar1, Bar2) + // fails for: (Bar1, Bar3) + // fails for: (Bar2, Bar2) + // fails for: (Bar2, Bar1) def fail4[T <: AnyRef](xx: (Foo[T], Foo[T])) = xx match { case (Bar1, Bar1) => () case (Bar2, Bar3) => () case (Bar3, _) => () } + // fails for: (Bar1, Bar2) + // fails for: (Bar1, Bar3) + // fails for: (Bar2, Bar1) + // fails for: (Bar2, Bar2) def fail5[T](xx: (Foo[T], Foo[T])) = xx match { case (Bar1, Bar1) => () case (Bar2, Bar3) => () case (Bar3, _) => () } - - def main(args: Array[String]): Unit = { - - } } diff --git a/test/files/neg/interop_classmanifests_arenot_concretetypetags.check b/test/files/neg/interop_classmanifests_arenot_concretetypetags.check new file mode 100644 index 0000000000..d6fa564df4 --- /dev/null +++ b/test/files/neg/interop_classmanifests_arenot_concretetypetags.check @@ -0,0 +1,4 @@ +interop_classmanifests_arenot_concretetypetags.scala:3: error: No ConcreteTypeTag available for T
+ println(concreteTypeTag[T])
+ ^
+one error found
diff --git a/test/files/neg/interop_classmanifests_arenot_concretetypetags.scala b/test/files/neg/interop_classmanifests_arenot_concretetypetags.scala new file mode 100644 index 0000000000..5b1ed55e47 --- /dev/null +++ b/test/files/neg/interop_classmanifests_arenot_concretetypetags.scala @@ -0,0 +1,9 @@ +object Test extends App { + def classManifestIsnotConcreteTypeTag[T: ClassManifest] = { + println(concreteTypeTag[T]) + } + + classManifestIsnotConcreteTypeTag[Int] + classManifestIsnotConcreteTypeTag[String] + classManifestIsnotConcreteTypeTag[Array[Int]] +}
\ No newline at end of file diff --git a/test/files/neg/interop_classtags_arenot_manifests.check b/test/files/neg/interop_classtags_arenot_manifests.check new file mode 100644 index 0000000000..95f6a94d4b --- /dev/null +++ b/test/files/neg/interop_classtags_arenot_manifests.check @@ -0,0 +1,7 @@ +interop_classtags_arenot_manifests.scala:3: error: No Manifest available for T.
+ println(manifest[T])
+ ^
+interop_classtags_arenot_manifests.scala:11: error: No Manifest available for T.
+ println(manifest[T])
+ ^
+two errors found
diff --git a/test/files/neg/interop_classtags_arenot_manifests.scala b/test/files/neg/interop_classtags_arenot_manifests.scala new file mode 100644 index 0000000000..7351f7e305 --- /dev/null +++ b/test/files/neg/interop_classtags_arenot_manifests.scala @@ -0,0 +1,17 @@ +object Test extends App { + def arrayTagIsnotManifest[T: ArrayTag] = { + println(manifest[T]) + } + + arrayTagIsnotManifest[Int] + arrayTagIsnotManifest[String] + arrayTagIsnotManifest[Array[Int]] + + def classTagIsnotManifest[T: ClassTag] = { + println(manifest[T]) + } + + classTagIsnotManifest[Int] + classTagIsnotManifest[String] + classTagIsnotManifest[Array[Int]] +}
\ No newline at end of file diff --git a/test/files/neg/interop_erasuretags_arenot_classmanifests.check b/test/files/neg/interop_erasuretags_arenot_classmanifests.check new file mode 100644 index 0000000000..4bb81108d1 --- /dev/null +++ b/test/files/neg/interop_erasuretags_arenot_classmanifests.check @@ -0,0 +1,4 @@ +interop_erasuretags_arenot_classmanifests.scala:3: error: could not find implicit value for parameter m: ClassManifest[T]
+ println(classManifest[T])
+ ^
+one error found
diff --git a/test/files/neg/interop_erasuretags_arenot_classmanifests.scala b/test/files/neg/interop_erasuretags_arenot_classmanifests.scala new file mode 100644 index 0000000000..cf7d1ac257 --- /dev/null +++ b/test/files/neg/interop_erasuretags_arenot_classmanifests.scala @@ -0,0 +1,9 @@ +object Test extends App { + def erasureTagIsnotClassManifest[T: ErasureTag] = { + println(classManifest[T]) + } + + erasureTagIsnotClassManifest[Int] + erasureTagIsnotClassManifest[String] + erasureTagIsnotClassManifest[Array[Int]] +}
\ No newline at end of file diff --git a/test/files/neg/interop_erasuretags_arenot_manifests.check b/test/files/neg/interop_erasuretags_arenot_manifests.check new file mode 100644 index 0000000000..da3c03d371 --- /dev/null +++ b/test/files/neg/interop_erasuretags_arenot_manifests.check @@ -0,0 +1,4 @@ +interop_erasuretags_arenot_manifests.scala:3: error: No Manifest available for T.
+ println(manifest[T])
+ ^
+one error found
diff --git a/test/files/neg/interop_erasuretags_arenot_manifests.scala b/test/files/neg/interop_erasuretags_arenot_manifests.scala new file mode 100644 index 0000000000..5c326549d8 --- /dev/null +++ b/test/files/neg/interop_erasuretags_arenot_manifests.scala @@ -0,0 +1,9 @@ +object Test extends App { + def erasureTagIsnotManifest[T: ErasureTag] = { + println(manifest[T]) + } + + erasureTagIsnotManifest[Int] + erasureTagIsnotManifest[String] + erasureTagIsnotManifest[Array[Int]] +}
\ No newline at end of file diff --git a/test/files/neg/interop_typetags_arenot_classmanifests.check b/test/files/neg/interop_typetags_arenot_classmanifests.check new file mode 100644 index 0000000000..9ed4fd43d4 --- /dev/null +++ b/test/files/neg/interop_typetags_arenot_classmanifests.check @@ -0,0 +1,4 @@ +interop_typetags_arenot_classmanifests.scala:3: error: could not find implicit value for parameter m: ClassManifest[T]
+ println(classManifest[T])
+ ^
+one error found
diff --git a/test/files/neg/interop_typetags_arenot_classmanifests.scala b/test/files/neg/interop_typetags_arenot_classmanifests.scala new file mode 100644 index 0000000000..b1fbb7b5a6 --- /dev/null +++ b/test/files/neg/interop_typetags_arenot_classmanifests.scala @@ -0,0 +1,9 @@ +object Test extends App { + def typeTagIsnotClassManifest[T: TypeTag] = { + println(classManifest[T]) + } + + typeTagIsnotClassManifest[Int] + typeTagIsnotClassManifest[String] + typeTagIsnotClassManifest[Array[Int]] +}
\ No newline at end of file diff --git a/test/files/neg/interop_typetags_arenot_manifests.check b/test/files/neg/interop_typetags_arenot_manifests.check new file mode 100644 index 0000000000..7761a747ff --- /dev/null +++ b/test/files/neg/interop_typetags_arenot_manifests.check @@ -0,0 +1,4 @@ +interop_typetags_arenot_manifests.scala:3: error: No Manifest available for T.
+ println(manifest[T])
+ ^
+one error found
diff --git a/test/files/neg/interop_typetags_arenot_manifests.scala b/test/files/neg/interop_typetags_arenot_manifests.scala new file mode 100644 index 0000000000..4e2a04489b --- /dev/null +++ b/test/files/neg/interop_typetags_arenot_manifests.scala @@ -0,0 +1,9 @@ +object Test extends App { + def typeTagIsnotManifest[T: TypeTag] = { + println(manifest[T]) + } + + typeTagIsnotManifest[Int] + typeTagIsnotManifest[String] + typeTagIsnotManifest[Array[Int]] +}
\ No newline at end of file diff --git a/test/files/neg/logImplicits.check b/test/files/neg/logImplicits.check index d98422dacb..54afc6f86d 100644 --- a/test/files/neg/logImplicits.check +++ b/test/files/neg/logImplicits.check @@ -1,16 +1,16 @@ -logImplicits.scala:2: applied implicit conversion from xs.type to ?{val size: ?} = implicit def byteArrayOps(xs: Array[Byte]): scala.collection.mutable.ArrayOps[Byte] +logImplicits.scala:2: applied implicit conversion from xs.type to ?{def size: ?} = implicit def byteArrayOps(xs: Array[Byte]): scala.collection.mutable.ArrayOps[Byte] def f(xs: Array[Byte]) = xs.size ^ -logImplicits.scala:7: applied implicit conversion from String("abc") to ?{val map: ?} = implicit def augmentString(x: String): scala.collection.immutable.StringOps +logImplicits.scala:7: applied implicit conversion from String("abc") to ?{def map: ?} = implicit def augmentString(x: String): scala.collection.immutable.StringOps def f = "abc" map (_ + 1) ^ logImplicits.scala:15: inferred view from String("abc") to Int = C.this.convert:(p: String("abc"))Int math.max(122, x: Int) ^ -logImplicits.scala:19: applied implicit conversion from Int(1) to ?{val ->: ?} = implicit def any2ArrowAssoc[A](x: A): ArrowAssoc[A] +logImplicits.scala:19: applied implicit conversion from Int(1) to ?{def ->: ?} = implicit def any2ArrowAssoc[A](x: A): ArrowAssoc[A] def f = (1 -> 2) + "c" ^ -logImplicits.scala:19: applied implicit conversion from (Int, Int) to ?{val +: ?} = implicit def any2stringadd(x: Any): scala.runtime.StringAdd +logImplicits.scala:19: applied implicit conversion from (Int, Int) to ?{def +: ?} = implicit def any2stringadd(x: Any): scala.runtime.StringAdd def f = (1 -> 2) + "c" ^ logImplicits.scala:22: error: class Un needs to be abstract, since method unimplemented is not defined diff --git a/test/files/neg/macro-argtype-mismatch.check b/test/files/neg/macro-argtype-mismatch.check deleted file mode 100644 index dd867be804..0000000000 --- a/test/files/neg/macro-argtype-mismatch.check +++ /dev/null @@ -1,6 +0,0 @@ -Test_2.scala:3: error: type mismatch;
- found : String("2")
- required: Int
- foo("2")
- ^
-one error found
diff --git a/test/files/neg/macro-argtype-mismatch.flags b/test/files/neg/macro-argtype-mismatch.flags deleted file mode 100644 index 7fea2ff901..0000000000 --- a/test/files/neg/macro-argtype-mismatch.flags +++ /dev/null @@ -1 +0,0 @@ --Xmacros
\ No newline at end of file diff --git a/test/files/neg/macro-basic-mamdmi.flags b/test/files/neg/macro-basic-mamdmi.flags index 06a7b31f11..5e5dd6ce79 100644 --- a/test/files/neg/macro-basic-mamdmi.flags +++ b/test/files/neg/macro-basic-mamdmi.flags @@ -1 +1 @@ --Xmacros +-language:experimental.macros diff --git a/test/files/neg/macro-cyclic.flags b/test/files/neg/macro-cyclic.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-cyclic.flags +++ b/test/files/neg/macro-cyclic.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-deprecate-dont-touch-backquotedidents.check b/test/files/neg/macro-deprecate-dont-touch-backquotedidents.check deleted file mode 100644 index 25df9a6a4a..0000000000 --- a/test/files/neg/macro-deprecate-dont-touch-backquotedidents.check +++ /dev/null @@ -1,10 +0,0 @@ -macro-deprecate-dont-touch-backquotedidents.scala:37: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
-package `macro` {
- ^
-macro-deprecate-dont-touch-backquotedidents.scala:38: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
- package `macro`.bar {
- ^
-macro-deprecate-dont-touch-backquotedidents.scala:43: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
- package `macro`.foo {
- ^
-three errors found
diff --git a/test/files/neg/macro-deprecate-idents.check b/test/files/neg/macro-deprecate-idents.check index bd685fc7b9..f8a7e519df 100644 --- a/test/files/neg/macro-deprecate-idents.check +++ b/test/files/neg/macro-deprecate-idents.check @@ -1,46 +1,52 @@ -macro-deprecate-idents.scala:2: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
+macro-deprecate-idents.scala:2: error: macro is now a reserved word; usage as an identifier is deprecated
val macro = ???
^
-macro-deprecate-idents.scala:6: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
+macro-deprecate-idents.scala:6: error: macro is now a reserved word; usage as an identifier is deprecated
var macro = ???
^
-macro-deprecate-idents.scala:10: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
+macro-deprecate-idents.scala:10: error: macro is now a reserved word; usage as an identifier is deprecated
type macro = Int
^
-macro-deprecate-idents.scala:14: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
+macro-deprecate-idents.scala:14: error: macro is now a reserved word; usage as an identifier is deprecated
class macro
^
-macro-deprecate-idents.scala:18: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
+macro-deprecate-idents.scala:18: error: macro is now a reserved word; usage as an identifier is deprecated
class macro
^
-macro-deprecate-idents.scala:22: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
+macro-deprecate-idents.scala:22: error: macro is now a reserved word; usage as an identifier is deprecated
object macro
^
-macro-deprecate-idents.scala:26: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
+macro-deprecate-idents.scala:26: error: macro is now a reserved word; usage as an identifier is deprecated
object macro
^
-macro-deprecate-idents.scala:30: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
+macro-deprecate-idents.scala:30: error: macro is now a reserved word; usage as an identifier is deprecated
trait macro
^
-macro-deprecate-idents.scala:34: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
+macro-deprecate-idents.scala:34: error: macro is now a reserved word; usage as an identifier is deprecated
trait macro
^
-macro-deprecate-idents.scala:37: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
+macro-deprecate-idents.scala:37: error: macro is now a reserved word; usage as an identifier is deprecated
package macro {
^
-macro-deprecate-idents.scala:38: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
+macro-deprecate-idents.scala:38: error: macro is now a reserved word; usage as an identifier is deprecated
package macro.bar {
^
-macro-deprecate-idents.scala:43: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
+macro-deprecate-idents.scala:43: error: macro is now a reserved word; usage as an identifier is deprecated
package macro.foo {
^
-macro-deprecate-idents.scala:48: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
+macro-deprecate-idents.scala:48: error: macro is now a reserved word; usage as an identifier is deprecated
val Some(macro) = Some(42)
^
-macro-deprecate-idents.scala:50: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
+macro-deprecate-idents.scala:49: error: macro is now a reserved word; usage as an identifier is deprecated
+ macro match {
+ ^
+macro-deprecate-idents.scala:50: error: macro is now a reserved word; usage as an identifier is deprecated
case macro => println(macro)
^
-macro-deprecate-idents.scala:55: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
+macro-deprecate-idents.scala:50: error: macro is now a reserved word; usage as an identifier is deprecated
+ case macro => println(macro)
+ ^
+macro-deprecate-idents.scala:55: error: macro is now a reserved word; usage as an identifier is deprecated
def macro = 2
^
-15 errors found
+17 errors found
diff --git a/test/files/neg/macro-invalidimpl-a.flags b/test/files/neg/macro-invalidimpl-a.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidimpl-a.flags +++ b/test/files/neg/macro-invalidimpl-a.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidimpl-b.flags b/test/files/neg/macro-invalidimpl-b.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidimpl-b.flags +++ b/test/files/neg/macro-invalidimpl-b.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidimpl-c.flags b/test/files/neg/macro-invalidimpl-c.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidimpl-c.flags +++ b/test/files/neg/macro-invalidimpl-c.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidimpl-d.flags b/test/files/neg/macro-invalidimpl-d.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidimpl-d.flags +++ b/test/files/neg/macro-invalidimpl-d.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidimpl-e.flags b/test/files/neg/macro-invalidimpl-e.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidimpl-e.flags +++ b/test/files/neg/macro-invalidimpl-e.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidimpl-f.flags b/test/files/neg/macro-invalidimpl-f.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidimpl-f.flags +++ b/test/files/neg/macro-invalidimpl-f.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidimpl-g.flags b/test/files/neg/macro-invalidimpl-g.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidimpl-g.flags +++ b/test/files/neg/macro-invalidimpl-g.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidimpl-h.flags b/test/files/neg/macro-invalidimpl-h.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidimpl-h.flags +++ b/test/files/neg/macro-invalidimpl-h.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidret-nontree.check b/test/files/neg/macro-invalidret-nontree.check index 7fcc396463..0b793cf421 100644 --- a/test/files/neg/macro-invalidret-nontree.check +++ b/test/files/neg/macro-invalidret-nontree.check @@ -1,7 +1,7 @@ -Macros_Test_2.scala:2: error: macro implementation has wrong shape: - required: (c: scala.reflect.makro.Context): c.Expr[Any] - found : (c: scala.reflect.makro.Context): Int -type mismatch for return type : c.Expr[Any] does not conform to Int - def foo = macro Impls.foo - ^ -one error found +Macros_Test_2.scala:2: error: macro implementation has wrong shape:
+ required: (c: scala.reflect.makro.Context): c.Expr[Any]
+ found : (c: scala.reflect.makro.Context): Int
+type mismatch for return type: Int does not conform to c.Expr[Any]
+ def foo = macro Impls.foo
+ ^
+one error found
diff --git a/test/files/neg/macro-invalidret-nontree.flags b/test/files/neg/macro-invalidret-nontree.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidret-nontree.flags +++ b/test/files/neg/macro-invalidret-nontree.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidret-nonuniversetree.check b/test/files/neg/macro-invalidret-nonuniversetree.check index a97d6daaa9..4fc06b5ceb 100644 --- a/test/files/neg/macro-invalidret-nonuniversetree.check +++ b/test/files/neg/macro-invalidret-nonuniversetree.check @@ -1,7 +1,7 @@ -Macros_Test_2.scala:2: error: macro implementation has wrong shape: - required: (c: scala.reflect.makro.Context): c.Expr[Any] - found : (c: scala.reflect.makro.Context): reflect.mirror.Literal -type mismatch for return type : c.Expr[Any] does not conform to reflect.mirror.Literal - def foo = macro Impls.foo - ^ -one error found +Macros_Test_2.scala:2: error: macro implementation has wrong shape:
+ required: (c: scala.reflect.makro.Context): c.Expr[Any]
+ found : (c: scala.reflect.makro.Context): reflect.mirror.Literal
+type mismatch for return type: reflect.mirror.Literal does not conform to c.Expr[Any]
+ def foo = macro Impls.foo
+ ^
+one error found
diff --git a/test/files/neg/macro-invalidret-nonuniversetree.flags b/test/files/neg/macro-invalidret-nonuniversetree.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidret-nonuniversetree.flags +++ b/test/files/neg/macro-invalidret-nonuniversetree.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidshape-a.flags b/test/files/neg/macro-invalidshape-a.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidshape-a.flags +++ b/test/files/neg/macro-invalidshape-a.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidshape-b.flags b/test/files/neg/macro-invalidshape-b.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidshape-b.flags +++ b/test/files/neg/macro-invalidshape-b.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidshape-c.flags b/test/files/neg/macro-invalidshape-c.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidshape-c.flags +++ b/test/files/neg/macro-invalidshape-c.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidshape-d.check b/test/files/neg/macro-invalidshape-d.check index 031aa653ab..f0d77e2f2d 100644 --- a/test/files/neg/macro-invalidshape-d.check +++ b/test/files/neg/macro-invalidshape-d.check @@ -1,4 +1,8 @@ -Macros_Test_2.scala:2: error: illegal start of statement
+Macros_Test_2.scala:2: warning: macro is now a reserved word; usage as an identifier is deprecated
def foo(x: Any) = {2; macro Impls.foo}
^
+Macros_Test_2.scala:2: error: ';' expected but '.' found.
+ def foo(x: Any) = {2; macro Impls.foo}
+ ^
+one warning found
one error found
diff --git a/test/files/neg/macro-invalidshape-d.flags b/test/files/neg/macro-invalidshape-d.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidshape-d.flags +++ b/test/files/neg/macro-invalidshape-d.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-context-bounds.check b/test/files/neg/macro-invalidsig-context-bounds.check index dd68e5db1b..0401993335 100644 --- a/test/files/neg/macro-invalidsig-context-bounds.check +++ b/test/files/neg/macro-invalidsig-context-bounds.check @@ -1,4 +1,4 @@ -Impls_1.scala:4: error: macro implementations cannot have implicit parameters other than TypeTag evidences
- def foo[U: c.TypeTag: Numeric](c: Ctx) = {
- ^
-one error found
+Impls_1.scala:4: error: macro implementations cannot have implicit parameters other than TypeTag evidences + def foo[U: c.TypeTag: Numeric](c: Ctx) = { + ^ +one error found diff --git a/test/files/neg/macro-invalidsig-context-bounds.flags b/test/files/neg/macro-invalidsig-context-bounds.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-context-bounds.flags +++ b/test/files/neg/macro-invalidsig-context-bounds.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-context-bounds/Macros_Test_2.scala b/test/files/neg/macro-invalidsig-context-bounds/Macros_Test_1.scala index 5b4602f328..5b4602f328 100644 --- a/test/files/neg/macro-invalidsig-context-bounds/Macros_Test_2.scala +++ b/test/files/neg/macro-invalidsig-context-bounds/Macros_Test_1.scala diff --git a/test/files/neg/macro-invalidsig-ctx-badargc.flags b/test/files/neg/macro-invalidsig-ctx-badargc.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-ctx-badargc.flags +++ b/test/files/neg/macro-invalidsig-ctx-badargc.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-ctx-badtype.flags b/test/files/neg/macro-invalidsig-ctx-badtype.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-ctx-badtype.flags +++ b/test/files/neg/macro-invalidsig-ctx-badtype.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-ctx-badvarargs.flags b/test/files/neg/macro-invalidsig-ctx-badvarargs.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-ctx-badvarargs.flags +++ b/test/files/neg/macro-invalidsig-ctx-badvarargs.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-ctx-noctx.flags b/test/files/neg/macro-invalidsig-ctx-noctx.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-ctx-noctx.flags +++ b/test/files/neg/macro-invalidsig-ctx-noctx.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-implicit-params.flags b/test/files/neg/macro-invalidsig-implicit-params.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-implicit-params.flags +++ b/test/files/neg/macro-invalidsig-implicit-params.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-params-badargc.flags b/test/files/neg/macro-invalidsig-params-badargc.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-params-badargc.flags +++ b/test/files/neg/macro-invalidsig-params-badargc.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-params-badtype.flags b/test/files/neg/macro-invalidsig-params-badtype.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-params-badtype.flags +++ b/test/files/neg/macro-invalidsig-params-badtype.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-params-badvarargs.flags b/test/files/neg/macro-invalidsig-params-badvarargs.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-params-badvarargs.flags +++ b/test/files/neg/macro-invalidsig-params-badvarargs.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-params-namemismatch.flags b/test/files/neg/macro-invalidsig-params-namemismatch.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-params-namemismatch.flags +++ b/test/files/neg/macro-invalidsig-params-namemismatch.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-tparams-badtype.flags b/test/files/neg/macro-invalidsig-tparams-badtype.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-tparams-badtype.flags +++ b/test/files/neg/macro-invalidsig-tparams-badtype.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-tparams-bounds-a.flags b/test/files/neg/macro-invalidsig-tparams-bounds-a.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-tparams-bounds-a.flags +++ b/test/files/neg/macro-invalidsig-tparams-bounds-a.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-tparams-bounds-b.flags b/test/files/neg/macro-invalidsig-tparams-bounds-b.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-tparams-bounds-b.flags +++ b/test/files/neg/macro-invalidsig-tparams-bounds-b.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-a.flags b/test/files/neg/macro-invalidsig-tparams-notparams-a.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-a.flags +++ b/test/files/neg/macro-invalidsig-tparams-notparams-a.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-b.flags b/test/files/neg/macro-invalidsig-tparams-notparams-b.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-b.flags +++ b/test/files/neg/macro-invalidsig-tparams-notparams-b.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-b/Impls_1.scala b/test/files/neg/macro-invalidsig-tparams-notparams-b/Impls_1.scala index 7bc46ff876..db79ddbcd8 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-b/Impls_1.scala +++ b/test/files/neg/macro-invalidsig-tparams-notparams-b/Impls_1.scala @@ -2,10 +2,9 @@ import scala.reflect.makro.{Context => Ctx} object Impls { def foo[T: c.TypeTag, U: c.TypeTag, V](c: Ctx)(implicit V: c.TypeTag[V]): c.Expr[Unit] = { - import c.mirror._ println(implicitly[c.TypeTag[T]]) println(implicitly[c.TypeTag[U]]) println(V) - Literal(Constant(())) + c.literalUnit } } diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-c.flags b/test/files/neg/macro-invalidsig-tparams-notparams-c.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-c.flags +++ b/test/files/neg/macro-invalidsig-tparams-notparams-c.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-c/Impls_1.scala b/test/files/neg/macro-invalidsig-tparams-notparams-c/Impls_1.scala index 7bc46ff876..43c5a2acd5 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-c/Impls_1.scala +++ b/test/files/neg/macro-invalidsig-tparams-notparams-c/Impls_1.scala @@ -6,6 +6,6 @@ object Impls { println(implicitly[c.TypeTag[T]]) println(implicitly[c.TypeTag[U]]) println(V) - Literal(Constant(())) + c.literalUnit } } diff --git a/test/files/neg/macro-invalidusage-badargs.flags b/test/files/neg/macro-invalidusage-badargs.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidusage-badargs.flags +++ b/test/files/neg/macro-invalidusage-badargs.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidusage-badbounds.flags b/test/files/neg/macro-invalidusage-badbounds.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidusage-badbounds.flags +++ b/test/files/neg/macro-invalidusage-badbounds.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidusage-badtargs.flags b/test/files/neg/macro-invalidusage-badtargs.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidusage-badtargs.flags +++ b/test/files/neg/macro-invalidusage-badtargs.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidusage-methodvaluesyntax.flags b/test/files/neg/macro-invalidusage-methodvaluesyntax.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidusage-methodvaluesyntax.flags +++ b/test/files/neg/macro-invalidusage-methodvaluesyntax.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-bind.check b/test/files/neg/macro-keyword-bind.check deleted file mode 100644 index 1f74cfe5cd..0000000000 --- a/test/files/neg/macro-keyword-bind.check +++ /dev/null @@ -1,7 +0,0 @@ -macro-keyword-bind.scala:2: error: illegal start of simple pattern
- val Some(macro) = Some(42)
- ^
-macro-keyword-bind.scala:6: error: ')' expected but '}' found.
-}
-^
-two errors found
diff --git a/test/files/neg/macro-keyword-bind.flags b/test/files/neg/macro-keyword-bind.flags deleted file mode 100644 index 7fea2ff901..0000000000 --- a/test/files/neg/macro-keyword-bind.flags +++ /dev/null @@ -1 +0,0 @@ --Xmacros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-bind.scala b/test/files/neg/macro-keyword-bind.scala deleted file mode 100644 index a3b1553348..0000000000 --- a/test/files/neg/macro-keyword-bind.scala +++ /dev/null @@ -1,6 +0,0 @@ -object Test12 { - val Some(macro) = Some(42) - macro match { - case macro => println(macro) - } -}
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-class1.check b/test/files/neg/macro-keyword-class1.check deleted file mode 100644 index d8983180ef..0000000000 --- a/test/files/neg/macro-keyword-class1.check +++ /dev/null @@ -1,4 +0,0 @@ -macro-keyword-class1.scala:3: error: identifier expected but 'macro' found.
-class macro
- ^
-one error found
diff --git a/test/files/neg/macro-keyword-class1.flags b/test/files/neg/macro-keyword-class1.flags deleted file mode 100644 index 7fea2ff901..0000000000 --- a/test/files/neg/macro-keyword-class1.flags +++ /dev/null @@ -1 +0,0 @@ --Xmacros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-class1.scala b/test/files/neg/macro-keyword-class1.scala deleted file mode 100644 index 8635d1f4f6..0000000000 --- a/test/files/neg/macro-keyword-class1.scala +++ /dev/null @@ -1,3 +0,0 @@ -package test4 - -class macro diff --git a/test/files/neg/macro-keyword-class2.check b/test/files/neg/macro-keyword-class2.check deleted file mode 100644 index 0e4d11bcc4..0000000000 --- a/test/files/neg/macro-keyword-class2.check +++ /dev/null @@ -1,4 +0,0 @@ -macro-keyword-class2.scala:2: error: identifier expected but 'macro' found.
- class macro
- ^
-one error found
diff --git a/test/files/neg/macro-keyword-class2.flags b/test/files/neg/macro-keyword-class2.flags deleted file mode 100644 index 7fea2ff901..0000000000 --- a/test/files/neg/macro-keyword-class2.flags +++ /dev/null @@ -1 +0,0 @@ --Xmacros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-class2.scala b/test/files/neg/macro-keyword-class2.scala deleted file mode 100644 index af24a489d0..0000000000 --- a/test/files/neg/macro-keyword-class2.scala +++ /dev/null @@ -1,3 +0,0 @@ -object Test5 { - class macro -} diff --git a/test/files/neg/macro-keyword-object1.check b/test/files/neg/macro-keyword-object1.check deleted file mode 100644 index cfbd06ffd6..0000000000 --- a/test/files/neg/macro-keyword-object1.check +++ /dev/null @@ -1,4 +0,0 @@ -macro-keyword-object1.scala:3: error: identifier expected but 'macro' found.
-object macro
- ^
-one error found
diff --git a/test/files/neg/macro-keyword-object1.flags b/test/files/neg/macro-keyword-object1.flags deleted file mode 100644 index 7fea2ff901..0000000000 --- a/test/files/neg/macro-keyword-object1.flags +++ /dev/null @@ -1 +0,0 @@ --Xmacros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-object1.scala b/test/files/neg/macro-keyword-object1.scala deleted file mode 100644 index 66eb494e6b..0000000000 --- a/test/files/neg/macro-keyword-object1.scala +++ /dev/null @@ -1,3 +0,0 @@ -package test6 - -object macro diff --git a/test/files/neg/macro-keyword-object2.check b/test/files/neg/macro-keyword-object2.check deleted file mode 100644 index ede31f13e5..0000000000 --- a/test/files/neg/macro-keyword-object2.check +++ /dev/null @@ -1,4 +0,0 @@ -macro-keyword-object2.scala:2: error: identifier expected but 'macro' found.
- object macro
- ^
-one error found
diff --git a/test/files/neg/macro-keyword-object2.flags b/test/files/neg/macro-keyword-object2.flags deleted file mode 100644 index 7fea2ff901..0000000000 --- a/test/files/neg/macro-keyword-object2.flags +++ /dev/null @@ -1 +0,0 @@ --Xmacros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-object2.scala b/test/files/neg/macro-keyword-object2.scala deleted file mode 100644 index 6f5b9ceacd..0000000000 --- a/test/files/neg/macro-keyword-object2.scala +++ /dev/null @@ -1,3 +0,0 @@ -object Test7 { - object macro -} diff --git a/test/files/neg/macro-keyword-package1.check b/test/files/neg/macro-keyword-package1.check deleted file mode 100644 index 22c1e11ded..0000000000 --- a/test/files/neg/macro-keyword-package1.check +++ /dev/null @@ -1,4 +0,0 @@ -macro-keyword-package1.scala:1: error: identifier expected but 'macro' found.
-package macro
- ^
-one error found
diff --git a/test/files/neg/macro-keyword-package1.flags b/test/files/neg/macro-keyword-package1.flags deleted file mode 100644 index 7fea2ff901..0000000000 --- a/test/files/neg/macro-keyword-package1.flags +++ /dev/null @@ -1 +0,0 @@ --Xmacros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-package1.scala b/test/files/neg/macro-keyword-package1.scala deleted file mode 100644 index 52d3fbabf6..0000000000 --- a/test/files/neg/macro-keyword-package1.scala +++ /dev/null @@ -1,3 +0,0 @@ -package macro - -package macro.bar
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-package2.check b/test/files/neg/macro-keyword-package2.check deleted file mode 100644 index 0cb542a85d..0000000000 --- a/test/files/neg/macro-keyword-package2.check +++ /dev/null @@ -1,4 +0,0 @@ -macro-keyword-package2.scala:3: error: identifier expected but 'macro' found.
-package macro.foo
- ^
-one error found
diff --git a/test/files/neg/macro-keyword-package2.flags b/test/files/neg/macro-keyword-package2.flags deleted file mode 100644 index 7fea2ff901..0000000000 --- a/test/files/neg/macro-keyword-package2.flags +++ /dev/null @@ -1 +0,0 @@ --Xmacros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-package2.scala b/test/files/neg/macro-keyword-package2.scala deleted file mode 100644 index a68ebd935f..0000000000 --- a/test/files/neg/macro-keyword-package2.scala +++ /dev/null @@ -1,3 +0,0 @@ -package foo - -package macro.foo diff --git a/test/files/neg/macro-keyword-trait1.check b/test/files/neg/macro-keyword-trait1.check deleted file mode 100644 index 9586a62e08..0000000000 --- a/test/files/neg/macro-keyword-trait1.check +++ /dev/null @@ -1,4 +0,0 @@ -macro-keyword-trait1.scala:3: error: identifier expected but 'macro' found.
-trait macro
- ^
-one error found
diff --git a/test/files/neg/macro-keyword-trait1.flags b/test/files/neg/macro-keyword-trait1.flags deleted file mode 100644 index 7fea2ff901..0000000000 --- a/test/files/neg/macro-keyword-trait1.flags +++ /dev/null @@ -1 +0,0 @@ --Xmacros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-trait1.scala b/test/files/neg/macro-keyword-trait1.scala deleted file mode 100644 index e32d4c1385..0000000000 --- a/test/files/neg/macro-keyword-trait1.scala +++ /dev/null @@ -1,3 +0,0 @@ -package test8 - -trait macro diff --git a/test/files/neg/macro-keyword-trait2.check b/test/files/neg/macro-keyword-trait2.check deleted file mode 100644 index 40aa764378..0000000000 --- a/test/files/neg/macro-keyword-trait2.check +++ /dev/null @@ -1,4 +0,0 @@ -macro-keyword-trait2.scala:2: error: identifier expected but 'macro' found.
- trait macro
- ^
-one error found
diff --git a/test/files/neg/macro-keyword-trait2.flags b/test/files/neg/macro-keyword-trait2.flags deleted file mode 100644 index 7fea2ff901..0000000000 --- a/test/files/neg/macro-keyword-trait2.flags +++ /dev/null @@ -1 +0,0 @@ --Xmacros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-trait2.scala b/test/files/neg/macro-keyword-trait2.scala deleted file mode 100644 index 243a54abe6..0000000000 --- a/test/files/neg/macro-keyword-trait2.scala +++ /dev/null @@ -1,3 +0,0 @@ -object Test9 { - trait macro -} diff --git a/test/files/neg/macro-keyword-type.check b/test/files/neg/macro-keyword-type.check deleted file mode 100644 index 4a7481114c..0000000000 --- a/test/files/neg/macro-keyword-type.check +++ /dev/null @@ -1,4 +0,0 @@ -macro-keyword-type.scala:2: error: identifier expected but 'macro' found.
- type macro = Int
- ^
-one error found
diff --git a/test/files/neg/macro-keyword-type.flags b/test/files/neg/macro-keyword-type.flags deleted file mode 100644 index 7fea2ff901..0000000000 --- a/test/files/neg/macro-keyword-type.flags +++ /dev/null @@ -1 +0,0 @@ --Xmacros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-type.scala b/test/files/neg/macro-keyword-type.scala deleted file mode 100644 index 30e523bcaf..0000000000 --- a/test/files/neg/macro-keyword-type.scala +++ /dev/null @@ -1,3 +0,0 @@ -object Test3 { - type macro = Int -}
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-val.check b/test/files/neg/macro-keyword-val.check deleted file mode 100644 index 0dc4c030a9..0000000000 --- a/test/files/neg/macro-keyword-val.check +++ /dev/null @@ -1,7 +0,0 @@ -macro-keyword-val.scala:2: error: illegal start of simple pattern
- val macro = ???
- ^
-macro-keyword-val.scala:3: error: '=' expected but '}' found.
-}
-^
-two errors found
diff --git a/test/files/neg/macro-keyword-val.flags b/test/files/neg/macro-keyword-val.flags deleted file mode 100644 index 7fea2ff901..0000000000 --- a/test/files/neg/macro-keyword-val.flags +++ /dev/null @@ -1 +0,0 @@ --Xmacros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-val.scala b/test/files/neg/macro-keyword-val.scala deleted file mode 100644 index 96f57acb30..0000000000 --- a/test/files/neg/macro-keyword-val.scala +++ /dev/null @@ -1,3 +0,0 @@ -object Test1 { - val macro = ??? -}
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-var.check b/test/files/neg/macro-keyword-var.check deleted file mode 100644 index 96d02e0052..0000000000 --- a/test/files/neg/macro-keyword-var.check +++ /dev/null @@ -1,7 +0,0 @@ -macro-keyword-var.scala:2: error: illegal start of simple pattern
- var macro = ???
- ^
-macro-keyword-var.scala:3: error: '=' expected but '}' found.
-}
-^
-two errors found
diff --git a/test/files/neg/macro-keyword-var.flags b/test/files/neg/macro-keyword-var.flags deleted file mode 100644 index 7fea2ff901..0000000000 --- a/test/files/neg/macro-keyword-var.flags +++ /dev/null @@ -1 +0,0 @@ --Xmacros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-var.scala b/test/files/neg/macro-keyword-var.scala deleted file mode 100644 index a79dda6dc2..0000000000 --- a/test/files/neg/macro-keyword-var.scala +++ /dev/null @@ -1,3 +0,0 @@ -object Test2 { - var macro = ??? -}
\ No newline at end of file diff --git a/test/files/neg/macro-noexpand.flags b/test/files/neg/macro-noexpand.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-noexpand.flags +++ b/test/files/neg/macro-noexpand.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-noncompilertree.check b/test/files/neg/macro-noncompilertree.check deleted file mode 100644 index 616765a39e..0000000000 --- a/test/files/neg/macro-noncompilertree.check +++ /dev/null @@ -1,6 +0,0 @@ -Macros_1.scala:2: error: type mismatch;
- found : reflect.mirror.Literal
- required: _context.Tree
- def macro foo = scala.reflect.mirror.Literal(scala.reflect.mirror.Constant(2))
- ^
-one error found
diff --git a/test/files/neg/macro-noncompilertree.flags b/test/files/neg/macro-noncompilertree.flags deleted file mode 100644 index 7fea2ff901..0000000000 --- a/test/files/neg/macro-noncompilertree.flags +++ /dev/null @@ -1 +0,0 @@ --Xmacros
\ No newline at end of file diff --git a/test/files/neg/macro-nontree.check b/test/files/neg/macro-nontree.check deleted file mode 100644 index a1c7139580..0000000000 --- a/test/files/neg/macro-nontree.check +++ /dev/null @@ -1,6 +0,0 @@ -Macros_1.scala:2: error: type mismatch;
- found : Int(2)
- required: _context.Tree
- def macro foo = 2
- ^
-one error found
diff --git a/test/files/neg/macro-nontree.flags b/test/files/neg/macro-nontree.flags deleted file mode 100644 index 7fea2ff901..0000000000 --- a/test/files/neg/macro-nontree.flags +++ /dev/null @@ -1 +0,0 @@ --Xmacros
\ No newline at end of file diff --git a/test/files/neg/macro-nontypeablebody.flags b/test/files/neg/macro-nontypeablebody.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-nontypeablebody.flags +++ b/test/files/neg/macro-nontypeablebody.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-override-macro-overrides-abstract-method-a.flags b/test/files/neg/macro-override-macro-overrides-abstract-method-a.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-override-macro-overrides-abstract-method-a.flags +++ b/test/files/neg/macro-override-macro-overrides-abstract-method-a.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-override-macro-overrides-abstract-method-b.flags b/test/files/neg/macro-override-macro-overrides-abstract-method-b.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-override-macro-overrides-abstract-method-b.flags +++ b/test/files/neg/macro-override-macro-overrides-abstract-method-b.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-override-method-overrides-macro.flags b/test/files/neg/macro-override-method-overrides-macro.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-override-method-overrides-macro.flags +++ b/test/files/neg/macro-override-method-overrides-macro.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-without-xmacros-a.check b/test/files/neg/macro-without-xmacros-a.check index a3ca081f04..fd2667dbb8 100644 --- a/test/files/neg/macro-without-xmacros-a.check +++ b/test/files/neg/macro-without-xmacros-a.check @@ -1,10 +1,17 @@ -Macros_2.scala:5: error: not found: value macro
+Macros_2.scala:5: error: macro definition needs to be enabled
+by making the implicit value language.experimental.macros visible.
+This can be achieved by adding the import clause 'import language.experimental.macros'
+or by setting the compiler option -language:experimental.macros.
+See the Scala docs for value scala.language.experimental.macros for a discussion
+why the feature needs to be explicitly enabled.
def foo(x: Int): Int = macro foo_impl
- ^
-Macros_2.scala:7: error: not found: value macro
+ ^
+Macros_2.scala:7: error: macro definition needs to be enabled
+by making the implicit value language.experimental.macros visible.
def bar(x: Int): Int = macro bar_impl
- ^
-Macros_2.scala:11: error: not found: value macro
+ ^
+Macros_2.scala:11: error: macro definition needs to be enabled
+by making the implicit value language.experimental.macros visible.
def quux(x: Int): Int = macro quux_impl
- ^
+ ^
three errors found
diff --git a/test/files/neg/macro-without-xmacros-a/Impls_1.scala b/test/files/neg/macro-without-xmacros-a/Impls_1.scala index 2493c81c95..e6cee46e85 100644 --- a/test/files/neg/macro-without-xmacros-a/Impls_1.scala +++ b/test/files/neg/macro-without-xmacros-a/Impls_1.scala @@ -1,18 +1,18 @@ import scala.reflect.makro.{Context => Ctx} object Impls { - def foo_impl(c: Ctx)(x: c.Expr[Int]): c.mirror.Tree = { + def foo_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.mirror._ - Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))) + Expr(Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1))))) } - def bar_impl(c: Ctx)(x: c.Expr[Int]): c.mirror.Tree = { + def bar_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.mirror._ - Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2)))) + Expr(Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2))))) } - def quux_impl(c: Ctx)(x: c.Expr[Int]): c.mirror.Tree = { + def quux_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.mirror._ - Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3)))) + Expr(Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3))))) } } diff --git a/test/files/neg/macro-without-xmacros-b.check b/test/files/neg/macro-without-xmacros-b.check index dce4a084c9..2d675b8319 100644 --- a/test/files/neg/macro-without-xmacros-b.check +++ b/test/files/neg/macro-without-xmacros-b.check @@ -1,10 +1,17 @@ -Macros_2.scala:3: error: ';' expected but '.' found.
+Macros_2.scala:3: error: macro definition needs to be enabled
+by making the implicit value language.experimental.macros visible.
+This can be achieved by adding the import clause 'import language.experimental.macros'
+or by setting the compiler option -language:experimental.macros.
+See the Scala docs for value scala.language.experimental.macros for a discussion
+why the feature needs to be explicitly enabled.
def foo(x: Int): Int = macro Impls.foo_impl
- ^
-Macros_2.scala:5: error: ';' expected but '.' found.
+ ^
+Macros_2.scala:5: error: macro definition needs to be enabled
+by making the implicit value language.experimental.macros visible.
def bar(x: Int): Int = macro Impls.bar_impl
- ^
-Macros_2.scala:9: error: ';' expected but '.' found.
+ ^
+Macros_2.scala:9: error: macro definition needs to be enabled
+by making the implicit value language.experimental.macros visible.
def quux(x: Int): Int = macro Impls.quux_impl
- ^
+ ^
three errors found
diff --git a/test/files/neg/macro-without-xmacros-b/Impls_1.scala b/test/files/neg/macro-without-xmacros-b/Impls_1.scala index 2493c81c95..e6cee46e85 100644 --- a/test/files/neg/macro-without-xmacros-b/Impls_1.scala +++ b/test/files/neg/macro-without-xmacros-b/Impls_1.scala @@ -1,18 +1,18 @@ import scala.reflect.makro.{Context => Ctx} object Impls { - def foo_impl(c: Ctx)(x: c.Expr[Int]): c.mirror.Tree = { + def foo_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.mirror._ - Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))) + Expr(Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1))))) } - def bar_impl(c: Ctx)(x: c.Expr[Int]): c.mirror.Tree = { + def bar_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.mirror._ - Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2)))) + Expr(Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2))))) } - def quux_impl(c: Ctx)(x: c.Expr[Int]): c.mirror.Tree = { + def quux_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.mirror._ - Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3)))) + Expr(Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3))))) } } diff --git a/test/files/neg/names-defaults-neg.check b/test/files/neg/names-defaults-neg.check index 01bbe2de4e..2809350855 100644 --- a/test/files/neg/names-defaults-neg.check +++ b/test/files/neg/names-defaults-neg.check @@ -28,10 +28,10 @@ names-defaults-neg.scala:18: error: not found: value m names-defaults-neg.scala:19: error: reference to x is ambiguous; it is both a method parameter and a variable in scope. test8(x = 1) ^ -names-defaults-neg.scala:22: error: parameter specified twice: a +names-defaults-neg.scala:22: error: parameter 'a' is already specified at parameter position 1 test1(1, a = 2) ^ -names-defaults-neg.scala:23: error: parameter specified twice: b +names-defaults-neg.scala:23: error: parameter 'b' is already specified at parameter position 1 test1(b = 1, b = "2") ^ names-defaults-neg.scala:26: error: Int does not take parameters @@ -61,10 +61,10 @@ and method g in object t7 of type (a: C, b: Int*)String match argument types (C) t7.g(new C()) // ambigous reference ^ -names-defaults-neg.scala:53: error: parameter specified twice: b +names-defaults-neg.scala:53: error: parameter 'b' is already specified at parameter position 2 test5(a = 1, b = "dkjl", b = "dkj") ^ -names-defaults-neg.scala:54: error: parameter specified twice: b +names-defaults-neg.scala:54: error: parameter 'b' is already specified at parameter position 2 test5(1, "2", b = 3) ^ names-defaults-neg.scala:55: error: when using named arguments, the vararg parameter has to be specified exactly once @@ -110,7 +110,7 @@ names-defaults-neg.scala:91: error: deprecated parameter name a has to be distin names-defaults-neg.scala:93: warning: the parameter name y has been deprecated. Use b instead. deprNam3(y = 10, b = 2) ^ -names-defaults-neg.scala:93: error: parameter specified twice: b +names-defaults-neg.scala:93: error: parameter 'b' is already specified at parameter position 1 deprNam3(y = 10, b = 2) ^ names-defaults-neg.scala:98: error: unknown parameter name: m @@ -122,7 +122,7 @@ names-defaults-neg.scala:131: error: reference to var2 is ambiguous; it is both names-defaults-neg.scala:134: error: missing parameter type for expanded function ((x$1) => a = x$1) val taf2: Int => Unit = testAnnFun(a = _, b = get("+")) ^ -names-defaults-neg.scala:135: error: parameter specified twice: a +names-defaults-neg.scala:135: error: parameter 'a' is already specified at parameter position 1 val taf3 = testAnnFun(b = _: String, a = get(8)) ^ names-defaults-neg.scala:136: error: wrong number of parameters; expected = 2 @@ -149,8 +149,12 @@ names-defaults-neg.scala:170: error: reference to x is ambiguous; it is both a m names-defaults-neg.scala:177: error: variable definition needs type because 'x' is used as a named argument in its body. class u15 { var x = u.f(x = 1) } ^ +names-defaults-neg.scala:177: warning: type-checking the invocation of method f checks if the named argument expression 'x = ...' is a valid assignment +in the current scope. The resulting type inference error (see above) can be fixed by providing an explicit type in the local definition for x. + class u15 { var x = u.f(x = 1) } + ^ names-defaults-neg.scala:180: error: reference to x is ambiguous; it is both a method parameter and a variable in scope. class u18 { var x: Int = u.f(x = 1) } ^ -one warning found +two warnings found 41 errors found diff --git a/test/files/neg/overloaded-unapply.check b/test/files/neg/overloaded-unapply.check index 1da93f6939..68a826bac2 100644 --- a/test/files/neg/overloaded-unapply.check +++ b/test/files/neg/overloaded-unapply.check @@ -7,7 +7,8 @@ match argument types (List[a]) overloaded-unapply.scala:22: error: cannot resolve overloaded unapply case List(x, xs) => 7 ^ -overloaded-unapply.scala:12: error: method unapply is defined twice in overloaded-unapply.scala +overloaded-unapply.scala:12: error: method unapply is defined twice + conflicting symbols both originated in file 'overloaded-unapply.scala' def unapply[a](xs: List[a]): Option[Null] = xs match { ^ three errors found diff --git a/test/files/neg/override.check b/test/files/neg/override.check index 0336fb2b11..fc152cb3b1 100644 --- a/test/files/neg/override.check +++ b/test/files/neg/override.check @@ -1,5 +1,5 @@ override.scala:9: error: overriding type T in trait A with bounds >: Int <: Int; type T in trait B with bounds >: String <: String has incompatible type lazy val x : A with B = x - ^ + ^ one error found diff --git a/test/files/neg/package-ob-case.flags b/test/files/neg/package-ob-case.flags index e8fb65d50c..6c1dd108ae 100644 --- a/test/files/neg/package-ob-case.flags +++ b/test/files/neg/package-ob-case.flags @@ -1 +1 @@ --Xfatal-warnings
\ No newline at end of file +-Xfatal-warnings -Xlint
\ No newline at end of file diff --git a/test/files/neg/pat_unreachable.flags b/test/files/neg/pat_unreachable.flags new file mode 100644 index 0000000000..cb8324a345 --- /dev/null +++ b/test/files/neg/pat_unreachable.flags @@ -0,0 +1 @@ +-Xoldpatmat
\ No newline at end of file diff --git a/test/files/neg/patmatexhaust.check b/test/files/neg/patmatexhaust.check index 5426d61d31..4556e6622f 100644 --- a/test/files/neg/patmatexhaust.check +++ b/test/files/neg/patmatexhaust.check @@ -1,54 +1,40 @@ -patmatexhaust.scala:7: error: match is not exhaustive! -missing combination Baz - +patmatexhaust.scala:7: error: match may not be exhaustive. +It would fail on the following input: Baz def ma1(x:Foo) = x match { ^ -patmatexhaust.scala:11: error: match is not exhaustive! -missing combination Bar - +patmatexhaust.scala:11: error: match may not be exhaustive. +It would fail on the following input: Bar(_) def ma2(x:Foo) = x match { ^ -patmatexhaust.scala:23: error: match is not exhaustive! -missing combination Kult Kult -missing combination Qult Qult - +patmatexhaust.scala:23: error: match may not be exhaustive. +It would fail on the following inputs: (Kult(_), Kult(_)), (Qult(), Qult()) def ma3(x:Mult) = (x,x) match { // not exhaustive ^ -patmatexhaust.scala:49: error: match is not exhaustive! -missing combination Gp -missing combination Gu - +patmatexhaust.scala:49: error: match may not be exhaustive. +It would fail on the following inputs: Gp(), Gu def ma4(x:Deep) = x match { // missing cases: Gu, Gp ^ -patmatexhaust.scala:53: error: match is not exhaustive! -missing combination Gp - - def ma5(x:Deep) = x match { // Gp +patmatexhaust.scala:55: error: unreachable code + case _ if 1 == 0 => + ^ +patmatexhaust.scala:53: error: match may not be exhaustive. +It would fail on the following input: Gp() + def ma5(x:Deep) = x match { ^ -patmatexhaust.scala:59: error: match is not exhaustive! -missing combination Nil - - def ma6() = List(1,2) match { // give up - ^ -patmatexhaust.scala:75: error: match is not exhaustive! -missing combination B - +patmatexhaust.scala:75: error: match may not be exhaustive. +It would fail on the following input: B() def ma9(x: B) = x match { ^ -patmatexhaust.scala:100: error: match is not exhaustive! -missing combination C1 - +patmatexhaust.scala:100: error: match may not be exhaustive. +It would fail on the following input: C1() def ma10(x: C) = x match { // not exhaustive: C1 is not sealed. ^ -patmatexhaust.scala:114: error: match is not exhaustive! -missing combination D1 -missing combination D2 - +patmatexhaust.scala:114: error: match may not be exhaustive. +It would fail on the following inputs: D1, D2() def ma10(x: C) = x match { // not exhaustive: C1 has subclasses. ^ -patmatexhaust.scala:126: error: match is not exhaustive! -missing combination C1 - +patmatexhaust.scala:126: error: match may not be exhaustive. +It would fail on the following input: C1() def ma10(x: C) = x match { // not exhaustive: C1 is not abstract. ^ 10 errors found diff --git a/test/files/neg/patmatexhaust.flags b/test/files/neg/patmatexhaust.flags index e8fb65d50c..85d8eb2ba2 100644 --- a/test/files/neg/patmatexhaust.flags +++ b/test/files/neg/patmatexhaust.flags @@ -1 +1 @@ --Xfatal-warnings
\ No newline at end of file +-Xfatal-warnings diff --git a/test/files/neg/patmatexhaust.scala b/test/files/neg/patmatexhaust.scala index 9297e09d0d..ceb960ee97 100644 --- a/test/files/neg/patmatexhaust.scala +++ b/test/files/neg/patmatexhaust.scala @@ -50,7 +50,7 @@ class TestSealedExhaustive { // compile only case Ga => } - def ma5(x:Deep) = x match { // Gp + def ma5(x:Deep) = x match { case Gu => case _ if 1 == 0 => case Ga => diff --git a/test/files/neg/primitive-sigs-1.check b/test/files/neg/primitive-sigs-1.check index 8713d95cc3..77dc457a49 100644 --- a/test/files/neg/primitive-sigs-1.check +++ b/test/files/neg/primitive-sigs-1.check @@ -1,6 +1,6 @@ -A_3.scala:3: error: type mismatch; +B.scala:3: error: type mismatch; found : Bippy required: AC[Integer] - J_2.f(new Bippy()) - ^ + J.f(new Bippy()) + ^ one error found diff --git a/test/files/neg/primitive-sigs-1/A_1.scala b/test/files/neg/primitive-sigs-1/A.scala index 0dd83b5d6a..0dd83b5d6a 100644 --- a/test/files/neg/primitive-sigs-1/A_1.scala +++ b/test/files/neg/primitive-sigs-1/A.scala diff --git a/test/files/neg/primitive-sigs-1/A_3.scala b/test/files/neg/primitive-sigs-1/B.scala index dec617a111..0958bcda57 100644 --- a/test/files/neg/primitive-sigs-1/A_3.scala +++ b/test/files/neg/primitive-sigs-1/B.scala @@ -1,5 +1,5 @@ object Test { def main(args: Array[String]): Unit = { - J_2.f(new Bippy()) + J.f(new Bippy()) } } diff --git a/test/files/neg/primitive-sigs-1/J_2.java b/test/files/neg/primitive-sigs-1/J.java index b416befb4d..2e43b8330c 100644 --- a/test/files/neg/primitive-sigs-1/J_2.java +++ b/test/files/neg/primitive-sigs-1/J.java @@ -1,6 +1,6 @@ // java: often the java or scala compiler will save us from // the untruth in the signature, but not always. -public class J_2 { +public class J { public static Integer f(AC<Integer> x) { return x.f(); } public static void main(String[] args) { f(new Bippy()); diff --git a/test/files/neg/reify_ann2b.check b/test/files/neg/reify_ann2b.check index b9dd84c1ee..52bdbe5b7c 100644 --- a/test/files/neg/reify_ann2b.check +++ b/test/files/neg/reify_ann2b.check @@ -1,4 +1,4 @@ -reify_ann2b.scala:6: error: inner classes cannot be classfile annotations
- class ann(bar: String) extends ClassfileAnnotation
- ^
-one error found
+reify_ann2b.scala:6: error: inner classes cannot be classfile annotations + class ann(bar: String) extends annotation.ClassfileAnnotation + ^ +one error found diff --git a/test/files/neg/reify_ann2b.scala b/test/files/neg/reify_ann2b.scala index 6b6da8f790..397d00210d 100644 --- a/test/files/neg/reify_ann2b.scala +++ b/test/files/neg/reify_ann2b.scala @@ -3,7 +3,7 @@ import scala.reflect.mirror._ object Test extends App { // test 1: reify val tree = reify{ - class ann(bar: String) extends ClassfileAnnotation + class ann(bar: String) extends annotation.ClassfileAnnotation @ann(bar="1a") @ann(bar="1b") class C[@ann(bar="2a") @ann(bar="2b") T](@ann(bar="3a") @ann(bar="3b") x: T @ann(bar="4a") @ann(bar="4b")) { @ann(bar="5a") @ann(bar="5b") def f(x: Int @ann(bar="6a") @ann(bar="6b")) = { diff --git a/test/files/neg/sealed-java-enums.check b/test/files/neg/sealed-java-enums.check index 9303c2df9c..20d00c8e91 100644 --- a/test/files/neg/sealed-java-enums.check +++ b/test/files/neg/sealed-java-enums.check @@ -1,9 +1,5 @@ -sealed-java-enums.scala:5: error: match is not exhaustive! -missing combination BLOCKED -missing combination State -missing combination TERMINATED -missing combination TIMED_WAITING - +sealed-java-enums.scala:5: error: match may not be exhaustive. +It would fail on the following inputs: BLOCKED, TERMINATED, TIMED_WAITING def f(state: State) = state match { ^ one error found diff --git a/test/files/neg/switch.check b/test/files/neg/switch.check index 7212c1a22b..8955c94b32 100644 --- a/test/files/neg/switch.check +++ b/test/files/neg/switch.check @@ -1,10 +1,10 @@ switch.scala:28: error: could not emit switch for @switch annotated match def fail1(c: Char) = (c: @switch) match { - ^ + ^ switch.scala:38: error: could not emit switch for @switch annotated match def fail2(c: Char) = (c: @switch @unchecked) match { - ^ + ^ switch.scala:45: error: could not emit switch for @switch annotated match def fail3(c: Char) = (c: @unchecked @switch) match { - ^ + ^ three errors found diff --git a/test/files/neg/macro-deprecate-dont-touch-backquotedidents.flags b/test/files/neg/switch.flags index e8fb65d50c..e8fb65d50c 100644 --- a/test/files/neg/macro-deprecate-dont-touch-backquotedidents.flags +++ b/test/files/neg/switch.flags diff --git a/test/files/neg/t1878-typer.check b/test/files/neg/t1878-typer.check new file mode 100644 index 0000000000..e3a20d0be7 --- /dev/null +++ b/test/files/neg/t1878-typer.check @@ -0,0 +1,4 @@ +t1878-typer.scala:4: error: _* may only come last + case <p> { _* } </p> => + ^ +one error found diff --git a/test/files/neg/t1878-typer.scala b/test/files/neg/t1878-typer.scala new file mode 100644 index 0000000000..1eb0cb7dff --- /dev/null +++ b/test/files/neg/t1878-typer.scala @@ -0,0 +1,6 @@ +object Test extends App { + // illegal - bug #1764 + null match { + case <p> { _* } </p> => + } +} diff --git a/test/files/neg/t1878.check b/test/files/neg/t1878.check index 128741a022..ac2071c3d8 100644 --- a/test/files/neg/t1878.check +++ b/test/files/neg/t1878.check @@ -1,18 +1,7 @@ -t1878.scala:3: error: _* may only come last +t1878.scala:3: error: bad use of _* (a sequence pattern must be the last pattern) val err1 = "" match { case Seq(f @ _*, ',') => f } - ^ -t1878.scala:3: error: scrutinee is incompatible with pattern type; - found : Seq[A] - required: String - val err1 = "" match { case Seq(f @ _*, ',') => f } - ^ -t1878.scala:3: error: not found: value f - val err1 = "" match { case Seq(f @ _*, ',') => f } - ^ -t1878.scala:9: error: _* may only come last + ^ +t1878.scala:9: error: bad use of _* (a sequence pattern must be the last pattern) val List(List(_*, arg2), _) = List(List(1,2,3), List(4,5,6)) - ^ -t1878.scala:13: error: _* may only come last - case <p> { _* } </p> => - ^ -5 errors found + ^ +two errors found diff --git a/test/files/neg/t1878.scala b/test/files/neg/t1878.scala index 5278fbb7bd..99fee48a96 100644 --- a/test/files/neg/t1878.scala +++ b/test/files/neg/t1878.scala @@ -8,8 +8,10 @@ object Test extends App { // illegal val List(List(_*, arg2), _) = List(List(1,2,3), List(4,5,6)) + /* see t1878-typer.scala // illegal - bug #1764 null match { case <p> { _* } </p> => } + */ } diff --git a/test/files/neg/t200.check b/test/files/neg/t200.check index 3ef6665fe5..b6b1a32267 100644 --- a/test/files/neg/t200.check +++ b/test/files/neg/t200.check @@ -1,4 +1,5 @@ -t200.scala:7: error: method foo is defined twice in t200.scala +t200.scala:7: error: method foo is defined twice + conflicting symbols both originated in file 't200.scala' def foo: Int; ^ one error found diff --git a/test/files/neg/t2386.check b/test/files/neg/t2386.check deleted file mode 100644 index f70f12535f..0000000000 --- a/test/files/neg/t2386.check +++ /dev/null @@ -1,4 +0,0 @@ -t2386.scala:2: error: No ClassTag available for Array[_ >: String with Int]
- val a = Array(Array(1, 2), Array("a","b"))
- ^
-one error found
diff --git a/test/files/neg/t2386.scala b/test/files/neg/t2386.scala deleted file mode 100644 index 56146cc5c3..0000000000 --- a/test/files/neg/t2386.scala +++ /dev/null @@ -1,3 +0,0 @@ -object Test { - val a = Array(Array(1, 2), Array("a","b")) -} diff --git a/test/files/neg/t2405.check b/test/files/neg/t2405.check new file mode 100644 index 0000000000..78360bcc21 --- /dev/null +++ b/test/files/neg/t2405.check @@ -0,0 +1,8 @@ +t2405.scala:6: warning: imported `y' is permanently hidden by definition of method y + import A.{x => y} + ^ +t2405.scala:8: error: could not find implicit value for parameter e: Int + implicitly[Int] + ^ +one warning found +one error found diff --git a/test/files/neg/t2405.scala b/test/files/neg/t2405.scala new file mode 100644 index 0000000000..6982285b98 --- /dev/null +++ b/test/files/neg/t2405.scala @@ -0,0 +1,10 @@ +object A { implicit val x: Int = 1 } + +// Expecting shadowing #1 +object Test2 { + { + import A.{x => y} + def y: Int = 0 + implicitly[Int] + } +} diff --git a/test/files/neg/t2488.check b/test/files/neg/t2488.check new file mode 100644 index 0000000000..170dbf88ff --- /dev/null +++ b/test/files/neg/t2488.check @@ -0,0 +1,31 @@ +t2488.scala:7: error: overloaded method value f with alternatives: + ()Int <and> + (a: Int,b: Int)Int + cannot be applied to (b: Int, Int) + println(c.f(b = 2, 2)) + ^ +t2488.scala:8: error: overloaded method value f with alternatives: + ()Int <and> + (a: Int,b: Int)Int + cannot be applied to (a: Int, c: Int) + println(c.f(a = 2, c = 2)) + ^ +t2488.scala:9: error: overloaded method value f with alternatives: + ()Int <and> + (a: Int,b: Int)Int + cannot be applied to (Int, c: Int) + println(c.f(2, c = 2)) + ^ +t2488.scala:10: error: overloaded method value f with alternatives: + ()Int <and> + (a: Int,b: Int)Int + cannot be applied to (c: Int, Int) + println(c.f(c = 2, 2)) + ^ +t2488.scala:11: error: overloaded method value f with alternatives: + ()Int <and> + (a: Int,b: Int)Int + cannot be applied to (Int) + println(c.f(2)) + ^ +5 errors found diff --git a/test/files/neg/t2488.scala b/test/files/neg/t2488.scala new file mode 100644 index 0000000000..8db052eec1 --- /dev/null +++ b/test/files/neg/t2488.scala @@ -0,0 +1,12 @@ +class C { + def f(a:Int, b:Int) = 1 + def f() = 2 +} +object Test extends App { + val c = new C() + println(c.f(b = 2, 2)) + println(c.f(a = 2, c = 2)) + println(c.f(2, c = 2)) + println(c.f(c = 2, 2)) + println(c.f(2)) +} diff --git a/test/files/neg/t2775.check b/test/files/neg/t2775.check index f357221cd9..a1e950cf73 100644 --- a/test/files/neg/t2775.check +++ b/test/files/neg/t2775.check @@ -1,4 +1,4 @@ -t2775.scala:1: error: cannot find class tag for element type B.this.T
-trait B[S] { type T = S; val c = new Array[T](1) }
- ^
-one error found
+t2775.scala:1: error: cannot find array tag for element type B.this.T +trait B[S] { type T = S; val c = new Array[T](1) } + ^ +one error found diff --git a/test/files/neg/t2779.check b/test/files/neg/t2779.check index d642541e3e..0ab4c50d0f 100644 --- a/test/files/neg/t2779.check +++ b/test/files/neg/t2779.check @@ -1,4 +1,5 @@ -t2779.scala:16: error: method f is defined twice in t2779.scala +t2779.scala:16: error: method f is defined twice + conflicting symbols both originated in file 't2779.scala' override def f = List(M1) ^ one error found diff --git a/test/files/neg/t278.check b/test/files/neg/t278.check index 0c2dfeb67a..405f7d225c 100644 --- a/test/files/neg/t278.check +++ b/test/files/neg/t278.check @@ -4,7 +4,8 @@ t278.scala:5: error: overloaded method value a with alternatives: does not take type parameters println(a[A]) ^ -t278.scala:4: error: method a is defined twice in t278.scala +t278.scala:4: error: method a is defined twice + conflicting symbols both originated in file 't278.scala' def a = (p:A) => () ^ two errors found diff --git a/test/files/neg/t3098.check b/test/files/neg/t3098.check index 403da281c8..85829747b9 100644 --- a/test/files/neg/t3098.check +++ b/test/files/neg/t3098.check @@ -1,6 +1,5 @@ -b.scala:3: error: match is not exhaustive! -missing combination C - +b.scala:3: error: match may not be exhaustive. +It would fail on the following input: (_ : C) def f = (null: T) match { ^ one error found diff --git a/test/files/neg/t3098.flags b/test/files/neg/t3098.flags index e8fb65d50c..85d8eb2ba2 100644 --- a/test/files/neg/t3098.flags +++ b/test/files/neg/t3098.flags @@ -1 +1 @@ --Xfatal-warnings
\ No newline at end of file +-Xfatal-warnings diff --git a/test/files/neg/t3189.check b/test/files/neg/t3189.check new file mode 100644 index 0000000000..3913c526a2 --- /dev/null +++ b/test/files/neg/t3189.check @@ -0,0 +1,4 @@ +t3189.scala:2: error: use _* to match a sequence + val Array(a,b*) = ("": Any) + ^ +one error found diff --git a/test/files/neg/t3189.scala b/test/files/neg/t3189.scala new file mode 100644 index 0000000000..4ea4bb7581 --- /dev/null +++ b/test/files/neg/t3189.scala @@ -0,0 +1,3 @@ +object A { + val Array(a,b*) = ("": Any) +}
\ No newline at end of file diff --git a/test/files/neg/t3507.check b/test/files/neg/t3507-old.check index 71bf295039..5c58444cb3 100644 --- a/test/files/neg/t3507.check +++ b/test/files/neg/t3507-old.check @@ -1,4 +1,4 @@ -t3507.scala:13: error: No ConcreteTypeTag available for _1.b.c.type
+t3507-old.scala:13: error: No Manifest available for _1.b.c.type.
mani/*[object _1.b.c]*/(c) // kaboom in manifestOfType / TreeGen.mkAttributedQualifier
^
one error found
diff --git a/test/files/neg/t3507.scala b/test/files/neg/t3507-old.scala index 32688d3934..32688d3934 100644 --- a/test/files/neg/t3507.scala +++ b/test/files/neg/t3507-old.scala diff --git a/test/files/neg/t3614.check b/test/files/neg/t3614.check new file mode 100644 index 0000000000..5fdb5cbf1f --- /dev/null +++ b/test/files/neg/t3614.check @@ -0,0 +1,4 @@ +t3614.scala:2: error: class type required but AnyRef{def a: <?>} found + def v = new ({ def a=0 }) + ^ +one error found
\ No newline at end of file diff --git a/test/files/neg/t3614.scala b/test/files/neg/t3614.scala new file mode 100644 index 0000000000..5b02cdf2b2 --- /dev/null +++ b/test/files/neg/t3614.scala @@ -0,0 +1,3 @@ +object t3614 { + def v = new ({ def a=0 }) +}
\ No newline at end of file diff --git a/test/files/neg/t3683a.check b/test/files/neg/t3683a.check index 18e80dd5e8..3de3ad784e 100644 --- a/test/files/neg/t3683a.check +++ b/test/files/neg/t3683a.check @@ -1,6 +1,5 @@ -t3683a.scala:14: error: match is not exhaustive! -missing combination XX - +t3683a.scala:14: error: match may not be exhaustive. +It would fail on the following input: XX() w match { ^ one error found diff --git a/test/files/neg/t3692-new.check b/test/files/neg/t3692-new.check new file mode 100644 index 0000000000..e013daca74 --- /dev/null +++ b/test/files/neg/t3692-new.check @@ -0,0 +1,4 @@ +t3692-new.scala:15: error: unreachable code
+ case m2: Map[T, Int] => new java.util.HashMap[T, Integer]
+ ^
+one error found
diff --git a/test/files/neg/t3692-new.flags b/test/files/neg/t3692-new.flags new file mode 100644 index 0000000000..cb8324a345 --- /dev/null +++ b/test/files/neg/t3692-new.flags @@ -0,0 +1 @@ +-Xoldpatmat
\ No newline at end of file diff --git a/test/files/neg/t3692-new.scala b/test/files/neg/t3692-new.scala new file mode 100644 index 0000000000..46874b02e3 --- /dev/null +++ b/test/files/neg/t3692-new.scala @@ -0,0 +1,19 @@ +import java.lang.Integer + +object Tester { + def main(args: Array[String]) = { + val map = Map("John" -> 1, "Josh" -> 2) + new Tester().toJavaMap(map) + } +} + +class Tester { + private final def toJavaMap[T, V](map: Map[T, V])(implicit m1: ClassTag[T], m2: ClassTag[V]): java.util.Map[_, _] = { + map match { + case m0: Map[Int, Int] => new java.util.HashMap[Integer, Integer] + case m1: Map[Int, V] => new java.util.HashMap[Integer, V] + case m2: Map[T, Int] => new java.util.HashMap[T, Integer] + case _ => new java.util.HashMap[T, V] + } + } +}
\ No newline at end of file diff --git a/test/files/neg/t3692-old.check b/test/files/neg/t3692-old.check new file mode 100644 index 0000000000..9da7033239 --- /dev/null +++ b/test/files/neg/t3692-old.check @@ -0,0 +1,8 @@ +t3692-old.scala:6: warning: object Manifest in package reflect is deprecated: Use `@scala.reflect.ConcreteTypeTag` instead
+ new ManifestTester().toJavaMap(map)
+ ^
+t3692-old.scala:15: error: unreachable code
+ case m2: Map[T, Int] => new java.util.HashMap[T, Integer]
+ ^
+one warning found
+one error found
diff --git a/test/files/neg/t3692-old.flags b/test/files/neg/t3692-old.flags new file mode 100644 index 0000000000..cb8324a345 --- /dev/null +++ b/test/files/neg/t3692-old.flags @@ -0,0 +1 @@ +-Xoldpatmat
\ No newline at end of file diff --git a/test/files/neg/t3692.scala b/test/files/neg/t3692-old.scala index 151535ae94..151535ae94 100644 --- a/test/files/neg/t3692.scala +++ b/test/files/neg/t3692-old.scala diff --git a/test/files/neg/t3692.check b/test/files/neg/t3692.check deleted file mode 100644 index d83abd31e2..0000000000 --- a/test/files/neg/t3692.check +++ /dev/null @@ -1,11 +0,0 @@ -t3692.scala:11: warning: type Manifest in object Predef is deprecated: Use `@scala.reflect.ConcreteTypeTag` instead
- private final def toJavaMap[T, V](map: Map[T, V])(implicit m1: Manifest[T], m2: Manifest[V]): java.util.Map[_, _] = {
- ^
-t3692.scala:11: warning: type Manifest in object Predef is deprecated: Use `@scala.reflect.ConcreteTypeTag` instead
- private final def toJavaMap[T, V](map: Map[T, V])(implicit m1: Manifest[T], m2: Manifest[V]): java.util.Map[_, _] = {
- ^
-t3692.scala:15: error: unreachable code
- case m2: Map[T, Int] => new java.util.HashMap[T, Integer]
- ^
-two warnings found
-one error found
diff --git a/test/files/neg/t3761-overload-byname.check b/test/files/neg/t3761-overload-byname.check new file mode 100644 index 0000000000..ae7d21dfa6 --- /dev/null +++ b/test/files/neg/t3761-overload-byname.check @@ -0,0 +1,13 @@ +t3761-overload-byname.scala:9: error: ambiguous reference to overloaded definition, +both method m1 in object t of type (x: => Int, s: Object)Int +and method m1 in object t of type (x: => AnyVal, s: String)Int +match argument types (Int,String) + m1(1, "") + ^ +t3761-overload-byname.scala:11: error: ambiguous reference to overloaded definition, +both method m2 in object t of type (x: => Int, s: Object)Int +and method m2 in object t of type (x: => Any, s: String)Int +match argument types (Int,String) + m2(1, "") + ^ +two errors found diff --git a/test/files/neg/t3761-overload-byname.scala b/test/files/neg/t3761-overload-byname.scala new file mode 100644 index 0000000000..5b9a381b93 --- /dev/null +++ b/test/files/neg/t3761-overload-byname.scala @@ -0,0 +1,13 @@ +object t { + def m1(x: => AnyVal, s: String) = 0 + def m1(x: => Int, s: Object) = 1 + + def m2(x: => Any, s: String) = 0 + def m2(x: => Int, s: Object) = 1 + + + m1(1, "") + m1(1d, "") + m2(1, "") + m2("", "") +} diff --git a/test/files/neg/t3816.check b/test/files/neg/t3816.check index 3658e76b64..40621f8962 100644 --- a/test/files/neg/t3816.check +++ b/test/files/neg/t3816.check @@ -1,4 +1,4 @@ -t3816.scala:30: error: stable identifier required, but syncID found. +t3816.scala:30: error: stable identifier required, but `syncID` found. case Some( `syncID` ) => ^ t3816.scala:38: error: stable identifier required, but Test.this.foo found. diff --git a/test/files/neg/t4098.check b/test/files/neg/t4098.check new file mode 100644 index 0000000000..7d69cf151c --- /dev/null +++ b/test/files/neg/t4098.check @@ -0,0 +1,13 @@ +t4098.scala:3: error: forward reference not allowed from self constructor invocation + this(b) + ^ +t4098.scala:8: error: forward reference not allowed from self constructor invocation + this(b) + ^ +t4098.scala:13: error: forward reference not allowed from self constructor invocation + this(b) + ^ +t4098.scala:18: error: forward reference not allowed from self constructor invocation + this(b) + ^ +four errors found diff --git a/test/files/neg/t4098.scala b/test/files/neg/t4098.scala new file mode 100644 index 0000000000..744d6191b5 --- /dev/null +++ b/test/files/neg/t4098.scala @@ -0,0 +1,22 @@ +class A(a: Any) { + def this() = { + this(b) + def b = new {} + } + + def this(x: Int) = { + this(b) + lazy val b = new {} + } + + def this(x: Int, y: Int) = { + this(b) + val b = new {} + } + + def this(x: Int, y: Int, z: Int) = { + this(b) + println(".") + def b = new {} + } +} diff --git a/test/files/neg/t4425.check b/test/files/neg/t4425.check index 4ff4b1eec0..0f2fe6f2d1 100644 --- a/test/files/neg/t4425.check +++ b/test/files/neg/t4425.check @@ -1,4 +1,4 @@ -t4425.scala:3: error: erroneous or inaccessible type +t4425.scala:3: error: isInstanceOf cannot test if value types are references. 42 match { case _ X _ => () } ^ one error found diff --git a/test/files/neg/t4568.check b/test/files/neg/t4568.check new file mode 100644 index 0000000000..f94d699486 --- /dev/null +++ b/test/files/neg/t4568.check @@ -0,0 +1,4 @@ +t4568.scala:8: error: recursive method isSubListOf needs result type + case h :: t => y.contains(h) && (t.isSubListOf(y.drop(y.indexOf(h) + 1))) + ^ +one error found diff --git a/test/files/neg/t4568.scala b/test/files/neg/t4568.scala new file mode 100644 index 0000000000..8067759262 --- /dev/null +++ b/test/files/neg/t4568.scala @@ -0,0 +1,13 @@ +object SubList { + implicit def sublistable[A](x: List[A]) = new SubListable(x) + + class SubListable[A](x: List[A]) { + def isSubListOf(y: List[A]) = { + x match { + case Nil => true + case h :: t => y.contains(h) && (t.isSubListOf(y.drop(y.indexOf(h) + 1))) + } + } + } + +}
\ No newline at end of file diff --git a/test/files/neg/t4818.check b/test/files/neg/t4818.check new file mode 100644 index 0000000000..a5e15e456b --- /dev/null +++ b/test/files/neg/t4818.check @@ -0,0 +1,6 @@ +t4818.scala:4: error: type mismatch; + found : Int(5) + required: Nothing + def f(x: Any) = x match { case Fn(f) => f(5) } + ^ +one error found diff --git a/test/files/neg/t4818.scala b/test/files/neg/t4818.scala new file mode 100644 index 0000000000..faae229206 --- /dev/null +++ b/test/files/neg/t4818.scala @@ -0,0 +1,7 @@ +object Test { + case class Fn[A, B](f: A => B) + + def f(x: Any) = x match { case Fn(f) => f(5) } + + Fn((x: String) => x) +} diff --git a/test/files/neg/t4928.check b/test/files/neg/t4928.check new file mode 100644 index 0000000000..06d4f22522 --- /dev/null +++ b/test/files/neg/t4928.check @@ -0,0 +1,5 @@ +t4928.scala:3: error: parameter 'a' is already specified at parameter position 1 +Note that that 'z' is not a parameter name of the invoked method. + f(z = 0, a = 1) + ^ +one error found diff --git a/test/files/neg/t4928.scala b/test/files/neg/t4928.scala new file mode 100644 index 0000000000..17a5980314 --- /dev/null +++ b/test/files/neg/t4928.scala @@ -0,0 +1,4 @@ +class C { + def f(a: Int, b: Int = 0) = 0 + f(z = 0, a = 1) +} diff --git a/test/files/neg/t5044.check b/test/files/neg/t5044.check new file mode 100644 index 0000000000..197da2a4e8 --- /dev/null +++ b/test/files/neg/t5044.check @@ -0,0 +1,9 @@ +t5044.scala:7: error: recursive value a needs type + val id = m(a) + ^ +t5044.scala:6: warning: type-checking the invocation of method foo checks if the named argument expression 'id = ...' is a valid assignment +in the current scope. The resulting type inference error (see above) can be fixed by providing an explicit type in the local definition for id. + val a = foo(id = 1) + ^ +one warning found +one error found diff --git a/test/files/neg/t5044.scala b/test/files/neg/t5044.scala new file mode 100644 index 0000000000..2663ec1bbb --- /dev/null +++ b/test/files/neg/t5044.scala @@ -0,0 +1,9 @@ +class T { + def foo[T](id: T) = 0 + def m(a: Int) = 0 + + def f { + val a = foo(id = 1) + val id = m(a) + } +} diff --git a/test/files/neg/t5106.check b/test/files/neg/t5106.check new file mode 100644 index 0000000000..ac16041cf7 --- /dev/null +++ b/test/files/neg/t5106.check @@ -0,0 +1,11 @@ +t5106.scala:3: error: type mismatch; + found : Int(4) + required: String + val (n, l): (String, Int) = (4, "") + ^ +t5106.scala:3: error: type mismatch; + found : String("") + required: Int + val (n, l): (String, Int) = (4, "") + ^ +two errors found diff --git a/test/files/neg/t5106.scala b/test/files/neg/t5106.scala new file mode 100644 index 0000000000..419b430ff1 --- /dev/null +++ b/test/files/neg/t5106.scala @@ -0,0 +1,5 @@ +class A { + def f { + val (n, l): (String, Int) = (4, "") + } +} diff --git a/test/files/neg/t5318.check b/test/files/neg/t5318.check new file mode 100644 index 0000000000..d6a3a57935 --- /dev/null +++ b/test/files/neg/t5318.check @@ -0,0 +1,5 @@ +t5318.scala:7: error: diverging implicit expansion for type CompilerHang.this.TC[F] +starting with method tc in class CompilerHang + breakage // type checker doesn't terminate, should report inference failure + ^ +one error found diff --git a/test/files/neg/t5318.scala b/test/files/neg/t5318.scala new file mode 100644 index 0000000000..8009c66e6b --- /dev/null +++ b/test/files/neg/t5318.scala @@ -0,0 +1,8 @@ +class CompilerHang { + trait TC[M[_]] + trait S[A] + + implicit def tc[M[_]](implicit M0: TC[M]): TC[S] = null + def breakage[F[_] : TC] = 0 + breakage // type checker doesn't terminate, should report inference failure +}
\ No newline at end of file diff --git a/test/files/neg/t5318b.check b/test/files/neg/t5318b.check new file mode 100644 index 0000000000..47a10d6733 --- /dev/null +++ b/test/files/neg/t5318b.check @@ -0,0 +1,5 @@ +t5318b.scala:7: error: diverging implicit expansion for type DivergingImplicitReported.this.TC[F] +starting with method tc in class DivergingImplicitReported + breakage // correct: diverging implicit expansion + ^ +one error found
\ No newline at end of file diff --git a/test/files/neg/t5318b.scala b/test/files/neg/t5318b.scala new file mode 100644 index 0000000000..123f8b4e04 --- /dev/null +++ b/test/files/neg/t5318b.scala @@ -0,0 +1,8 @@ +class DivergingImplicitReported { + trait TC[M] + trait S + + implicit def tc[M](implicit M0: TC[M]): TC[S] = null + def breakage[F: TC] = 0 + breakage // correct: diverging implicit expansion +}
\ No newline at end of file diff --git a/test/files/neg/t5318c.check b/test/files/neg/t5318c.check new file mode 100644 index 0000000000..594539be69 --- /dev/null +++ b/test/files/neg/t5318c.check @@ -0,0 +1,5 @@ +t5318c.scala:13: error: diverging implicit expansion for type CompilerHang.this.TC[F] +starting with method tc in class CompilerHang + breakage // type checker doesn't terminate, should report inference failure + ^ +one error found diff --git a/test/files/neg/t5318c.scala b/test/files/neg/t5318c.scala new file mode 100644 index 0000000000..477a9874ad --- /dev/null +++ b/test/files/neg/t5318c.scala @@ -0,0 +1,14 @@ +class CompilerHang { + trait TC[M[_]] + trait S[A] + + class C[M[_]] { + type TCM = TC[M] + } + + // A nefarious implicit, to motivate the removal of `&& sym.owner.isTerm` from + // `isFreeTypeParamNoSkolem`. + implicit def tc[x[_], CC[x[_]] <: C[x]](implicit M0: CC[x]#TCM): CC[x]#TCM = null + def breakage[F[_] : TC] = 0 + breakage // type checker doesn't terminate, should report inference failure +} diff --git a/test/files/neg/t5452-new.check b/test/files/neg/t5452-new.check new file mode 100644 index 0000000000..bbd3734f74 --- /dev/null +++ b/test/files/neg/t5452-new.check @@ -0,0 +1,8 @@ +t5452-new.scala:28: error: overloaded method value apply with alternatives:
+ ()Queryable[CoffeesTable] <and>
+ (t: Tree)(implicit evidence$2: ClassTag[CoffeesTable])Nothing <and>
+ (implicit evidence$1: ClassTag[CoffeesTable])Nothing
+ cannot be applied to (Queryable[CoffeesTable])
+ Queryable[CoffeesTable]( q.treeFilter(null) )
+ ^
+one error found
diff --git a/test/files/neg/t5452-new.scala b/test/files/neg/t5452-new.scala new file mode 100644 index 0000000000..c829de7d7c --- /dev/null +++ b/test/files/neg/t5452-new.scala @@ -0,0 +1,29 @@ +// /scala/trac/5452/a.scala +// Mon Feb 13 22:52:36 PST 2012 + +// import scala.reflect.mirror._ + +trait Tree + +object Bip { + def ??? = sys.error("") +} +import Bip._ + +case class Queryable[T]() { + def treeFilter( t:Tree ) : Queryable[T] = ??? +} + +object Queryable { + def apply[T:ClassTag] = ??? + def apply[T:ClassTag]( t:Tree ) = ??? +} + +trait CoffeesTable{ + def sales : Int +} + +object Test extends App{ + val q = new Queryable[CoffeesTable] + Queryable[CoffeesTable]( q.treeFilter(null) ) +} diff --git a/test/files/neg/t5452.check b/test/files/neg/t5452-old.check index 2f35a45509..e5872a5759 100644 --- a/test/files/neg/t5452.check +++ b/test/files/neg/t5452-old.check @@ -1,8 +1,8 @@ -t5452.scala:28: error: overloaded method value apply with alternatives: - ()Queryable[CoffeesTable] <and> - (t: Tree)(implicit evidence$2: Manifest[CoffeesTable])Nothing <and> - (implicit evidence$1: Manifest[CoffeesTable])Nothing - cannot be applied to (Queryable[CoffeesTable]) - Queryable[CoffeesTable]( q.treeFilter(null) ) - ^ -one error found +t5452-old.scala:28: error: overloaded method value apply with alternatives:
+ ()Queryable[CoffeesTable] <and>
+ (t: Tree)(implicit evidence$2: Manifest[CoffeesTable])Nothing <and>
+ (implicit evidence$1: Manifest[CoffeesTable])Nothing
+ cannot be applied to (Queryable[CoffeesTable])
+ Queryable[CoffeesTable]( q.treeFilter(null) )
+ ^
+one error found
diff --git a/test/files/neg/t5452.scala b/test/files/neg/t5452-old.scala index 1032db7a4b..1032db7a4b 100644 --- a/test/files/neg/t5452.scala +++ b/test/files/neg/t5452-old.scala diff --git a/test/files/neg/t5504.check b/test/files/neg/t5504.check new file mode 100644 index 0000000000..2827c02d10 --- /dev/null +++ b/test/files/neg/t5504.check @@ -0,0 +1,4 @@ +error: type _$1 is defined twice + conflicting symbols both originated in file 't5504/s_1.scala' + Note: this may be due to a bug in the compiler involving wildcards in package objects +one error found diff --git a/test/files/neg/t5504/s_1.scala b/test/files/neg/t5504/s_1.scala new file mode 100644 index 0000000000..35cb2c8bae --- /dev/null +++ b/test/files/neg/t5504/s_1.scala @@ -0,0 +1,4 @@ +// a.scala +package object foo { + val m: List[_] = Nil +} diff --git a/test/files/neg/t5504/s_2.scala b/test/files/neg/t5504/s_2.scala new file mode 100644 index 0000000000..03eecf6e19 --- /dev/null +++ b/test/files/neg/t5504/s_2.scala @@ -0,0 +1,8 @@ +// b.scala +package foo + +object Test { + def main(args: Array[String]): Unit = { + println(foo.m) + } +} diff --git a/test/files/neg/t5510.check b/test/files/neg/t5510.check new file mode 100644 index 0000000000..60da3bed40 --- /dev/null +++ b/test/files/neg/t5510.check @@ -0,0 +1,19 @@ +t5510.scala:2: error: unclosed string literal + val s1 = s"xxx + ^ +t5510.scala:3: error: unclosed string literal + val s2 = s"xxx $x + ^ +t5510.scala:4: error: unclosed string literal + val s3 = s"xxx $$ + ^ +t5510.scala:5: error: unclosed string literal + val s4 = ""s" + ^ +t5510.scala:6: error: unclosed multi-line string literal + val s5 = ""s""" $s1 $s2 s" + ^ +t5510.scala:7: error: '}' expected but eof found. +} + ^ +6 errors found diff --git a/test/files/neg/t5510.scala b/test/files/neg/t5510.scala new file mode 100644 index 0000000000..12630eb2cd --- /dev/null +++ b/test/files/neg/t5510.scala @@ -0,0 +1,7 @@ +object Test { + val s1 = s"xxx + val s2 = s"xxx $x + val s3 = s"xxx $$ + val s4 = ""s" + val s5 = ""s""" $s1 $s2 s" +} diff --git a/test/files/neg/t5544.check b/test/files/neg/t5544.check new file mode 100644 index 0000000000..d4113935a3 --- /dev/null +++ b/test/files/neg/t5544.check @@ -0,0 +1,4 @@ +Test_2.scala:2: error: value baz is not a member of object Api + Api.baz + ^ +one error found diff --git a/test/files/neg/t5544/Api_1.scala b/test/files/neg/t5544/Api_1.scala new file mode 100644 index 0000000000..77637f440a --- /dev/null +++ b/test/files/neg/t5544/Api_1.scala @@ -0,0 +1,8 @@ +import scala.annotation.StaticAnnotation + +class ann(val bar: Any) extends StaticAnnotation + +object Api { + @ann({def baz = "baz!!"}) + def foo = println("foo") +} diff --git a/test/files/neg/t5544/Test_2.scala b/test/files/neg/t5544/Test_2.scala new file mode 100644 index 0000000000..4c8c99cbc7 --- /dev/null +++ b/test/files/neg/t5544/Test_2.scala @@ -0,0 +1,3 @@ +object Test extends App { + Api.baz +} diff --git a/test/files/neg/t5564.check b/test/files/neg/t5564.check new file mode 100644 index 0000000000..e7e13ccc9c --- /dev/null +++ b/test/files/neg/t5564.check @@ -0,0 +1,4 @@ +t5564.scala:8: error: inferred type arguments [A] do not conform to method bar's type parameter bounds [B >: A <: C] + def bar[B >: A <: C]: T = throw new Exception + ^ +one error found diff --git a/test/files/neg/t5564.scala b/test/files/neg/t5564.scala new file mode 100644 index 0000000000..663cf88726 --- /dev/null +++ b/test/files/neg/t5564.scala @@ -0,0 +1,9 @@ + + + +trait C + + +class Foo[@specialized(Int) T, A] { + def bar[B >: A <: C]: T = throw new Exception +} diff --git a/test/files/neg/t5578.check b/test/files/neg/t5578.check new file mode 100644 index 0000000000..d803adb223 --- /dev/null +++ b/test/files/neg/t5578.check @@ -0,0 +1,4 @@ +t5578.scala:33: error: No Manifest available for T. + def plus[T: Numeric](x: Rep[T], y: Rep[T]): Rep[T] = Plus[T](x,y) + ^ +one error found diff --git a/test/files/neg/t5578.scala b/test/files/neg/t5578.scala new file mode 100644 index 0000000000..ce72f32d53 --- /dev/null +++ b/test/files/neg/t5578.scala @@ -0,0 +1,39 @@ +trait Base { + type Rep[T] +} + +trait Expressions { + // constants/symbols (atomic) + abstract class Exp[T] + // ... + case class Sym[T](n: Int) extends Exp[T] + + // operations (composite, defined in subtraits) + abstract class Def[T] + + // additional members for managing encountered definitions + def findOrCreateDefinition[T](rhs: Def[T]): Sym[T] + implicit def toExp[T:Manifest](d: Def[T]): Exp[T] = findOrCreateDefinition(d) +} + +trait BaseExp extends Base with Expressions { + type Rep[T] = Exp[T] + + def findOrCreateDefinition[T](rhs: Def[T]): Sym[T] = null // stub +} + +trait NumericOps extends Base { + def plus[T](x: Rep[T], y: Rep[T]): Rep[T] +} + +trait NumericOpsExp extends BaseExp { + case class Plus[T:Numeric](x: Rep[T], y: Rep[T]) + extends Def[T] + + def plus[T: Numeric](x: Rep[T], y: Rep[T]): Rep[T] = Plus[T](x,y) + + // Possible solutions: +// def plus[T: Numeric: Manifest](x: Rep[T], y: Rep[T]): Rep[T] = Plus[T](x, y) +// def plus[T](x: Rep[T], y: Rep[T])(implicit num: Numeric[T], man: Manifest[T]): Rep[T] = Plus(x,y) + +} diff --git a/test/files/neg/t5663-badwarneq.check b/test/files/neg/t5663-badwarneq.check new file mode 100644 index 0000000000..00c2234e9d --- /dev/null +++ b/test/files/neg/t5663-badwarneq.check @@ -0,0 +1,22 @@ +t5663-badwarneq.scala:42: error: comparing case class values of types Some[Int] and None.type using `==' will always yield false + println(new Some(1) == None) // Should complain on type, was: spuriously complains on fresh object + ^ +t5663-badwarneq.scala:43: error: comparing case class values of types Some[Int] and Thing using `==' will always yield false + println(Some(1) == new Thing(1)) // Should complain on type, was: spuriously complains on fresh object + ^ +t5663-badwarneq.scala:51: error: ThingOne and Thingy are unrelated: they will most likely never compare equal + println(t1 == t2) // true, but apparently unrelated, a compromise warning + ^ +t5663-badwarneq.scala:52: error: ThingThree and Thingy are unrelated: they will most likely never compare equal + println(t4 == t2) // true, complains because ThingThree is final and Thingy not a subclass, stronger claim than unrelated + ^ +t5663-badwarneq.scala:55: error: comparing case class values of types ThingTwo and Some[Int] using `==' will always yield false + println(t3 == Some(1)) // false, warn on different cases + ^ +t5663-badwarneq.scala:56: error: comparing values of types ThingOne and Cousin using `==' will always yield false + println(t1 == c) // should warn + ^ +t5663-badwarneq.scala:64: error: comparing case class values of types Simple and SimpleSibling.type using `==' will always yield false + println(new Simple() == SimpleSibling) // like Some(1) == None, but needn't be final case + ^ +7 errors found diff --git a/test/files/neg/t5663-badwarneq.flags b/test/files/neg/t5663-badwarneq.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/neg/t5663-badwarneq.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/neg/t5663-badwarneq.scala b/test/files/neg/t5663-badwarneq.scala new file mode 100644 index 0000000000..56ec389c03 --- /dev/null +++ b/test/files/neg/t5663-badwarneq.scala @@ -0,0 +1,76 @@ + +// alias +trait Thingy + +class Gramps + +// sibling classes that extend a case class +case class Thing(i: Int) extends Gramps +class ThingOne(x:Int) extends Thing(x) +class ThingTwo(y:Int) extends Thing(y) with Thingy +final class ThingThree(z:Int) extends Thing(z) + +// not case cousin +class Cousin extends Gramps + +class SimpleParent +case class Simple() extends SimpleParent +case object SimpleSibling extends SimpleParent + +/* It's not possible to run partest without -deprecation. + * Since detecting the warnings requires a neg test with + * -Xfatal-warnings, and deprecation terminates the compile, + * we'll just comment out the nasty part. The point was + * just to show there's nothing special about a trait + * that extends a case class, which is only permitted + * (deprecatingly) by omitting the parens. + * +// common ancestor is something else +class AnyThing +case class SomeThing extends AnyThing // deprecation +class OtherThing extends AnyThing + +// how you inherit caseness doesn't matter +trait InThing extends SomeThing +class MyThing extends InThing +*/ + +object Test { + def main(a: Array[String]) { + // nothing to do with Gavin + println(new Some(1) == new Some(1)) // OK, true + println(new Some(1) == None) // Should complain on type, was: spuriously complains on fresh object + println(Some(1) == new Thing(1)) // Should complain on type, was: spuriously complains on fresh object + + val t1 = new ThingOne(11) + val t2: Thingy = new ThingTwo(11) + val t3 = new ThingTwo(11) + val t4 = new ThingThree(11) + val c = new Cousin + + println(t1 == t2) // true, but apparently unrelated, a compromise warning + println(t4 == t2) // true, complains because ThingThree is final and Thingy not a subclass, stronger claim than unrelated + println(t2 == t3) // OK, two Thingy + println(t3 == t2) // ditto with case receiver + println(t3 == Some(1)) // false, warn on different cases + println(t1 == c) // should warn + + // don't warn on fresh cases + println(new ThingOne(11) == t1) // OK, was: two cases not warnable on trunk + println(new ThingTwo(11) == t2) // true, was: spuriously complains on fresh object + println(new ThingOne(11) == t3) // two cases not warnable on trunk + println(new ThingTwo(11) == t3) // ditto + + println(new Simple() == SimpleSibling) // like Some(1) == None, but needn't be final case + + /* + val mine = new MyThing + val some = new SomeThing + val other = new OtherThing + println(mine == some) // OK, two Something + println(some == mine) + println(mine == other) // OK, two Anything? + println(mine == t1) // false + */ + } +} diff --git a/test/files/neg/t5666.check b/test/files/neg/t5666.check new file mode 100644 index 0000000000..4289b00ade --- /dev/null +++ b/test/files/neg/t5666.check @@ -0,0 +1,37 @@ +t5666.scala:2: error: class Any is abstract; cannot be instantiated + new Any + ^ +t5666.scala:3: error: class AnyVal is abstract; cannot be instantiated + new AnyVal + ^ +t5666.scala:4: error: Double does not have a constructor + new Double + ^ +t5666.scala:5: error: Float does not have a constructor + new Float + ^ +t5666.scala:6: error: Long does not have a constructor + new Long + ^ +t5666.scala:7: error: Int does not have a constructor + new Int + ^ +t5666.scala:8: error: Char does not have a constructor + new Char + ^ +t5666.scala:9: error: Short does not have a constructor + new Short + ^ +t5666.scala:10: error: Byte does not have a constructor + new Byte + ^ +t5666.scala:11: error: Boolean does not have a constructor + new Boolean + ^ +t5666.scala:12: error: Unit does not have a constructor + new Unit + ^ +t5666.scala:13: error: class Nothing is abstract; cannot be instantiated + new Nothing + ^ +12 errors found diff --git a/test/files/neg/t5666.scala b/test/files/neg/t5666.scala new file mode 100644 index 0000000000..ffaeaacdaf --- /dev/null +++ b/test/files/neg/t5666.scala @@ -0,0 +1,14 @@ +object t5666 { + new Any + new AnyVal + new Double + new Float + new Long + new Int + new Char + new Short + new Byte + new Boolean + new Unit + new Nothing +}
\ No newline at end of file diff --git a/test/files/neg/t5683.check b/test/files/neg/t5683.check new file mode 100644 index 0000000000..7c0e50113c --- /dev/null +++ b/test/files/neg/t5683.check @@ -0,0 +1,16 @@ +t5683.scala:12: error: inferred kinds of the type arguments (Object,Int) do not conform to the expected kinds of the type parameters (type M,type B). +Object's type parameters do not match type M's expected parameters: +class Object has no type parameters, but type M has one + val crash: K[StringW,Int,Int] = k{ (y: Int) => null: W[String, Int] } + ^ +t5683.scala:12: error: type mismatch; + found : Int => Test.W[String,Int] + required: Int => M[B] + val crash: K[StringW,Int,Int] = k{ (y: Int) => null: W[String, Int] } + ^ +t5683.scala:12: error: type mismatch; + found : Test.K[M,Int,B] + required: Test.K[Test.StringW,Int,Int] + val crash: K[StringW,Int,Int] = k{ (y: Int) => null: W[String, Int] } + ^ +three errors found diff --git a/test/files/neg/t5683.scala b/test/files/neg/t5683.scala new file mode 100644 index 0000000000..05ab035792 --- /dev/null +++ b/test/files/neg/t5683.scala @@ -0,0 +1,23 @@ +object Test { + trait NT[X] + trait W[W, A] extends NT[Int] + type StringW[T] = W[String, T] + trait K[M[_], A, B] + + def k[M[_], B](f: Int => M[B]): K[M, Int, B] = null + + val okay1: K[StringW,Int,Int] = k{ (y: Int) => null: StringW[Int] } + val okay2 = k[StringW,Int]{ (y: Int) => null: W[String, Int] } + + val crash: K[StringW,Int,Int] = k{ (y: Int) => null: W[String, Int] } + + // remove `extends NT[Int]`, and the last line gives an inference error + // rather than a crash. + // test/files/pos/t5683.scala:12: error: no type parameters for method k: (f: Int => M[B])Test.K[M,Int,B] exist so that it can be applied to arguments (Int => Test.W[String,Int]) + // --- because --- + // argument expression's type is not compatible with formal parameter type; + // found : Int => Test.W[String,Int] + // required: Int => ?M[?B] + // val crash: K[StringW,Int,Int] = k{ (y: Int) => null: W[String, Int] } + // ^ +} diff --git a/test/files/neg/t5689.check b/test/files/neg/t5689.check new file mode 100644 index 0000000000..6abc4c13f6 --- /dev/null +++ b/test/files/neg/t5689.check @@ -0,0 +1,7 @@ +t5689.scala:4: error: macro implementation has wrong shape:
+ required: (c: scala.reflect.makro.Context)(i: c.Expr[Double]): c.Expr[String]
+ found : (c: scala.reflect.makro.Context)(i: c.Expr[Double]): c.Expr[Int]
+type mismatch for return type: c.Expr[Int] does not conform to c.Expr[String]
+ def returnsString(i: Double): String = macro returnsIntImpl
+ ^
+one error found
diff --git a/test/files/neg/t5689.flags b/test/files/neg/t5689.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/files/neg/t5689.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/t5689.scala b/test/files/neg/t5689.scala new file mode 100644 index 0000000000..ef7a45b364 --- /dev/null +++ b/test/files/neg/t5689.scala @@ -0,0 +1,6 @@ +import scala.reflect.makro.Context + +object Macros { + def returnsString(i: Double): String = macro returnsIntImpl + def returnsIntImpl(c: Context)(i: c.Expr[Double]): c.Expr[Int] = ??? +} diff --git a/test/files/neg/t5702-neg-bad-and-wild.check b/test/files/neg/t5702-neg-bad-and-wild.check new file mode 100644 index 0000000000..eae81ad5f2 --- /dev/null +++ b/test/files/neg/t5702-neg-bad-and-wild.check @@ -0,0 +1,28 @@ +t5702-neg-bad-and-wild.scala:10: error: bad use of _* (a sequence pattern must be the last pattern) + case List(1, _*,) => // bad use of _* (a sequence pattern must be the last pattern) + ^ +t5702-neg-bad-and-wild.scala:10: error: illegal start of simple pattern + case List(1, _*,) => // bad use of _* (a sequence pattern must be the last pattern) + ^ +t5702-neg-bad-and-wild.scala:12: error: illegal start of simple pattern + case List(1, _*3,) => // illegal start of simple pattern + ^ +t5702-neg-bad-and-wild.scala:14: error: use _* to match a sequence + case List(1, x*) => // use _* to match a sequence + ^ +t5702-neg-bad-and-wild.scala:15: error: trailing * is not a valid pattern + case List(x*, 1) => // trailing * is not a valid pattern + ^ +t5702-neg-bad-and-wild.scala:16: error: trailing * is not a valid pattern + case (1, x*) => // trailing * is not a valid pattern + ^ +t5702-neg-bad-and-wild.scala:17: error: bad use of _* (sequence pattern not allowed) + case (1, x@_*) => // bad use of _* (sequence pattern not allowed) + ^ +t5702-neg-bad-and-wild.scala:23: error: bad use of _* (a sequence pattern must be the last pattern) + val K(ns @ _*, x) = k // bad use of _* (a sequence pattern must be the last pattern) + ^ +t5702-neg-bad-and-wild.scala:24: error: bad use of _* (sequence pattern not allowed) + val (b, _ * ) = Pair(5,6) // bad use of _* (sequence pattern not allowed) + ^ +9 errors found diff --git a/test/files/neg/t5702-neg-bad-and-wild.scala b/test/files/neg/t5702-neg-bad-and-wild.scala new file mode 100644 index 0000000000..3833a002b1 --- /dev/null +++ b/test/files/neg/t5702-neg-bad-and-wild.scala @@ -0,0 +1,29 @@ + +object Test { + case class K(i: Int) + + def main(args: Array[String]) { + val k = new K(9) + val is = List(1,2,3) + + is match { + case List(1, _*,) => // bad use of _* (a sequence pattern must be the last pattern) + // illegal start of simple pattern + case List(1, _*3,) => // illegal start of simple pattern + //case List(1, _*3:) => // poor recovery by parens + case List(1, x*) => // use _* to match a sequence + case List(x*, 1) => // trailing * is not a valid pattern + case (1, x*) => // trailing * is not a valid pattern + case (1, x@_*) => // bad use of _* (sequence pattern not allowed) + } + +// good syntax, bad semantics, detected by typer +//gowild.scala:14: error: star patterns must correspond with varargs parameters + val K(is @ _*) = k + val K(ns @ _*, x) = k // bad use of _* (a sequence pattern must be the last pattern) + val (b, _ * ) = Pair(5,6) // bad use of _* (sequence pattern not allowed) +// no longer complains +//bad-and-wild.scala:15: error: ')' expected but '}' found. + } +} + diff --git a/test/files/neg/t5702-neg-bad-brace.check b/test/files/neg/t5702-neg-bad-brace.check new file mode 100644 index 0000000000..503f7d95ed --- /dev/null +++ b/test/files/neg/t5702-neg-bad-brace.check @@ -0,0 +1,10 @@ +t5702-neg-bad-brace.scala:14: error: Unmatched closing brace '}' ignored here + case List(1, _*} => + ^ +t5702-neg-bad-brace.scala:14: error: illegal start of simple pattern + case List(1, _*} => + ^ +t5702-neg-bad-brace.scala:15: error: ')' expected but '}' found. + } + ^ +three errors found diff --git a/test/files/neg/t5702-neg-bad-brace.scala b/test/files/neg/t5702-neg-bad-brace.scala new file mode 100644 index 0000000000..16a341cf8c --- /dev/null +++ b/test/files/neg/t5702-neg-bad-brace.scala @@ -0,0 +1,17 @@ + +object Test { + + def main(args: Array[String]) { + val is = List(1,2,3) + + is match { +// the erroneous brace is ignored, so we can't halt on it. +// maybe brace healing can detect overlapping unmatched (...} +// In this case, the fix emits an extra error: +// t5702-neg-bad-brace.scala:10: error: Unmatched closing brace '}' ignored here +// t5702-neg-bad-brace.scala:10: error: illegal start of simple pattern (i.e., =>) +// t5702-neg-bad-brace.scala:11: error: ')' expected but '}' found. + case List(1, _*} => + } + } +} diff --git a/test/files/neg/t5702-neg-bad-xbrace.check b/test/files/neg/t5702-neg-bad-xbrace.check new file mode 100644 index 0000000000..d88638aee9 --- /dev/null +++ b/test/files/neg/t5702-neg-bad-xbrace.check @@ -0,0 +1,7 @@ +t5702-neg-bad-xbrace.scala:19: error: bad brace or paren after _* + case <year>{_*)}</year> => y + ^ +t5702-neg-bad-xbrace.scala:28: error: bad brace or paren after _* + val <top>{a, z@_*)}</top> = xml + ^ +two errors found diff --git a/test/files/neg/t5702-neg-bad-xbrace.scala b/test/files/neg/t5702-neg-bad-xbrace.scala new file mode 100644 index 0000000000..64bbdb18be --- /dev/null +++ b/test/files/neg/t5702-neg-bad-xbrace.scala @@ -0,0 +1,31 @@ + +object Test { + def main(args: Array[String]) { + /* PiS example, minus a brace + val yearMade = 1965 + val old = + <a>{ if (yearMade < 2000) <old>yearMade}</old> + else xml.NodeSeq.Empty } </a> + println(old) + */ + + // bad brace or paren after _* + // actually, we know it's a bad paren... + // we skip it because not in a context looking for rparen + val xyear = <year>1965</year> + val ancient = + <b>{ + val when = xyear match { + case <year>{_*)}</year> => y + case _ => "2035" + } + <old>{when}</old> + }</b> + println(ancient) + + val xml = <top><a>apple</a><b>boy</b><c>child</c></top> + // bad brace or paren after _* + val <top>{a, z@_*)}</top> = xml + println("A for "+ a +", ending with "+ z) + } +} diff --git a/test/files/neg/t5702-neg-ugly-xbrace.check b/test/files/neg/t5702-neg-ugly-xbrace.check new file mode 100644 index 0000000000..7d80bbf6be --- /dev/null +++ b/test/files/neg/t5702-neg-ugly-xbrace.check @@ -0,0 +1,19 @@ +t5702-neg-ugly-xbrace.scala:11: error: bad brace or paren after _* + val <top>{a, z@_*)</top> = xml + ^ +t5702-neg-ugly-xbrace.scala:12: error: Missing closing brace `}' assumed here + println("A for "+ a +", ending with "+ z) + ^ +t5702-neg-ugly-xbrace.scala:13: error: in XML literal: in XML content, please use '}}' to express '}' + } + ^ +t5702-neg-ugly-xbrace.scala:11: error: I encountered a '}' where I didn't expect one, maybe this tag isn't closed <top> + val <top>{a, z@_*)</top> = xml + ^ +t5702-neg-ugly-xbrace.scala:14: error: illegal start of simple pattern +} +^ +t5702-neg-ugly-xbrace.scala:14: error: '}' expected but eof found. +} + ^ +6 errors found diff --git a/test/files/neg/t5702-neg-ugly-xbrace.scala b/test/files/neg/t5702-neg-ugly-xbrace.scala new file mode 100644 index 0000000000..0ff7bfa09d --- /dev/null +++ b/test/files/neg/t5702-neg-ugly-xbrace.scala @@ -0,0 +1,14 @@ + +object Test { + def main(args: Array[String]) { + + val xml = <top><a>apple</a><b>boy</b><c>child</c></top> + // This is the more likely typo, and the uglier parse. + // We could turn it into a } if } does not follow (to + // avoid handing }} back to xml) but that is quite ad hoc. + // Assuming } for ) after _* would not be not outlandish. + // bad brace or paren after _* + val <top>{a, z@_*)</top> = xml + println("A for "+ a +", ending with "+ z) + } +} diff --git a/test/files/neg/t5728.check b/test/files/neg/t5728.check new file mode 100644 index 0000000000..14f9c42ae0 --- /dev/null +++ b/test/files/neg/t5728.check @@ -0,0 +1,4 @@ +t5728.scala:3: error: implicit classes must accept exactly one primary constructor parameter + implicit class Foo + ^ +one error found diff --git a/test/files/neg/t5728.scala b/test/files/neg/t5728.scala new file mode 100644 index 0000000000..99337d06d4 --- /dev/null +++ b/test/files/neg/t5728.scala @@ -0,0 +1,7 @@ +object Test { + + implicit class Foo + + implicit def Foo = new Foo + +} diff --git a/test/files/neg/t5735.check b/test/files/neg/t5735.check new file mode 100644 index 0000000000..f6e0028044 --- /dev/null +++ b/test/files/neg/t5735.check @@ -0,0 +1,6 @@ +t5735.scala:6: error: type mismatch; + found : (x: Int)Int <and> => String + required: Int + val z: Int = a + ^ +one error found diff --git a/test/files/neg/t5735.scala b/test/files/neg/t5735.scala new file mode 100644 index 0000000000..fde71ff962 --- /dev/null +++ b/test/files/neg/t5735.scala @@ -0,0 +1,7 @@ +abstract class Base { + def a: String = "one" +} +class Clazz extends Base { + def a(x: Int): Int = 2 + val z: Int = a +} diff --git a/test/files/neg/t5760-pkgobj-warn.check b/test/files/neg/t5760-pkgobj-warn.check new file mode 100644 index 0000000000..a89398c3f7 --- /dev/null +++ b/test/files/neg/t5760-pkgobj-warn.check @@ -0,0 +1,4 @@ +stalepkg_2.scala:6: error: Foo is already defined as class Foo in package object stalepkg + class Foo + ^ +one error found diff --git a/test/files/neg/t5760-pkgobj-warn/stalepkg_1.scala b/test/files/neg/t5760-pkgobj-warn/stalepkg_1.scala new file mode 100644 index 0000000000..ed4b731bb0 --- /dev/null +++ b/test/files/neg/t5760-pkgobj-warn/stalepkg_1.scala @@ -0,0 +1,11 @@ + +package object stalepkg { + class Foo +} + +package stalepkg { + object Test { + def main(args: Array[String]) { + } + } +} diff --git a/test/files/neg/t5760-pkgobj-warn/stalepkg_2.scala b/test/files/neg/t5760-pkgobj-warn/stalepkg_2.scala new file mode 100644 index 0000000000..9abcdbab17 --- /dev/null +++ b/test/files/neg/t5760-pkgobj-warn/stalepkg_2.scala @@ -0,0 +1,11 @@ + +package object stalepkg { +} + +package stalepkg { + class Foo + object Test { + def main(args: Array[String]) { + } + } +} diff --git a/test/files/neg/t5801.check b/test/files/neg/t5801.check new file mode 100644 index 0000000000..abf8e6e932 --- /dev/null +++ b/test/files/neg/t5801.check @@ -0,0 +1,22 @@ +t5801.scala:1: error: object sth is not a member of package scala +import scala.sth + ^ +t5801.scala:4: error: not found: value sth + def foo(a: Int)(implicit b: sth.Sth): Unit = {} + ^ +t5801.scala:7: error: not found: value sth + def bar(x: Int)(implicit y: Int): sth.Sth = null + ^ +t5801.scala:8: error: could not find implicit value for parameter y: Int + bar(1) + ^ +t5801.scala:10: error: not found: value sth + def meh(x: Int)(implicit a: sth.Sth, b: Int): Unit = {} + ^ +t5801.scala:13: error: not found: value sth + def meh2(x: Int)(implicit b: Int, a: sth.Sth): Unit = {} + ^ +t5801.scala:14: error: could not find implicit value for parameter b: Int + meh2(1) + ^ +7 errors found diff --git a/test/files/neg/t5801.scala b/test/files/neg/t5801.scala new file mode 100644 index 0000000000..d452222ac8 --- /dev/null +++ b/test/files/neg/t5801.scala @@ -0,0 +1,16 @@ +import scala.sth + +object Test extends App { + def foo(a: Int)(implicit b: sth.Sth): Unit = {} + foo(1) + + def bar(x: Int)(implicit y: Int): sth.Sth = null + bar(1) + + def meh(x: Int)(implicit a: sth.Sth, b: Int): Unit = {} + meh(1) + + def meh2(x: Int)(implicit b: Int, a: sth.Sth): Unit = {} + meh2(1) +} + diff --git a/test/files/neg/t5803.check b/test/files/neg/t5803.check new file mode 100644 index 0000000000..6a2de2e1df --- /dev/null +++ b/test/files/neg/t5803.check @@ -0,0 +1,4 @@ +t5803.scala:3: error: could not find implicit value for parameter ev: Nothing + new Foo(): String + ^ +one error found diff --git a/test/files/neg/t5803.scala b/test/files/neg/t5803.scala new file mode 100644 index 0000000000..f818272f86 --- /dev/null +++ b/test/files/neg/t5803.scala @@ -0,0 +1,4 @@ +object Test { + class Foo()(implicit ev: Nothing) + new Foo(): String +} diff --git a/test/files/neg/t5821.check b/test/files/neg/t5821.check new file mode 100644 index 0000000000..f9c00604bc --- /dev/null +++ b/test/files/neg/t5821.check @@ -0,0 +1,4 @@ +t5821.scala:1: error: not found: object SthImportant +import SthImportant._ + ^ +one error found diff --git a/test/files/neg/t5821.scala b/test/files/neg/t5821.scala new file mode 100644 index 0000000000..4af0a2bf7f --- /dev/null +++ b/test/files/neg/t5821.scala @@ -0,0 +1,8 @@ +import SthImportant._ + +class Bar + +class Foo2 { + type Sth = Array[Bar] + def foo(xs: Sth): Bar = if ((xs eq null) || (xs.length == 0)) null else xs(0) +} diff --git a/test/files/neg/t5845.check b/test/files/neg/t5845.check new file mode 100644 index 0000000000..8c6100d6de --- /dev/null +++ b/test/files/neg/t5845.check @@ -0,0 +1,7 @@ +t5845.scala:9: error: value +++ is not a member of Int + println(5 +++ 5) + ^ +t5845.scala:15: error: value +++ is not a member of Int + println(5 +++ 5) + ^ +two errors found diff --git a/test/files/neg/t5845.scala b/test/files/neg/t5845.scala new file mode 100644 index 0000000000..823c722c14 --- /dev/null +++ b/test/files/neg/t5845.scala @@ -0,0 +1,16 @@ +class Num[T] { + def mkOps = new Ops + class Ops { def +++(rhs: T) = () } +} + +class A { + implicit def infixOps[T, CC[X] <: Num[X]](lhs: T)(implicit num: CC[T]) = num.mkOps + implicit val n1 = new Num[Int] { } + println(5 +++ 5) +} + +class B { + implicit def infixOps[T, CC[X] <: Num[X]](lhs: T)(implicit num: CC[T]) : CC[T]#Ops = num.mkOps + implicit val n1 = new Num[Int] {} + println(5 +++ 5) +} diff --git a/test/files/neg/t591.check b/test/files/neg/t591.check index 5cdeebf079..d33f6d7a2f 100644 --- a/test/files/neg/t591.check +++ b/test/files/neg/t591.check @@ -1,4 +1,5 @@ -t591.scala:38: error: method input_= is defined twice in t591.scala +t591.scala:38: error: method input_= is defined twice + conflicting symbols both originated in file 't591.scala' def input_=(in : Input) = {} ^ one error found diff --git a/test/files/neg/t639.check b/test/files/neg/t639.check index 3b53da0515..6d41d872de 100644 --- a/test/files/neg/t639.check +++ b/test/files/neg/t639.check @@ -1,4 +1,7 @@ t639.scala:3: error: not found: object a import a._ ^ -one error found +t639.scala:5: error: not found: type B +@B + ^ +two errors found diff --git a/test/files/neg/t750.check b/test/files/neg/t750.check new file mode 100644 index 0000000000..c17ca334e6 --- /dev/null +++ b/test/files/neg/t750.check @@ -0,0 +1,15 @@ +Test_2.scala:4: error: type mismatch; + found : Array[Int] + required: Array[? with Object] +Note: Int >: ? with Object, but class Array is invariant in type T. +You may wish to investigate a wildcard type such as `_ >: ? with Object`. (SLS 3.2.10) + AO_1.f(a) + ^ +Test_2.scala:5: error: type mismatch; + found : Array[Int] + required: Array[Int] +Note: Int >: Int, but class Array is invariant in type T. +You may wish to investigate a wildcard type such as `_ >: Int`. (SLS 3.2.10) + AO_1.f[Int](a) + ^ +two errors found diff --git a/test/files/neg/t750/AO_1.java b/test/files/neg/t750/AO_1.java new file mode 100644 index 0000000000..4c7360ec6f --- /dev/null +++ b/test/files/neg/t750/AO_1.java @@ -0,0 +1,5 @@ +public class AO_1 { + public static <T> void f(T[] ar0) { + System.out.println(ar0); + } +}
\ No newline at end of file diff --git a/test/files/neg/t750/Test_2.scala b/test/files/neg/t750/Test_2.scala new file mode 100644 index 0000000000..80977431c5 --- /dev/null +++ b/test/files/neg/t750/Test_2.scala @@ -0,0 +1,6 @@ +// t750 +object Test extends App { + val a = Array(1, 2, 3) + AO_1.f(a) + AO_1.f[Int](a) +} diff --git a/test/files/neg/t750b.check b/test/files/neg/t750b.check new file mode 100644 index 0000000000..72a249191e --- /dev/null +++ b/test/files/neg/t750b.check @@ -0,0 +1,15 @@ +Test.scala:4: error: type mismatch; + found : Array[Int] + required: Array[? with Object] +Note: Int >: ? with Object, but class Array is invariant in type T. +You may wish to investigate a wildcard type such as `_ >: ? with Object`. (SLS 3.2.10) + AO.f(a) + ^ +Test.scala:5: error: type mismatch; + found : Array[Int] + required: Array[Int] +Note: Int >: Int, but class Array is invariant in type T. +You may wish to investigate a wildcard type such as `_ >: Int`. (SLS 3.2.10) + AO.f[Int](a) + ^ +two errors found diff --git a/test/files/neg/t750b/AO.java b/test/files/neg/t750b/AO.java new file mode 100644 index 0000000000..060baf9a3c --- /dev/null +++ b/test/files/neg/t750b/AO.java @@ -0,0 +1,5 @@ +public class AO { + public static <T> void f(T[] ar0) { + System.out.println(ar0); + } +}
\ No newline at end of file diff --git a/test/files/neg/t750b/Test.scala b/test/files/neg/t750b/Test.scala new file mode 100644 index 0000000000..5f792a7be8 --- /dev/null +++ b/test/files/neg/t750b/Test.scala @@ -0,0 +1,6 @@ +// t750 +object Test extends App { + val a = Array(1, 2, 3) + AO.f(a) + AO.f[Int](a) +} diff --git a/test/files/neg/t800.check b/test/files/neg/t800.check index 44c316a95b..8ba95fddde 100644 --- a/test/files/neg/t800.check +++ b/test/files/neg/t800.check @@ -1,13 +1,16 @@ t800.scala:4: error: qualification is already defined as value qualification val qualification = false; ^ -t800.scala:8: error: method qualification is defined twice in t800.scala +t800.scala:8: error: method qualification is defined twice + conflicting symbols both originated in file 't800.scala' val qualification = false; ^ -t800.scala:12: error: value qualification is defined twice in t800.scala +t800.scala:12: error: value qualification is defined twice + conflicting symbols both originated in file 't800.scala' var qualification = false; ^ -t800.scala:16: error: method qualification is defined twice in t800.scala +t800.scala:16: error: method qualification is defined twice + conflicting symbols both originated in file 't800.scala' var qualification = false; ^ four errors found diff --git a/test/files/neg/t900.check b/test/files/neg/t900.check index 047094ad6e..4611ceba8c 100644 --- a/test/files/neg/t900.check +++ b/test/files/neg/t900.check @@ -2,8 +2,8 @@ t900.scala:4: error: type mismatch; found : Foo.this.x.type (with underlying type Foo.this.bar) required: AnyRef Note that implicit conversions are not applicable because they are ambiguous: - both method any2stringadd in object Predef of type (x: Any)scala.runtime.StringAdd - and method any2stringfmt in object Predef of type (x: Any)scala.runtime.StringFormat + both method any2stringfmt in object Predef of type (x: Any)scala.runtime.StringFormat + and method any2stringadd in object Predef of type (x: Any)scala.runtime.StringAdd are possible conversion functions from Foo.this.x.type to AnyRef def break(): x.type ^ diff --git a/test/files/neg/t963.check b/test/files/neg/t963.check new file mode 100644 index 0000000000..1f2d0687b3 --- /dev/null +++ b/test/files/neg/t963.check @@ -0,0 +1,12 @@ +t963.scala:14: error: stable identifier required, but Test.this.y3.x found. + val w3 : y3.x.type = y3.x + ^ +t963.scala:17: error: stable identifier required, but Test.this.y4.x found. + val w4 : y4.x.type = y4.x + ^ +t963.scala:10: error: type mismatch; + found : Object{def x: Integer} + required: AnyRef{val x: Integer} + val y2 : { val x : java.lang.Integer } = new { def x = new java.lang.Integer(r.nextInt) } + ^ +three errors found diff --git a/test/files/neg/t963.scala b/test/files/neg/t963.scala new file mode 100644 index 0000000000..0cc2034299 --- /dev/null +++ b/test/files/neg/t963.scala @@ -0,0 +1,18 @@ +import scala.util.Random + +// Only y1 (val/val) should actually compile. +object Test { + val r = new Random() + + val y1 : { val x : java.lang.Integer } = new { val x = new java.lang.Integer(r.nextInt) } + val w1 : y1.x.type = y1.x + + val y2 : { val x : java.lang.Integer } = new { def x = new java.lang.Integer(r.nextInt) } + val w2 : y2.x.type = y2.x + + val y3 : { def x : java.lang.Integer } = new { val x = new java.lang.Integer(r.nextInt) } + val w3 : y3.x.type = y3.x + + val y4 : { def x : java.lang.Integer } = new { def x = new java.lang.Integer(r.nextInt) } + val w4 : y4.x.type = y4.x +} diff --git a/test/files/neg/t963b.check b/test/files/neg/t963b.check new file mode 100644 index 0000000000..9918a98c46 --- /dev/null +++ b/test/files/neg/t963b.check @@ -0,0 +1,6 @@ +t963b.scala:25: error: type mismatch; + found : B.type + required: AnyRef{val y: A} + B.f(B) + ^ +one error found diff --git a/test/files/neg/t963b.scala b/test/files/neg/t963b.scala new file mode 100644 index 0000000000..b34aae8095 --- /dev/null +++ b/test/files/neg/t963b.scala @@ -0,0 +1,26 @@ +// Soundness bug, at #963 and dup at #2079. +trait A { + type T + var v : T +} + +object B { + def f(x : { val y : A }) { x.y.v = x.y.v } + + var a : A = _ + var b : Boolean = false + def y : A = { + if(b) { + a = new A { type T = Int; var v = 1 } + a + } else { + a = new A { type T = String; var v = "" } + b = true + a + } + } +} + +object Test extends App { + B.f(B) +} diff --git a/test/files/neg/tailrec-2.check b/test/files/neg/tailrec-2.check index a918858773..d3432a7e76 100644 --- a/test/files/neg/tailrec-2.check +++ b/test/files/neg/tailrec-2.check @@ -1,4 +1,4 @@ -tailrec-2.scala:8: error: could not optimize @tailrec annotated method f: it contains a recursive call targetting a supertype +tailrec-2.scala:8: error: could not optimize @tailrec annotated method f: it contains a recursive call targeting supertype Super[A] @annotation.tailrec final def f[B >: A](mem: List[B]): List[B] = (null: Super[A]).f(mem) ^ tailrec-2.scala:9: error: @tailrec annotated method contains no recursive calls diff --git a/test/files/neg/tailrec.check b/test/files/neg/tailrec.check index ad92731b2c..946d3421e6 100644 --- a/test/files/neg/tailrec.check +++ b/test/files/neg/tailrec.check @@ -4,9 +4,9 @@ tailrec.scala:45: error: could not optimize @tailrec annotated method facfail: i tailrec.scala:50: error: could not optimize @tailrec annotated method fail1: it is neither private nor final so can be overridden @tailrec def fail1(x: Int): Int = fail1(x) ^ -tailrec.scala:55: error: could not optimize @tailrec annotated method fail2: it contains a recursive call not in tail position - case x :: xs => x :: fail2[T](xs) - ^ +tailrec.scala:53: error: could not optimize @tailrec annotated method fail2: it contains a recursive call not in tail position + @tailrec final def fail2[T](xs: List[T]): List[T] = xs match { + ^ tailrec.scala:59: error: could not optimize @tailrec annotated method fail3: it is called recursively with different type arguments @tailrec final def fail3[T](x: Int): Int = fail3(x - 1) ^ diff --git a/test/files/neg/unreachablechar.flags b/test/files/neg/unreachablechar.flags new file mode 100644 index 0000000000..809e9ff2f2 --- /dev/null +++ b/test/files/neg/unreachablechar.flags @@ -0,0 +1 @@ + -Xoldpatmat diff --git a/test/files/neg/virtpatmat_reach_null.check b/test/files/neg/virtpatmat_reach_null.check new file mode 100644 index 0000000000..595c8ec889 --- /dev/null +++ b/test/files/neg/virtpatmat_reach_null.check @@ -0,0 +1,4 @@ +virtpatmat_reach_null.scala:13: error: unreachable code + case _ => // unreachable + ^ +one error found diff --git a/test/files/neg/virtpatmat_reach_null.flags b/test/files/neg/virtpatmat_reach_null.flags new file mode 100644 index 0000000000..e8fb65d50c --- /dev/null +++ b/test/files/neg/virtpatmat_reach_null.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/test/files/neg/virtpatmat_reach_null.scala b/test/files/neg/virtpatmat_reach_null.scala new file mode 100644 index 0000000000..6314a5b1d8 --- /dev/null +++ b/test/files/neg/virtpatmat_reach_null.scala @@ -0,0 +1,19 @@ +sealed abstract class Const { + final def excludes(other: Const) = + (this, other) match { + case (_, NullConst) => + case (NullConst, _) => + case (_: ValueConst, _: ValueConst) => + case (_: ValueConst, _: TypeConst) => + case (_: TypeConst, _: ValueConst) => + case (_: TypeConst, _: TypeConst) => + case (null, _) => + case (_, null) => + case null => + case _ => // unreachable + } +} + +sealed class TypeConst extends Const +sealed class ValueConst extends Const +case object NullConst extends Const diff --git a/test/files/neg/virtpatmat_reach_sealed_unsealed.check b/test/files/neg/virtpatmat_reach_sealed_unsealed.check new file mode 100644 index 0000000000..10638eff52 --- /dev/null +++ b/test/files/neg/virtpatmat_reach_sealed_unsealed.check @@ -0,0 +1,14 @@ +virtpatmat_reach_sealed_unsealed.scala:16: error: match may not be exhaustive. +It would fail on the following input: false + (true: Boolean) match { case true => } // not exhaustive, but reachable + ^ +virtpatmat_reach_sealed_unsealed.scala:18: error: unreachable code + (true: Boolean) match { case true => case false => case _ => } // exhaustive, last case is unreachable + ^ +virtpatmat_reach_sealed_unsealed.scala:19: error: unreachable code + (true: Boolean) match { case true => case false => case _: Boolean => } // exhaustive, last case is unreachable + ^ +virtpatmat_reach_sealed_unsealed.scala:20: error: unreachable code + (true: Boolean) match { case true => case false => case _: Any => } // exhaustive, last case is unreachable + ^ +four errors found diff --git a/test/files/neg/virtpatmat_reach_sealed_unsealed.flags b/test/files/neg/virtpatmat_reach_sealed_unsealed.flags new file mode 100644 index 0000000000..e8fb65d50c --- /dev/null +++ b/test/files/neg/virtpatmat_reach_sealed_unsealed.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/test/files/neg/virtpatmat_reach_sealed_unsealed.scala b/test/files/neg/virtpatmat_reach_sealed_unsealed.scala new file mode 100644 index 0000000000..13911dbd78 --- /dev/null +++ b/test/files/neg/virtpatmat_reach_sealed_unsealed.scala @@ -0,0 +1,21 @@ +sealed abstract class X +sealed case class A(x: Int) extends X + +// test reachability on mixed sealed / non-sealed matches +object Test extends App { + val B: X = A(0) + val C: X = A(1) + + // all cases are reachable and the match is exhaustive + (C: X) match { + case B => + case C => + case A(_) => + } + + (true: Boolean) match { case true => } // not exhaustive, but reachable + (true: Boolean) match { case true => case false => } // exhaustive, reachable + (true: Boolean) match { case true => case false => case _ => } // exhaustive, last case is unreachable + (true: Boolean) match { case true => case false => case _: Boolean => } // exhaustive, last case is unreachable + (true: Boolean) match { case true => case false => case _: Any => } // exhaustive, last case is unreachable +}
\ No newline at end of file diff --git a/test/files/pos/annot-inner.scala b/test/files/pos/annot-inner.scala index f2ecb5ddb3..9f155a5a83 100644 --- a/test/files/pos/annot-inner.scala +++ b/test/files/pos/annot-inner.scala @@ -1,5 +1,5 @@ object test { - class annot extends Annotation + class annot extends scala.annotation.Annotation def foo { @annot def bar(i: Int): Int = i diff --git a/test/files/pos/annotDepMethType.scala b/test/files/pos/annotDepMethType.scala index b5e7cb9e8b..079ca6224c 100644 --- a/test/files/pos/annotDepMethType.scala +++ b/test/files/pos/annotDepMethType.scala @@ -1,4 +1,4 @@ -case class pc(calls: Any*) extends TypeConstraint +case class pc(calls: Any*) extends annotation.TypeConstraint object Main { class C0 { def baz: String = "" } diff --git a/test/files/pos/annotations.scala b/test/files/pos/annotations.scala index 4e5fddda39..706a715bad 100644 --- a/test/files/pos/annotations.scala +++ b/test/files/pos/annotations.scala @@ -1,5 +1,5 @@ -class ann(i: Int) extends Annotation -class cfann(x: String) extends ClassfileAnnotation +class ann(i: Int) extends scala.annotation.Annotation +class cfann(x: String) extends annotation.ClassfileAnnotation // annotations on abstract types abstract class C1[@serializable @cloneable +T, U, V[_]] @@ -91,9 +91,9 @@ trait BeanF { } -class Ann3(arr: Array[String]) extends ClassfileAnnotation -class Ann4(i: Int) extends ClassfileAnnotation -class Ann5(value: Class[_]) extends ClassfileAnnotation +class Ann3(arr: Array[String]) extends annotation.ClassfileAnnotation +class Ann4(i: Int) extends annotation.ClassfileAnnotation +class Ann5(value: Class[_]) extends annotation.ClassfileAnnotation object Test3 { final val i = 1083 diff --git a/test/files/pos/anyval-children.flags b/test/files/pos/anyval-children.flags deleted file mode 100644 index 80fce051e6..0000000000 --- a/test/files/pos/anyval-children.flags +++ /dev/null @@ -1 +0,0 @@ --Ystop-after:erasure
\ No newline at end of file diff --git a/test/files/pos/arrays3.scala b/test/files/pos/arrays3.scala new file mode 100644 index 0000000000..f96be0b427 --- /dev/null +++ b/test/files/pos/arrays3.scala @@ -0,0 +1,11 @@ +trait Foo { + type Repr <: String + def f2(x: Repr) = x.length +} +trait Fooz[Repr <: Array[_]] { + def f0(x: Repr) = x.length +} + +trait Bar[Repr <: List[_]] extends Foo with Fooz[Array[Int]] { + def f1(x: Repr) = x.length +} diff --git a/test/files/pos/attributes.scala b/test/files/pos/attributes.scala index f3bbb4c42e..ec735d0aae 100644 --- a/test/files/pos/attributes.scala +++ b/test/files/pos/attributes.scala @@ -52,15 +52,15 @@ object O6 { } object myAttrs { - class a1 extends scala.Annotation; - class a2(x: Int) extends scala.Annotation; - class a3(x: a1) extends scala.Annotation; + class a1 extends scala.annotation.Annotation; + class a2(x: Int) extends scala.annotation.Annotation; + class a3(x: a1) extends scala.annotation.Annotation; } -class a4(ns: Array[Int]) extends scala.Annotation; +class a4(ns: Array[Int]) extends scala.annotation.Annotation; object O7 { - class a1 extends scala.Annotation; - class a2(x: Int) extends scala.Annotation; - class a3(x: a1) extends scala.Annotation; + class a1 extends scala.annotation.Annotation; + class a2(x: Int) extends scala.annotation.Annotation; + class a3(x: a1) extends scala.annotation.Annotation; final val x = new a1; @a1 class C1; diff --git a/test/files/pos/contextbounds-implicits-new.scala b/test/files/pos/contextbounds-implicits-new.scala new file mode 100644 index 0000000000..71b3cca36f --- /dev/null +++ b/test/files/pos/contextbounds-implicits-new.scala @@ -0,0 +1,8 @@ +/* Tests implicit parameters in the presence of context bounds. + * See Section 7.4 of the Scala Language Specification. + */ +class C { + + def f[T: TypeTag, S: TypeTag](x: T, y: S)(implicit p: C) { } + +} diff --git a/test/files/pos/contextbounds-implicits.scala b/test/files/pos/contextbounds-implicits-old.scala index f9113ee320..f9113ee320 100644 --- a/test/files/pos/contextbounds-implicits.scala +++ b/test/files/pos/contextbounds-implicits-old.scala diff --git a/test/files/pos/exhaust_alternatives.flags b/test/files/pos/exhaust_alternatives.flags new file mode 100644 index 0000000000..e8fb65d50c --- /dev/null +++ b/test/files/pos/exhaust_alternatives.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/test/files/pos/exhaust_alternatives.scala b/test/files/pos/exhaust_alternatives.scala new file mode 100644 index 0000000000..cc81d0be7d --- /dev/null +++ b/test/files/pos/exhaust_alternatives.scala @@ -0,0 +1,10 @@ +sealed abstract class X +sealed case class A(x: Boolean) extends X +case object B extends X + +object Test { + def test(x: X) = x match { + case A(true) => + case A(false) | B => + } +}
\ No newline at end of file diff --git a/test/files/pos/exhaustive_heuristics.scala b/test/files/pos/exhaustive_heuristics.scala new file mode 100644 index 0000000000..297900510b --- /dev/null +++ b/test/files/pos/exhaustive_heuristics.scala @@ -0,0 +1,26 @@ +// tests exhaustivity doesn't give warnings (due to its heuristic rewrites kicking in or it backing off) +object Test { + // List() => Nil + List(1) match { + case List() => + case x :: xs => + } + + // we don't look into guards + val turnOffChecks = true + List(1) match { + case _ if turnOffChecks => + } + + // we back off when there are any user-defined extractors + // in fact this is exhaustive, but we pretend we don't know since List's unapplySeq is not special to the compiler + // to compensate our ignorance, we back off + // well, in truth, we do rewrite List() to Nil, but otherwise we do nothing + // the full rewrite List(a, b) to a :: b :: Nil, for example is planned (but not sure it's a good idea) + List(true, false) match { + case List(_, _, _*) => + case List(node, _*) => + case Nil => + } + +}
\ No newline at end of file diff --git a/test/files/pos/gen-traversable-methods.scala b/test/files/pos/gen-traversable-methods.scala new file mode 100644 index 0000000000..2604a09f11 --- /dev/null +++ b/test/files/pos/gen-traversable-methods.scala @@ -0,0 +1,20 @@ + + + +import collection._ + + + +object Test { + + def main(args: Array[String]) { + val gen: GenTraversable[Int] = List(1, 2, 3) + gen.head + gen.headOption + gen.tail + gen.last + gen.lastOption + gen.init + } + +} diff --git a/test/files/pos/generic-sigs.scala b/test/files/pos/generic-sigs.scala index 40ec044656..b112766056 100644 --- a/test/files/pos/generic-sigs.scala +++ b/test/files/pos/generic-sigs.scala @@ -1,3 +1,5 @@ +import language.existentials + object A { def f1 = List(classOf[Int], classOf[String]) def f2 = List(classOf[String], classOf[Int]) @@ -15,4 +17,4 @@ object A { class Boppy[+T1,-T2] def g1 = new Boppy[t forSome { type t <: Int }, u forSome { type u <: String }] -}
\ No newline at end of file +} diff --git a/test/files/pos/hkarray.flags b/test/files/pos/hkarray.flags index e8fb65d50c..e745d8bbe3 100644 --- a/test/files/pos/hkarray.flags +++ b/test/files/pos/hkarray.flags @@ -1 +1 @@ --Xfatal-warnings
\ No newline at end of file +-Xfatal-warnings -language:higherKinds
\ No newline at end of file diff --git a/test/files/pos/implicits-new.scala b/test/files/pos/implicits-new.scala new file mode 100644 index 0000000000..7eb7e100c3 --- /dev/null +++ b/test/files/pos/implicits-new.scala @@ -0,0 +1,89 @@ +// #1435 +object t1435 { + implicit def a(s:String):String = error("") + implicit def a(i:Int):String = error("") + implicit def b(i:Int):String = error("") +} + +class C1435 { + val v:String = { + import t1435.a + 2 + } +} + +// #1492 +class C1492 { + + class X + + def foo(x: X => X) {} + + foo ( implicit x => implicitly[X] ) + foo { implicit x => implicitly[X] } +} + +// #1579 +object Test1579 { + class Column + class Query[E](val value: E) + class Invoker(q: Any) { val foo = null } + + implicit def unwrap[C](q: Query[C]) = q.value + implicit def invoker(q: Query[Column]) = new Invoker(q) + + val q = new Query(new Column) + q.foo +} +// #1625 +object Test1625 { + + class Wrapped(x:Any) { + def unwrap() = x + } + + implicit def byName[A](x: =>A) = new Wrapped(x) + + implicit def byVal[A](x: A) = x + + def main(args: Array[String]) = { + +// val res:Wrapped = 7 // works + + val res = 7.unwrap() // doesn't work + + println("=> result: " + res) + } +} + +object Test2188 { + implicit def toJavaList[A: ArrayTag](t:collection.Seq[A]):java.util.List[A] = java.util.Arrays.asList(t.toArray:_*) + + val x: java.util.List[String] = List("foo") +} + +object TestNumericWidening { + val y = 1 + val x: java.lang.Long = y +} + +// #2709 +package foo2709 { + class A + class B + + package object bar { + implicit def a2b(a: A): B = new B + } + + package bar { + object test { + new A: B + } + } +} + +// Problem with specs +object specsProblem { + println(implicitly[ConcreteTypeTag[Class[_]]]) +} diff --git a/test/files/pos/implicits.scala.temporarily.disabled b/test/files/pos/implicits-old.scala index 2c01dd0ba8..2c01dd0ba8 100644 --- a/test/files/pos/implicits.scala.temporarily.disabled +++ b/test/files/pos/implicits-old.scala diff --git a/test/files/pos/macro-deprecate-dont-touch-backquotedidents.flags b/test/files/pos/macro-deprecate-dont-touch-backquotedidents.flags new file mode 100644 index 0000000000..e8fb65d50c --- /dev/null +++ b/test/files/pos/macro-deprecate-dont-touch-backquotedidents.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/test/files/neg/macro-deprecate-dont-touch-backquotedidents.scala b/test/files/pos/macro-deprecate-dont-touch-backquotedidents.scala index dee2f1de3b..69a7333011 100644 --- a/test/files/neg/macro-deprecate-dont-touch-backquotedidents.scala +++ b/test/files/pos/macro-deprecate-dont-touch-backquotedidents.scala @@ -44,12 +44,12 @@ package foo { } } -object Test12 { - val Some(`macro`) = Some(42) - `macro` match { - case `macro` => println(`macro`) - } -} +//object Test12 { +// val Some(`macro`) = Some(42) +// `macro` match { +// case `macro` => println(`macro`) +// } +//} object Test13 { def `macro` = 2 diff --git a/test/files/pos/manifest1-new.scala b/test/files/pos/manifest1-new.scala new file mode 100644 index 0000000000..645bd42665 --- /dev/null +++ b/test/files/pos/manifest1-new.scala @@ -0,0 +1,21 @@ +import scala.reflect.TypeTag + +object Test { + def foo[T](x: T)(implicit m: TypeTag[T]) { + foo(List(x)) + } + foo(1) + foo("abc") + foo(List(1, 2, 3)) + val x: List[Int] with Ordered[List[Int]] = null + foo(x) + foo[x.type](x) + abstract class C { type T = String; val x: T } + val c = new C { val x = "abc" } + foo(c.x) + abstract class D { type T; implicit val m: TypeTag[T]; val x: T } + val stringm = implicitly[TypeTag[String]] + val d: D = new D { type T = String; val m = stringm; val x = "x" } + import d.m + foo(d.x) +} diff --git a/test/files/pos/manifest1.scala.temporarily.disabled b/test/files/pos/manifest1-old.scala index 8901aa7437..8901aa7437 100644 --- a/test/files/pos/manifest1.scala.temporarily.disabled +++ b/test/files/pos/manifest1-old.scala diff --git a/test/files/pos/noproductN.flags b/test/files/pos/noproductN.flags deleted file mode 100644 index 14b05e7354..0000000000 --- a/test/files/pos/noproductN.flags +++ /dev/null @@ -1 +0,0 @@ --Yno-productN
\ No newline at end of file diff --git a/test/files/pos/noproductN.scala b/test/files/pos/noproductN.scala deleted file mode 100644 index 856d960b7d..0000000000 --- a/test/files/pos/noproductN.scala +++ /dev/null @@ -1,2 +0,0 @@ -object Foo { type S = String } -case class Foo(x: Foo.S) { } diff --git a/test/files/pos/nothing_manifest_disambig-new.scala b/test/files/pos/nothing_manifest_disambig-new.scala new file mode 100644 index 0000000000..a60b0fdbf8 --- /dev/null +++ b/test/files/pos/nothing_manifest_disambig-new.scala @@ -0,0 +1,10 @@ +object Test { + def mani[T: TypeTag](xs: T) = xs + mani(List()) + + def listElMani[T: TypeTag](xs: List[T]) = xs + listElMani(List()) + + def foo[A, C](m : C)(implicit ev: C <:< Traversable[A], mani: TypeTag[A]): (C, A, TypeTag[A]) = (m, m.head, mani) + foo(List(1,2,3)) +}
\ No newline at end of file diff --git a/test/files/pos/nothing_manifest_disambig.scala b/test/files/pos/nothing_manifest_disambig-old.scala index 076742033f..076742033f 100644 --- a/test/files/pos/nothing_manifest_disambig.scala +++ b/test/files/pos/nothing_manifest_disambig-old.scala diff --git a/test/files/pos/overloaded_extractor_and_regular_def.scala b/test/files/pos/overloaded_extractor_and_regular_def.scala new file mode 100644 index 0000000000..c8e7da5cad --- /dev/null +++ b/test/files/pos/overloaded_extractor_and_regular_def.scala @@ -0,0 +1,32 @@ +trait TreesBase { + type Tree + + type Apply <: Tree + + val Apply: ApplyExtractor + + abstract class ApplyExtractor { + def apply(x: Int): Apply + def unapply(apply: Apply): Option[Int] + } +} + +trait TreesApi extends TreesBase { + def Apply(x: String) +} + +class Universe extends TreesApi { + abstract class Tree + case class Apply(x: Int) extends Tree + object Apply extends ApplyExtractor + def Apply(x: String) = Apply(x.toInt) +} + +object Test extends App { + def foo(tapi: TreesApi) { + import tapi._ + def bar(tree: Tree) { + val Apply(x) = tree + } + } +}
\ No newline at end of file diff --git a/test/files/pos/rangepos-patmat.flags b/test/files/pos/rangepos-patmat.flags new file mode 100644 index 0000000000..281f0a10cd --- /dev/null +++ b/test/files/pos/rangepos-patmat.flags @@ -0,0 +1 @@ +-Yrangepos diff --git a/test/files/pos/rangepos-patmat.scala b/test/files/pos/rangepos-patmat.scala new file mode 100644 index 0000000000..98c842aaf8 --- /dev/null +++ b/test/files/pos/rangepos-patmat.scala @@ -0,0 +1,4 @@ +class Foo { + def test: PartialFunction[Any, String] = { case _ => "ok" } + +} diff --git a/test/files/pos/spec-annotations.scala b/test/files/pos/spec-annotations.scala index 35cab6de09..48281e5df5 100644 --- a/test/files/pos/spec-annotations.scala +++ b/test/files/pos/spec-annotations.scala @@ -1,4 +1,4 @@ -class ann(i: Int) extends Annotation +class ann(i: Int) extends scala.annotation.Annotation // annotations on abstract types abstract class C1[@serializable @cloneable +T, U, V[_]] diff --git a/test/files/pos/spec-constr-new.scala b/test/files/pos/spec-constr-new.scala new file mode 100644 index 0000000000..7cd02b0680 --- /dev/null +++ b/test/files/pos/spec-constr-new.scala @@ -0,0 +1,7 @@ +class SparseArray2[@specialized(Int) T:ArrayTag](val maxSize: Int, initialLength:Int = 3) { + private var data = new Array[T](initialLength); + private var index = new Array[Int](initialLength); + + // comment out to compile correctly + data.length + 3; +} diff --git a/test/files/pos/spec-constr.scala b/test/files/pos/spec-constr-old.scala index e908b65a41..e908b65a41 100644 --- a/test/files/pos/spec-constr.scala +++ b/test/files/pos/spec-constr-old.scala diff --git a/test/files/pos/spec-doubledef-new.scala b/test/files/pos/spec-doubledef-new.scala new file mode 100644 index 0000000000..33f1e82b6e --- /dev/null +++ b/test/files/pos/spec-doubledef-new.scala @@ -0,0 +1,28 @@ +object Test { + def fn[@specialized T, @specialized U](t : T => Int, u : U => Int) : T = + null.asInstanceOf[T] +} + +trait A[@specialized(Int) T] { + var value: T + def getWith[@specialized(Int) Z](f: T => Z) = f(value) +} + +class C extends A[Int] { + var value = 10 + override def getWith[@specialized(Int) Z](f: Int => Z) = f(value) +} + +abstract class B[T, @specialized(scala.Int) U : TypeTag, @specialized(scala.Int) V <% Ordered[V]] { + val u: U + val v: V + + def f(t: T, v2: V): Pair[U, V] = { + val m: Array[U] = null + if (m.isEmpty) { + Pair(u, v) + } else { + Pair(u, v2) + } + } +} diff --git a/test/files/pos/spec-doubledef.scala b/test/files/pos/spec-doubledef-old.scala index 86b0d857d3..86b0d857d3 100644 --- a/test/files/pos/spec-doubledef.scala +++ b/test/files/pos/spec-doubledef-old.scala diff --git a/test/files/pos/spec-fields-new.scala b/test/files/pos/spec-fields-new.scala new file mode 100644 index 0000000000..ddd8bd6624 --- /dev/null +++ b/test/files/pos/spec-fields-new.scala @@ -0,0 +1,10 @@ +abstract class Foo[@specialized T: ArrayTag, U <: Ordered[U]](x: T, size: Int) { + var y: T + var z: T = x + + def initialSize = 16 + val array = new Array[T](initialSize + size) + + def getZ = z + def setZ(zz: T) = z = zz +} diff --git a/test/files/pos/spec-fields.scala b/test/files/pos/spec-fields-old.scala index 26a8c4ffbd..26a8c4ffbd 100644 --- a/test/files/pos/spec-fields.scala +++ b/test/files/pos/spec-fields-old.scala diff --git a/test/files/pos/spec-params-new.scala b/test/files/pos/spec-params-new.scala new file mode 100644 index 0000000000..5fe0c82d40 --- /dev/null +++ b/test/files/pos/spec-params-new.scala @@ -0,0 +1,32 @@ +class Foo[@specialized A: ArrayTag] { + + // conflicting in bounds, expect a normalized member calling m + // and bridge + implementation in specialized subclasses + // and overloads here according to specialization on A + def m1[@specialized B <: A](x: B, y: A) = + goal(x) + + // conflicting, unsolvable, expect a warning + def m2[@specialized B <: String](x: B) = x.concat("a") + + // conflicting in bounds, no mention of other spec members + // expect an overload here plus implementation in + // compatible specialized subclasses + def m3[@specialized B >: A](x: B) = () + + // non-conflicting, expect a normalized overload implementation here + def m4[@specialized T, U <: Ordered[T]](x: T, y: U) = () + + // non-conflicting, expect a normalized overload implementation here + def m5[@specialized B](x: B) = x + + // non-conflicting, expect a normalized implementation here + // and specialized implementations for all expansions in specialized subclasses + def m6[@specialized B](x: B, y: A) = + goal(y) + + def goal(x: A) = { + val xs = new Array[A](1) + xs(0) = x + } +} diff --git a/test/files/pos/spec-params.scala b/test/files/pos/spec-params-old.scala index f522512846..f522512846 100644 --- a/test/files/pos/spec-params.scala +++ b/test/files/pos/spec-params-old.scala diff --git a/test/files/pos/spec-sparsearray-new.scala b/test/files/pos/spec-sparsearray-new.scala new file mode 100644 index 0000000000..0659bf7926 --- /dev/null +++ b/test/files/pos/spec-sparsearray-new.scala @@ -0,0 +1,24 @@ +import scala.collection.mutable.MapLike + +class SparseArray[@specialized(Int) T:ArrayTag] extends collection.mutable.Map[Int,T] with collection.mutable.MapLike[Int,T,SparseArray[T]] { + override def get(x: Int) = { + val ind = findOffset(x) + if(ind < 0) None else Some(error("ignore")) + } + + /** + * Returns the offset into index and data for the requested vector + * index. If the requested index is not found, the return value is + * negative and can be converted into an insertion point with -(rv+1). + */ + private def findOffset(i : Int) : Int = { + error("impl doesn't matter") + } + + override def apply(i : Int) : T = { error("ignore") } + override def update(i : Int, value : T) = error("ignore") + override def empty = new SparseArray[T] + def -=(ind: Int) = error("ignore") + def +=(kv: (Int,T)) = error("ignore") + override final def iterator = error("ignore") +} diff --git a/test/files/pos/spec-sparsearray.scala b/test/files/pos/spec-sparsearray-old.scala index ea7710a785..ea7710a785 100644 --- a/test/files/pos/spec-sparsearray.scala +++ b/test/files/pos/spec-sparsearray-old.scala diff --git a/test/files/pos/t1029/Test_1.scala b/test/files/pos/t1029/Test_1.scala index e828087f2c..d268c71429 100644 --- a/test/files/pos/t1029/Test_1.scala +++ b/test/files/pos/t1029/Test_1.scala @@ -1,4 +1,4 @@ -class ann(a: Array[Int]) extends StaticAnnotation +class ann(a: Array[Int]) extends annotation.StaticAnnotation object Test1 { // bug #1029 diff --git a/test/files/pos/t1133.scala b/test/files/pos/t1133.scala new file mode 100644 index 0000000000..4538de5f5f --- /dev/null +++ b/test/files/pos/t1133.scala @@ -0,0 +1,32 @@ +object Match +{ + def main(args: Array[String]) = { + args(0) match { + case Extractor1(Extractor2(Extractor3("dog", "dog", "dog"), x2, x3), b, c, Extractor3("b", "b", f), e) => println(e) + case Extractor3(Extractor2(Extractor1("a", "aa", "aaa", "aa", "a"), Extractor2("a", "aa", "aaa"), e), y, z) => println(e) + case Extractor2(Extractor3("a", "a", x), Extractor3("b", "b", y), Extractor3("c", "c", z)) => println(z) + case _ => println("fail") + } + } + + object Extractor1 { + def unapply(x: Any) = x match { + case x: String => Some(x, x+x, x+x+x, x+x, x) + case _ => None + } + } + + object Extractor2 { + def unapply(x: Any) = x match { + case x: String => Some(x, x+x, x+x+x) + case _ => None + } + } + + object Extractor3 { + def unapply(x: Any) = x match { + case x: String => Some(x, x, x) + case _ => None + } + } +} diff --git a/test/files/pos/t1203.scala b/test/files/pos/t1203.scala index 4938621aa9..062ef93fc6 100644 --- a/test/files/pos/t1203.scala +++ b/test/files/pos/t1203.scala @@ -1,4 +1,4 @@ -case class ant(t: String) extends Annotation +case class ant(t: String) extends scala.annotation.Annotation object Test { def main(args: Array[String]): Unit = { val a: scala.xml.NodeSeq @ant("12") = Nil diff --git a/test/files/pos/t1279a.scala b/test/files/pos/t1279a.scala index 9212b583d4..18b1e53f46 100644 --- a/test/files/pos/t1279a.scala +++ b/test/files/pos/t1279a.scala @@ -1,40 +1,39 @@ -// see #13 -// providing the type parameter in the recursive call to all4Impl -// avoids the problem - - // covariant linked list -abstract class M -{ self => - - type T - final type selfType = M {type T <: self.T} - type actualSelfType >: self.type <: selfType - - def next: selfType +abstract class M { + self => + type T + final type selfType = M {type T <: self.T} + type actualSelfType >: self.type <: selfType - // I don't understand why this doesn't compile, but that's a separate matter - // error: method all2 cannot be accessed in M.this.selfType - // because its instance type => Stream[M{type T <: M.this.selfType#T}] - // contains a malformed type: M.this.selfType#T - // def all2: Stream[M {type T <: self.T}] = Stream.cons(self: actualSelfType, next.all2) + def next: selfType + // I don't understand why this doesn't compile, but that's a separate matter + // error: method all2 cannot be accessed in M.this.selfType + // because its instance type => Stream[M{type T <: M.this.selfType#T}] + // contains a malformed type: M.this.selfType#T + def all2: Stream[M {type T <: self.T}] = Stream.cons(self: actualSelfType, next.all2) - // compiles successfully - // def all3: Stream[M {type T <: self.T}] = all3Impl(self: actualSelfType) - // private def all3Impl(first: M {type T <: self.T}): Stream[M {type T <: self.T}] = Stream.cons(first, all3Impl(first.next)) + // compiles successfully + def all3: Stream[M {type T <: self.T}] = all3Impl(self: actualSelfType) + private def all3Impl(first: M {type T <: self.T}): Stream[M {type T <: self.T}] = Stream.cons(first, all3Impl(first.next)) - - - def all4: Stream[M {type T <: self.T}] = Unrelated.all4Impl[T](self: actualSelfType) + def all4: Stream[M {type T <: self.T}] = Unrelated.all4Impl[T](self: actualSelfType) } -object Unrelated -{ - // TODO!!! fix this bug for real, it compiles successfully, but weird types are inferred - // def all4Impl[U](first: M {type T <: U}): Stream[M {type T <: U}] = Stream.cons(first, all4Impl(first.next)) - -// compiles successfully - def all4Impl[U](first: M {type T <: U}): Stream[M {type T <: U}] = Stream.cons(first, all4Impl[U](first.next)) +// TODO!!! fix this bug for real, it compiles successfully, but weird types are inferred +object Unrelated { + // compiles successfully + def all4Impl[U](first: M {type T <: U}): Stream[M {type T <: U}] = Stream.cons(first, all4Impl[U](first.next)) + + // should compile successfully without the [U], but: + // def all4ImplFail[U](first: M {type T <: U}): Stream[M {type T <: U}] = Stream.cons(first, all4ImplFail(first.next)) + // + // test/files/pos/t1279a.scala:31: error: type mismatch; + // found : first.selfType + // (which expands to) M{type T <: first.T} + // required: M{type T <: Nothing} + // def all4ImplFail[U](first: M {type T <: U}): Stream[M {type T <: U}] = Stream.cons(first, all4ImplFail(first.next)) + // ^ + // one error found } diff --git a/test/files/pos/t1357.scala b/test/files/pos/t1357.scala new file mode 100644 index 0000000000..7bc6d45034 --- /dev/null +++ b/test/files/pos/t1357.scala @@ -0,0 +1,21 @@ +object NonEmptyCons { + def unapply[H, T](c: (H, T)): Option[(H, T)] = Some(c) +} + + +object Main { + + type BT[+H, +T <: Tuple2[Tuple2[H, T], Tuple2[H, T]]] = Tuple2[H, T] + + // type T = Tuple2[String,String] + type BinaryTree[+E] = BT[E, T forSome { type T <: Tuple2[BT[E, T], BT[E, T]] }] + + def foo[E](tree: BinaryTree[E]): Unit = tree match { + case NonEmptyCons(_, tail) => { + tail match { + case NonEmptyCons(_, _) => { + } + } + } + } +}
\ No newline at end of file diff --git a/test/files/pos/t1381-new.scala b/test/files/pos/t1381-new.scala new file mode 100644 index 0000000000..8781ef4fdb --- /dev/null +++ b/test/files/pos/t1381-new.scala @@ -0,0 +1,31 @@ +import scala.reflect.TypeTag + +class D[V <: Variable] + +class ID[V<:IV] extends D[V] { + type E = V#ValueType + def index(value:E) : Int = 0 + // Comment this out to eliminate crash. Or see below + def index(values:E*) : Iterable[Int] = null +} + +abstract class Variable { + type VT <: Variable + def d : D[VT] = null +} + +abstract class PV[T](initval:T) extends Variable { + type VT <: PV[T] + type ValueType = T +} + +trait IV extends Variable { + type ValueType +} + +abstract class EV[T](initval:T) extends PV[T](initval) with IV { + type VT <: EV[T] + override def d : ID[VT] = null + // Comment this out to eliminate crash + protected var indx = d.index(initval) +} diff --git a/test/files/pos/t1381.scala b/test/files/pos/t1381-old.scala index 0762891898..0762891898 100644 --- a/test/files/pos/t1381.scala +++ b/test/files/pos/t1381-old.scala diff --git a/test/files/pos/t1439.flags b/test/files/pos/t1439.flags index 779916d58f..1e70f5c5c7 100644 --- a/test/files/pos/t1439.flags +++ b/test/files/pos/t1439.flags @@ -1 +1 @@ --unchecked -Xfatal-warnings
\ No newline at end of file +-unchecked -Xfatal-warnings -Xoldpatmat -language:higherKinds diff --git a/test/files/pos/t1785.scala b/test/files/pos/t1785.scala new file mode 100644 index 0000000000..0b1fafb27c --- /dev/null +++ b/test/files/pos/t1785.scala @@ -0,0 +1,7 @@ +class t1785 { + def apply[T](x: Int) = 1 +} + +object test { + (new t1785)[Int](1) +} diff --git a/test/files/pos/t1942/A_1.scala b/test/files/pos/t1942/A_1.scala index 19a7575a0a..4915b54a64 100644 --- a/test/files/pos/t1942/A_1.scala +++ b/test/files/pos/t1942/A_1.scala @@ -3,7 +3,7 @@ class A { def foo(x: String) = 1 } -class ann(x: Int) extends StaticAnnotation +class ann(x: Int) extends annotation.StaticAnnotation class t { val a = new A diff --git a/test/files/pos/t1987.scala b/test/files/pos/t1987a.scala index ccab133716..ccab133716 100644 --- a/test/files/pos/t1987.scala +++ b/test/files/pos/t1987a.scala diff --git a/test/files/pos/t2405.scala b/test/files/pos/t2405.scala new file mode 100644 index 0000000000..224b2ce83b --- /dev/null +++ b/test/files/pos/t2405.scala @@ -0,0 +1,23 @@ +object A { implicit val x: Int = 1 } + +// Problem as stated in the ticket. +object Test1 { + import A.{x => y} + implicitly[Int] +} + +// Testing for the absense of shadowing #1. +object Test2 { + import A.{x => y} + val x = 2 + implicitly[Int] +} + +// Testing for the absense of shadowing #2. +object Test3 { + { + import A.{x => y} + def x: Int = 0 + implicitly[Int] + } +} diff --git a/test/files/pos/t2435.scala b/test/files/pos/t2435.scala new file mode 100644 index 0000000000..2db931b99f --- /dev/null +++ b/test/files/pos/t2435.scala @@ -0,0 +1,27 @@ +object Bug { + abstract class FChain { + type T + + def chain(constant:String) = + new FConstant[this.type](constant, this) //removing [this.type], everything compiles + } + + case class FConstant[E <: FChain](constant:String, tail:E) extends FChain { + type T = tail.T + } + + object FNil extends FChain { + type T = Unit + } + +} + +object Test { + import Bug._ + println("Compiles:") + val a1 = FNil.chain("a").chain("a") + val a2 = a1.chain("a") + + println("\nDoesn't compile:") + val a = FNil.chain("a").chain("a").chain("a") +} diff --git a/test/files/pos/t2764/Ann.java b/test/files/pos/t2764/Ann.java new file mode 100644 index 0000000000..184fc6e864 --- /dev/null +++ b/test/files/pos/t2764/Ann.java @@ -0,0 +1,5 @@ +package bippy; + +public @interface Ann { + Enum value(); +} diff --git a/test/files/pos/t2764/Enum.java b/test/files/pos/t2764/Enum.java new file mode 100644 index 0000000000..fe07559535 --- /dev/null +++ b/test/files/pos/t2764/Enum.java @@ -0,0 +1,5 @@ +package bippy; + +public enum Enum { + VALUE; +} diff --git a/test/files/pos/t2764/Use.scala b/test/files/pos/t2764/Use.scala new file mode 100644 index 0000000000..8cf8102709 --- /dev/null +++ b/test/files/pos/t2764/Use.scala @@ -0,0 +1,6 @@ +package bippy + +class Use { + @Ann(Enum.VALUE) + def foo {} +} diff --git a/test/files/pos/t2795-new.scala b/test/files/pos/t2795-new.scala new file mode 100644 index 0000000000..af9c4e8b1c --- /dev/null +++ b/test/files/pos/t2795-new.scala @@ -0,0 +1,17 @@ +package t1 + +trait Element[T] { +} + +trait Config { + type T <: Element[T] + implicit val m: ArrayTag[T] + // XXX Following works fine: + // type T <: Element[_] +} + +trait Transform { self: Config => + def processBlock(block: Array[T]): Unit = { + var X = new Array[T](1) + } +} diff --git a/test/files/pos/t2795.scala b/test/files/pos/t2795-old.scala index 935cb1f444..935cb1f444 100644 --- a/test/files/pos/t2795.scala +++ b/test/files/pos/t2795-old.scala diff --git a/test/files/pos/t2868/pick_1.scala b/test/files/pos/t2868/pick_1.scala index e91728ec2f..a211687432 100644 --- a/test/files/pos/t2868/pick_1.scala +++ b/test/files/pos/t2868/pick_1.scala @@ -1,4 +1,4 @@ -class ann(s: String) extends StaticAnnotation +class ann(s: String) extends annotation.StaticAnnotation class pick { final val s = "bang!" @ann("bang!") def foo = 1 diff --git a/test/files/pos/t3097.flags b/test/files/pos/t3097.flags deleted file mode 100644 index 144ddac9d3..0000000000 --- a/test/files/pos/t3097.flags +++ /dev/null @@ -1 +0,0 @@ --unchecked -Xfatal-warnings diff --git a/test/files/pos/t3097.scala b/test/files/pos/t3097.scala deleted file mode 100644 index a034b960f7..0000000000 --- a/test/files/pos/t3097.scala +++ /dev/null @@ -1,31 +0,0 @@ -package seal - -sealed trait ISimpleValue - -sealed trait IListValue extends ISimpleValue { - def items: List[IAtomicValue[_]] -} -sealed trait IAtomicValue[O] extends ISimpleValue { - def data: O -} - -sealed trait IAbstractDoubleValue[O] extends IAtomicValue[O] { } -sealed trait IDoubleValue extends IAbstractDoubleValue[Double] - -case class ListValue(val items: List[IAtomicValue[_]]) extends IListValue -class DoubleValue(val data: Double) extends IDoubleValue { - def asDouble = data -} - -object Test { - /** - * @param args the command line arguments - */ - def main(args: Array[String]): Unit = { - val v: ISimpleValue = new DoubleValue(1) - v match { - case m: IListValue => println("list") - case a: IAtomicValue[_] => println("atomic") - } - } -} diff --git a/test/files/pos/t3363-new.scala b/test/files/pos/t3363-new.scala new file mode 100644 index 0000000000..270462745c --- /dev/null +++ b/test/files/pos/t3363-new.scala @@ -0,0 +1,18 @@ +object TestCase { + + //now matter if you put (abstract) class or trait it will fail in all cases + trait MapOps[T] + + //if fs was reduced to List (generic type with one parameter) then the code compiles + //if you inherit from MapOps[T] instead of MapOps[F] then code compiles fine + implicit def map2ops[T,F](fs: Map[T,F]) = new MapOps[F] { + //if you remove this line, then code compiles + lazy val m: TypeTag[T] = error("just something to make it compile") + def is(xs: List[T]) = List(xs) + } + + def main(args: Array[String]) { + println(Map(1 -> "2") is List(2)) + } + + } diff --git a/test/files/pos/t3363.scala b/test/files/pos/t3363-old.scala index bae54084ea..bae54084ea 100755..100644 --- a/test/files/pos/t3363.scala +++ b/test/files/pos/t3363-old.scala diff --git a/test/files/pos/t3498-new.scala b/test/files/pos/t3498-new.scala new file mode 100644 index 0000000000..653c50042a --- /dev/null +++ b/test/files/pos/t3498-new.scala @@ -0,0 +1,15 @@ +abstract class A[T, @specialized(scala.Int) U : ArrayTag] { + def f(state: T): Array[U] +} + +abstract class B extends A[ Array[Byte], Int ] { + type T = Array[Byte] + type U = Int + + val N = 0 + + def f(state: T): Array[U] = + { + new Array[U](N + state(N)) + } +}
\ No newline at end of file diff --git a/test/files/pos/t3498.scala b/test/files/pos/t3498-old.scala index bcc90ca64c..bcc90ca64c 100644 --- a/test/files/pos/t3498.scala +++ b/test/files/pos/t3498-old.scala diff --git a/test/files/pos/t3800.scala b/test/files/pos/t3800.scala index 796eb268c5..61dbeafff3 100644 --- a/test/files/pos/t3800.scala +++ b/test/files/pos/t3800.scala @@ -1,4 +1,4 @@ -class meh extends StaticAnnotation +class meh extends annotation.StaticAnnotation class ALike[C] abstract class AFactory[CC[x] <: ALike[CC[x]]] { diff --git a/test/files/pos/t3856.scala b/test/files/pos/t3856.scala index fd253a56a8..5ea4b84e2c 100644 --- a/test/files/pos/t3856.scala +++ b/test/files/pos/t3856.scala @@ -2,6 +2,7 @@ case class C[T](x: T) case class CS(xs: C[_]*) +// t3856 object Test { val x = CS(C(5), C("abc")) match { case CS(C(5), xs @ _*) => xs } println(x) diff --git a/test/files/pos/t3880.scala b/test/files/pos/t3880.scala new file mode 100644 index 0000000000..b6f06c43a3 --- /dev/null +++ b/test/files/pos/t3880.scala @@ -0,0 +1,16 @@ +abstract class Bar[+B] { +} +abstract class C1[+B] extends Bar[B] { + private[this] def g(x: C1[B]): Unit = () + + // this method is fine: notice that it allows the call to g, + // which requires C1[B], even though we matched on C1[_]. + // (That is good news.) + private[this] def f1(x: Bar[B]): Unit = x match { + case x: C1[_] => g(x) + } + // this one crashes. + private[this] def f2(x: Bar[B]): Unit = x match { + case x: C1[_] => f2(x) + } +}
\ No newline at end of file diff --git a/test/files/pos/t3951/Coll_1.scala b/test/files/pos/t3951/Coll_1.scala index c2cc39a1a9..556c848688 100644 --- a/test/files/pos/t3951/Coll_1.scala +++ b/test/files/pos/t3951/Coll_1.scala @@ -15,7 +15,7 @@ sealed trait DynamicDocument extends Document { class Coll extends StaticDocument // similiar issue with annotations -class ann[T] extends StaticAnnotation +class ann[T] extends annotation.StaticAnnotation trait StatDoc extends Doc { @ann[StatFB] diff --git a/test/files/pos/t4579.flags b/test/files/pos/t4579.flags new file mode 100644 index 0000000000..1182725e86 --- /dev/null +++ b/test/files/pos/t4579.flags @@ -0,0 +1 @@ +-optimize
\ No newline at end of file diff --git a/test/files/pos/t4579.scala b/test/files/pos/t4579.scala new file mode 100644 index 0000000000..2404b19da1 --- /dev/null +++ b/test/files/pos/t4579.scala @@ -0,0 +1,518 @@ +//############################################################################ +// Lisp interpreter (revived as an optimizer test.) +//############################################################################ + +//############################################################################ +// Lisp Scanner + +class LispTokenizer(s: String) extends Iterator[String] { + private var i = 0; + private def isDelimiter(ch: Char) = ch <= ' ' || ch == '(' || ch == ')' + def hasNext: Boolean = { + while (i < s.length() && s.charAt(i) <= ' ') i += 1 + i < s.length() + } + def next: String = + if (hasNext) { + val start = i + if (isDelimiter(s charAt i)) i += 1 + else + do i = i + 1 + while (!isDelimiter(s charAt i)) + s.substring(start, i) + } else sys.error("premature end of string") +} + +//############################################################################ +// Lisp Interface + +trait Lisp { + type Data + + def string2lisp(s: String): Data + def lisp2string(s: Data): String + + def evaluate(d: Data): Data + // !!! def evaluate(s: String): Data = evaluate(string2lisp(s)) + def evaluate(s: String): Data +} + +//############################################################################ +// Lisp Implementation Using Case Classes + +object LispCaseClasses extends Lisp { + + import List.range + + trait Data { + def elemsToString(): String = toString(); + } + case class CONS(car: Data, cdr: Data) extends Data { + override def toString() = "(" + elemsToString() + ")"; + override def elemsToString() = car.toString() + (cdr match { + case NIL() => "" + case _ => " " + cdr.elemsToString(); + }) + } + case class NIL() extends Data { // !!! use case object + override def toString() = "()"; + } + case class SYM(name: String) extends Data { + override def toString() = name; + } + case class NUM(x: Int) extends Data { + override def toString() = x.toString(); + } + case class STR(x: String) extends Data { + override def toString() = "\"" + x + "\""; + } + case class FUN(f: List[Data] => Data) extends Data { + override def toString() = "<fn>"; + } + + def list(): Data = + NIL(); + def list(x0: Data): Data = + CONS(x0, NIL()); + def list(x0: Data, x1: Data): Data = + CONS(x0, list(x1)); + def list(x0: Data, x1: Data, x2: Data): Data = + CONS(x0, list(x1, x2)); + def list(x0: Data, x1: Data, x2: Data, x3: Data): Data = + CONS(x0, list(x1, x2, x3)); + def list(x0: Data, x1: Data, x2: Data, x3: Data, x4: Data): Data = + CONS(x0, list(x1, x2, x3, x4)); + def list(x0: Data, x1: Data, x2: Data, x3: Data, x4: Data, x5: Data): Data = + CONS(x0, list(x1, x2, x3, x4, x5)); + def list(x0: Data, x1: Data, x2: Data, x3: Data, x4: Data, x5: Data, + x6: Data): Data = + CONS(x0, list(x1, x2, x3, x4, x5, x6)); + def list(x0: Data, x1: Data, x2: Data, x3: Data, x4: Data, x5: Data, + x6: Data, x7: Data): Data = + CONS(x0, list(x1, x2, x3, x4, x5, x6, x7)); + def list(x0: Data, x1: Data, x2: Data, x3: Data, x4: Data, x5: Data, + x6: Data, x7: Data, x8: Data): Data = + CONS(x0, list(x1, x2, x3, x4, x5, x6, x7, x8)); + def list(x0: Data, x1: Data, x2: Data, x3: Data, x4: Data, x5: Data, + x6: Data, x7: Data, x8: Data, x9: Data): Data = + CONS(x0, list(x1, x2, x3, x4, x5, x6, x7, x8, x9)); + + var curexp: Data = null + var trace: Boolean = false + var indent: Int = 0 + + def lispError[a](msg: String): a = + sys.error("error: " + msg + "\n" + curexp); + + trait Environment { + def lookup(n: String): Data; + def extendRec(name: String, expr: Environment => Data) = + new Environment { + def lookup(n: String): Data = + if (n == name) expr(this) else Environment.this.lookup(n); + } + def extend(name: String, v: Data) = extendRec(name, (env1 => v)); + } + val EmptyEnvironment = new Environment { + def lookup(n: String): Data = lispError("undefined: " + n); + } + + def toList(x: Data): List[Data] = x match { + case NIL() => List() + case CONS(y, ys) => y :: toList(ys) + case _ => lispError("malformed list: " + x); + } + + def toBoolean(x: Data) = x match { + case NUM(0) => false + case _ => true + } + + def normalize(x: Data): Data = x match { + case CONS(SYM("def"), + CONS(CONS(SYM(name), args), CONS(body, CONS(expr, NIL())))) => + normalize(list(SYM("def"), + SYM(name), list(SYM("lambda"), args, body), expr)) + case CONS(SYM("cond"), CONS(CONS(SYM("else"), CONS(expr, NIL())),NIL())) => + normalize(expr) + case CONS(SYM("cond"), CONS(CONS(test, CONS(expr, NIL())), rest)) => + normalize(list(SYM("if"), test, expr, CONS(SYM("cond"), rest))) + case CONS(h, t) => CONS(normalize(h), normalize(t)) + case _ => x + } + + def eval(x: Data, env: Environment): Data = { + val prevexp = curexp; + curexp = x; + if (trace) { + for (x <- range(1, indent)) Console.print(" "); + Console.println("===> " + x); + indent = indent + 1; + } + val result = eval1(x, env); + if (trace) { + indent = indent - 1; + for (x <- range(1, indent)) Console.print(" "); + Console.println("<=== " + result); + } + curexp = prevexp; + result + } + + def eval1(x: Data, env: Environment): Data = x match { + case SYM(name) => + env lookup name + case CONS(SYM("def"), CONS(SYM(name), CONS(y, CONS(z, NIL())))) => + eval(z, env.extendRec(name, (env1 => eval(y, env1)))) + case CONS(SYM("val"), CONS(SYM(name), CONS(y, CONS(z, NIL())))) => + eval(z, env.extend(name, eval(y, env))) + case CONS(SYM("lambda"), CONS(params, CONS(y, NIL()))) => + mkLambda(params, y, env) + case CONS(SYM("if"), CONS(c, CONS(t, CONS(e, NIL())))) => + if (toBoolean(eval(c, env))) eval(t, env) else eval(e, env) + case CONS(SYM("quote"), CONS(x, NIL())) => + x + case CONS(y, xs) => + apply(eval(y, env), toList(xs) map (x => eval(x, env))) + case NUM(_) => x + case STR(_) => x + case FUN(_) => x + case _ => + lispError("illegal term") + } + + def apply(fn: Data, args: List[Data]): Data = fn match { + case FUN(f) => f(args); + case _ => lispError("application of non-function: " + fn); + } + + def mkLambda(params: Data, expr: Data, env: Environment): Data = { + + def extendEnv(env: Environment, + ps: List[String], args: List[Data]): Environment = + Pair(ps, args) match { + case Pair(List(), List()) => + env + case Pair(p :: ps1, arg :: args1) => + extendEnv(env.extend(p, arg), ps1, args1) + case _ => + lispError("wrong number of arguments") + } + + val ps: List[String] = toList(params) map { + case SYM(name) => name + case _ => sys.error("illegal parameter list"); + } + + FUN(args => eval(expr, extendEnv(env, ps, args))) + } + + val globalEnv = EmptyEnvironment + .extend("=", FUN({ + case List(NUM(arg1),NUM(arg2)) => NUM(if (arg1 == arg2) 1 else 0) + case List(STR(arg1),STR(arg2)) => NUM(if (arg1 == arg2) 1 else 0)})) + .extend("+", FUN({ + case List(NUM(arg1),NUM(arg2)) => NUM(arg1 + arg2) + case List(STR(arg1),STR(arg2)) => STR(arg1 + arg2)})) + .extend("-", FUN({ + case List(NUM(arg1),NUM(arg2)) => NUM(arg1 - arg2)})) + .extend("*", FUN({ + case List(NUM(arg1),NUM(arg2)) => NUM(arg1 * arg2)})) + .extend("/", FUN({ + case List(NUM(arg1),NUM(arg2)) => NUM(arg1 / arg2)})) + .extend("car", FUN({ + case List(CONS(x, xs)) => x})) + .extend("cdr", FUN({ + case List(CONS(x, xs)) => xs})) + .extend("null?", FUN({ + case List(NIL()) => NUM(1) + case _ => NUM(0)})) + .extend("cons", FUN({ + case List(x, y) => CONS(x, y)})); + + def evaluate(x: Data): Data = eval(normalize(x), globalEnv); + def evaluate(s: String): Data = evaluate(string2lisp(s)); + + def string2lisp(s: String): Data = { + val it = new LispTokenizer(s); + def parseExpr(token: String): Data = { + if (token == "(") parseList + else if (token == ")") sys.error("unbalanced parentheses") + else if ('0' <= token.charAt(0) && token.charAt(0) <= '9') + NUM(token.toInt) + else if (token.charAt(0) == '\"' && token.charAt(token.length()-1)=='\"') + STR(token.substring(1,token.length() - 1)) + else SYM(token) + } + def parseList: Data = { + val token = it.next; + if (token == ")") NIL() else CONS(parseExpr(token), parseList) + } + parseExpr(it.next) + } + + def lisp2string(d: Data): String = d.toString(); +} + +//############################################################################ +// Lisp Implementation Using Any + +object LispAny extends Lisp { + + import List._; + + type Data = Any; + + case class Lambda(f: List[Data] => Data); + + var curexp: Data = null; + var trace: Boolean = false; + var indent: Int = 0; + + def lispError[a](msg: String): a = + sys.error("error: " + msg + "\n" + curexp); + + trait Environment { + def lookup(n: String): Data; + def extendRec(name: String, expr: Environment => Data) = + new Environment { + def lookup(n: String): Data = + if (n == name) expr(this) else Environment.this.lookup(n); + } + def extend(name: String, v: Data) = extendRec(name, (env1 => v)); + } + val EmptyEnvironment = new Environment { + def lookup(n: String): Data = lispError("undefined: " + n); + } + + def asList(x: Data): List[Data] = x match { + case y: List[_] => y + case _ => lispError("malformed list: " + x) + } + + def asInt(x: Data): Int = x match { + case y: Int => y + case _ => lispError("not an integer: " + x) + } + + def asString(x: Data): String = x match { + case y: String => y + case _ => lispError("not a string: " + x) + } + + def asBoolean(x: Data): Boolean = x != 0 + + def normalize(x: Data): Data = x match { + case 'and :: x :: y :: Nil => + normalize('if :: x :: y :: 0 :: Nil) + case 'or :: x :: y :: Nil => + normalize('if :: x :: 1 :: y :: Nil) + case 'def :: (name :: args) :: body :: expr :: Nil => + normalize('def :: name :: ('lambda :: args :: body :: Nil) :: expr :: Nil) + case 'cond :: ('else :: expr :: Nil) :: rest => + normalize(expr); + case 'cond :: (test :: expr :: Nil) :: rest => + normalize('if :: test :: expr :: ('cond :: rest) :: Nil) + case 'cond :: 'else :: expr :: Nil => + normalize(expr) + case h :: t => + normalize(h) :: asList(normalize(t)) + case _ => + x + } + + def eval(x: Data, env: Environment): Data = { + val prevexp = curexp; + curexp = x; + if (trace) { + for (x <- range(1, indent)) Console.print(" "); + Console.println("===> " + x); + indent += 1; + } + val result = eval1(x, env); + if (trace) { + indent -= 1; + for (x <- range(1, indent)) Console.print(" "); + Console.println("<=== " + result); + } + curexp = prevexp; + result + } + + def eval1(x: Data, env: Environment): Data = x match { + case Symbol(name) => + env lookup name + case 'def :: Symbol(name) :: y :: z :: Nil => + eval(z, env.extendRec(name, (env1 => eval(y, env1)))) + case 'val :: Symbol(name) :: y :: z :: Nil => + eval(z, env.extend(name, eval(y, env))) + case 'lambda :: params :: y :: Nil => + mkLambda(params, y, env) + case 'if :: c :: y :: z :: Nil => + if (asBoolean(eval(c, env))) eval(y, env) else eval(z, env) + case 'quote :: y :: Nil => + y + case y :: z => + apply(eval(y, env), z map (x => eval(x, env))) + case Lambda(_) => x + case y: String => x + case y: Int => x + case y => lispError("illegal term") + } + + def lisp2string(x: Data): String = x match { + case Symbol(name) => name + case Nil => "()" + case y :: ys => + def list2string(xs: List[Data]): String = xs match { + case List() => "" + case y :: ys => " " + lisp2string(y) + list2string(ys) + } + "(" + lisp2string(y) + list2string(ys) + ")" + case _ => if (x.isInstanceOf[String]) "\"" + x + "\""; else x.toString() + } + + def apply(fn: Data, args: List[Data]): Data = fn match { + case Lambda(f) => f(args); + case _ => lispError("application of non-function: " + fn + " to " + args); + } + + def mkLambda(params: Data, expr: Data, env: Environment): Data = { + + def extendEnv(env: Environment, + ps: List[String], args: List[Data]): Environment = + Pair(ps, args) match { + case Pair(List(), List()) => + env + case Pair(p :: ps1, arg :: args1) => + extendEnv(env.extend(p, arg), ps1, args1) + case _ => + lispError("wrong number of arguments") + } + + val ps: List[String] = asList(params) map { + case Symbol(name) => name + case _ => sys.error("illegal parameter list"); + } + + Lambda(args => eval(expr, extendEnv(env, ps, args))) + } + + val globalEnv = EmptyEnvironment + .extend("=", Lambda{ + case List(arg1, arg2) => if(arg1 == arg2) 1 else 0}) + .extend("+", Lambda{ + case List(arg1: Int, arg2: Int) => arg1 + arg2 + case List(arg1: String, arg2: String) => arg1 + arg2}) + .extend("-", Lambda{ + case List(arg1: Int, arg2: Int) => arg1 - arg2}) + .extend("*", Lambda{ + case List(arg1: Int, arg2: Int) => arg1 * arg2}) + .extend("/", Lambda{ + case List(arg1: Int, arg2: Int) => arg1 / arg2}) + .extend("nil", Nil) + .extend("cons", Lambda{ + case List(arg1, arg2) => arg1 :: asList(arg2)}) + .extend("car", Lambda{ + case List(x :: xs) => x}) + .extend("cdr", Lambda{ + case List(x :: xs) => xs}) + .extend("null?", Lambda{ + case List(Nil) => 1 + case _ => 0}); + + def evaluate(x: Data): Data = eval(normalize(x), globalEnv); + def evaluate(s: String): Data = evaluate(string2lisp(s)); + + def string2lisp(s: String): Data = { + val it = new LispTokenizer(s); + def parseExpr(token: String): Data = { + if (token == "(") parseList + else if (token == ")") sys.error("unbalanced parentheses") + //else if (Character.isDigit(token.charAt(0))) + else if (token.charAt(0).isDigit) + token.toInt + else if (token.charAt(0) == '\"' && token.charAt(token.length()-1)=='\"') + token.substring(1,token.length() - 1) + else Symbol(token) + } + def parseList: List[Data] = { + val token = it.next; + if (token == ")") Nil else parseExpr(token) :: parseList + } + parseExpr(it.next) + } +} + +//############################################################################ +// List User + +class LispUser(lisp: Lisp) { + + import lisp._; + + def evaluate(s: String) = lisp2string(lisp.evaluate(s)); + + def run = { + + Console.println(string2lisp("(lambda (x) (+ (* x x) 1))").asInstanceOf[AnyRef]); + Console.println(lisp2string(string2lisp("(lambda (x) (+ (* x x) 1))"))); + Console.println; + + Console.println("( '(1 2 3)) = " + evaluate(" (quote(1 2 3))")); + Console.println("(car '(1 2 3)) = " + evaluate("(car (quote(1 2 3)))")); + Console.println("(cdr '(1 2 3)) = " + evaluate("(cdr (quote(1 2 3)))")); + Console.println("(null? '(2 3)) = " + evaluate("(null? (quote(2 3)))")); + Console.println("(null? '()) = " + evaluate("(null? (quote()))")); + Console.println; + + Console.println("faculty(10) = " + evaluate( + "(def (faculty n) " + + "(if (= n 0) " + + "1 " + + "(* n (faculty (- n 1)))) " + + "(faculty 10))")); + Console.println("faculty(10) = " + evaluate( + "(def (faculty n) " + + "(cond " + + "((= n 0) 1) " + + "(else (* n (faculty (- n 1))))) " + + "(faculty 10))")); + Console.println("foobar = " + evaluate( + "(def (foo n) " + + "(cond " + + "((= n 0) \"a\")" + + "((= n 1) \"b\")" + + "((= (/ n 2) 1) " + + "(cond " + + "((= n 2) \"c\")" + + "(else \"d\")))" + + "(else " + + "(def (bar m) " + + "(cond " + + "((= m 0) \"e\")" + + "((= m 1) \"f\")" + + "(else \"z\"))" + + "(bar (- n 4)))))" + + "(val nil (quote ())" + + "(val v1 (foo 0) " + + "(val v2 (+ (foo 1) (foo 2)) " + + "(val v3 (+ (+ (foo 3) (foo 4)) (foo 5)) " + + "(val v4 (foo 6) " + + "(cons v1 (cons v2 (cons v3 (cons v4 nil))))))))))")); + Console.println; + } +} + +//############################################################################ +// Main + +object Test { + def main(args: Array[String]) { + new LispUser(LispCaseClasses).run; + new LispUser(LispAny).run; + () + } +} + +//############################################################################ diff --git a/test/files/pos/t4651.scala b/test/files/pos/t4651.scala new file mode 100644 index 0000000000..0612a8fcfb --- /dev/null +++ b/test/files/pos/t4651.scala @@ -0,0 +1,12 @@ +object Test { + def analyze(x: Any) = x match { + case s: String => println("It's a string: " + s) + case 1 => println("It's a one") + case (a: Int, b) => println("It's a pair of and int " + a + + " and something " + b) + case 1 :: 2 :: _ => println("It's a list starting with 1, 2") + case List(a, b, c) => println("It's a three-element list with " + + a + ", " + b + ", " + c) + case _ => println("It's something different") + } +} diff --git a/test/files/pos/t4717.scala b/test/files/pos/t4717.scala new file mode 100644 index 0000000000..4acfe489cc --- /dev/null +++ b/test/files/pos/t4717.scala @@ -0,0 +1,35 @@ + + + + + + + +trait Bug1[@specialized(Boolean) A] extends TraversableOnce[A] { + + def ++[B >: A](that: TraversableOnce[B]): Iterator[B] = new Iterator[B] { + lazy val it = that.toIterator + def hasNext = it.hasNext + def next = it.next + } + +} + + + +trait WorksFine[@specialized(Boolean) A] { + class SubBounds[B >: A] extends Bounds[B] { + lazy val it = ??? + } + def x[B >: A]: Unit = new SubBounds[B] +} + + +trait Bounds[@specialized(Boolean) A] { + // okay without `>: A` + def x[B >: A]: Unit = new Bounds[B] { + lazy val it = ??? // def or val okay + } +} + + diff --git a/test/files/pos/t4812.scala b/test/files/pos/t4812.scala new file mode 100644 index 0000000000..2a807ab05e --- /dev/null +++ b/test/files/pos/t4812.scala @@ -0,0 +1,4 @@ +trait Test1 { + def m1(sym: Symbol = 'TestSym) + def m2(s: String = "TestString") +} diff --git a/test/files/pos/t4911.flags b/test/files/pos/t4911.flags new file mode 100644 index 0000000000..779916d58f --- /dev/null +++ b/test/files/pos/t4911.flags @@ -0,0 +1 @@ +-unchecked -Xfatal-warnings
\ No newline at end of file diff --git a/test/files/pos/t4911.scala b/test/files/pos/t4911.scala new file mode 100644 index 0000000000..66c867a37f --- /dev/null +++ b/test/files/pos/t4911.scala @@ -0,0 +1,16 @@ +import language._ + +object Test { + class Foo[T](val x: T) ; object Foo { def unapply[T](x: Foo[T]) = Some(x.x) } + def f1[T](x: Foo[T]) = x match { case Foo(y) => y } + def f2[M[_], T](x: M[T]) = x match { case Foo(y) => y } + + case class Bar[T](x: T) + def f3[T](x: Bar[T]) = x match { case Bar(y) => y } + def f4[M[_], T](x: M[T]) = x match { case Bar(y) => y } +} +// +// ./b.scala:4: warning: non variable type-argument T in type pattern Test.Foo[T] is unchecked since it is eliminated by erasure +// def f2[M[_], T](x: M[T]) = x match { case Foo(y) => y } +// ^ +// one warning found
\ No newline at end of file diff --git a/test/files/pos/t4975.scala b/test/files/pos/t4975.scala new file mode 100644 index 0000000000..12d889c0d5 --- /dev/null +++ b/test/files/pos/t4975.scala @@ -0,0 +1,12 @@ +object ImplicitScope { + class A[T] + + def foo { + trait B + object B { + implicit def ab = new A[B] + } + + implicitly[A[B]] // Error + } +} diff --git a/test/files/pos/t5029.flags b/test/files/pos/t5029.flags new file mode 100644 index 0000000000..e8fb65d50c --- /dev/null +++ b/test/files/pos/t5029.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/test/files/pos/t5029.scala b/test/files/pos/t5029.scala new file mode 100644 index 0000000000..6f9a329b80 --- /dev/null +++ b/test/files/pos/t5029.scala @@ -0,0 +1,3 @@ +object Test { + (Vector(): Seq[_]) match { case List() => true; case Nil => false } +}
\ No newline at end of file diff --git a/test/files/pos/t5041.scala b/test/files/pos/t5041.scala new file mode 100644 index 0000000000..78a1b27d5a --- /dev/null +++ b/test/files/pos/t5041.scala @@ -0,0 +1,9 @@ +case class Token(text: String, startIndex: Int) + +object Comment { + def unapply(s: String): Option[Token] = None +} + +object HiddenTokens { + "foo" match { case Comment(_) => } +} diff --git a/test/files/pos/t5137.scala b/test/files/pos/t5137.scala new file mode 100644 index 0000000000..bb72cf378f --- /dev/null +++ b/test/files/pos/t5137.scala @@ -0,0 +1,17 @@ +object Test { + + // okay + (1 * (List[BigInt]().map(((x0) => x0 match { + case x => x + })).sum)) + + // okay + ((1: BigInt) * (List[BigInt]().map({ + case x => x + }).sum)) + + // fail + (1 * (List[BigInt]().map({ + case x => x + }).sum)) +}
\ No newline at end of file diff --git a/test/files/pos/t5165/TestAnnotation.java b/test/files/pos/t5165/TestAnnotation.java new file mode 100644 index 0000000000..90886b7537 --- /dev/null +++ b/test/files/pos/t5165/TestAnnotation.java @@ -0,0 +1,11 @@ +import java.lang.annotation.*; + +@Retention(RetentionPolicy.RUNTIME) +public @interface TestAnnotation { + public enum TestEnumOne { A, B } + public enum TestEnumTwo { C, D } + + public TestEnumOne one(); + public TestEnumTwo two(); + public String strVal(); +} diff --git a/test/files/pos/t5165/TestObject.scala b/test/files/pos/t5165/TestObject.scala new file mode 100644 index 0000000000..eaf244e9d0 --- /dev/null +++ b/test/files/pos/t5165/TestObject.scala @@ -0,0 +1,3 @@ + +object TestObject extends TestTrait + diff --git a/test/files/pos/t5165/TestTrait.scala b/test/files/pos/t5165/TestTrait.scala new file mode 100644 index 0000000000..b317e6c6a3 --- /dev/null +++ b/test/files/pos/t5165/TestTrait.scala @@ -0,0 +1,3 @@ + +@TestAnnotation(one=TestAnnotation.TestEnumOne.A, two=TestAnnotation.TestEnumTwo.C, strVal="something") +trait TestTrait diff --git a/test/files/pos/t5198.scala b/test/files/pos/t5198.scala new file mode 100644 index 0000000000..f403f77f7d --- /dev/null +++ b/test/files/pos/t5198.scala @@ -0,0 +1,15 @@ +package gaga + + + + + +trait Sys[Self <: Sys[Self]] { + type Tx +} + + +sealed trait AssocEntry[S <: Sys[S], @specialized(Int) A] { + def value: A + def value(implicit tx: S#Tx): A +} diff --git a/test/files/pos/t5210.scala b/test/files/pos/t5210.scala new file mode 100644 index 0000000000..e85037a902 --- /dev/null +++ b/test/files/pos/t5210.scala @@ -0,0 +1,10 @@ +object WithOpTest { + trait WithOp extends Cloneable { + def f: this.type = this + def g1: this.type = f + def g2: this.type = { + val t = f + t + } + } +} diff --git a/test/files/pos/t5240.scala b/test/files/pos/t5240.scala new file mode 100644 index 0000000000..2db689c27d --- /dev/null +++ b/test/files/pos/t5240.scala @@ -0,0 +1,11 @@ + + + + + + +package object foo { + + var labels: Array[_ <: String] = null + +} diff --git a/test/files/pos/t5259.scala b/test/files/pos/t5259.scala new file mode 100644 index 0000000000..d33c4dd6a7 --- /dev/null +++ b/test/files/pos/t5259.scala @@ -0,0 +1,21 @@ +class A[T] +class B { + def m(a: A[this.type] = new A[this.type]) { } +} + +class C { + def foo(a: Int, b: Int = 0) = 0 + def foo() = 0 +} + +object Test { + def newB = new B + newB.m() + + val stableB = new B + stableB.m() + + def f { + println((new C).foo(0)) + } +} diff --git a/test/files/pos/t5305.scala b/test/files/pos/t5305.scala new file mode 100644 index 0000000000..4c32cd7c6d --- /dev/null +++ b/test/files/pos/t5305.scala @@ -0,0 +1,13 @@ +object t5305 { + def in(a: Any) = {} + + object O { + type F = Int + val v = "" + } + + in { + import O.{F, v} + type x = {type l = (F, v.type)} // not found: type F + } +} diff --git a/test/files/pos/t5313.scala b/test/files/pos/t5313.scala new file mode 100644 index 0000000000..e77b73ca4c --- /dev/null +++ b/test/files/pos/t5313.scala @@ -0,0 +1,30 @@ +object DepBug { + class A { + class B + def mkB = new B + def m(b : B) = b + } + + trait Dep { + val a : A + val b : a.B + } + + val dep = new Dep { + val a = new A + val b = a.mkB + } + + def useDep(d : Dep) { + import d._ + a.m(b) // OK + } + + { + import dep._ + a.m(b) // OK with 2.9.1.final, error on trunk + } + + dep.a.m(dep.b) + +} diff --git a/test/files/pos/t5384.scala b/test/files/pos/t5384.scala new file mode 100644 index 0000000000..4e297d5935 --- /dev/null +++ b/test/files/pos/t5384.scala @@ -0,0 +1,7 @@ +class A(x: String, y: Int)(implicit o: String) +class B1(implicit o: String) extends A(y = 5, x = "a") +class B2(implicit o: String) extends A("a", 5) +class B3(implicit o: String) extends A(y = 5, x = "a")(o) + +class AM[E: Manifest](val x: Unit = (), y: Unit) +class BM[E: Manifest] extends AM[E](y = ()) diff --git a/test/files/pos/t5399.scala b/test/files/pos/t5399.scala new file mode 100644 index 0000000000..ebae7dbd9e --- /dev/null +++ b/test/files/pos/t5399.scala @@ -0,0 +1,45 @@ +class Test { + class A[T] + class B[T](val a: A[T]) + + case class CaseClass[T](x: T) + + def break(existB: B[_]) = + CaseClass(existB.a) match { case CaseClass(_) => } +} + +class Foo { + trait Init[T] + class ScopedKey[T] extends Init[T] + + trait Setting[T] { + val key: ScopedKey[T] + } + + case class ScopedKey1[T](val foo: Init[T]) extends ScopedKey[T] + + val scalaHome: Setting[Option[String]] = null + val scalaVersion: Setting[String] = null + + def testPatternMatch(s: Setting[_]) { + s.key match { + case ScopedKey1(scalaHome.key | scalaVersion.key) => () + } + } +} + +class Test2 { + type AnyCyclic = Execute[Task]#CyclicException[_] + + trait Task[T] + + trait Execute[A[_] <: AnyRef] { + class CyclicException[T](val caller: A[T], val target: A[T]) + } + + def convertCyclic(c: AnyCyclic): String = + (c.caller, c.target) match { + case (caller: Task[_], target: Task[_]) => "bazinga!" + } +} + diff --git a/test/files/pos/t5542.flags b/test/files/pos/t5542.flags new file mode 100644 index 0000000000..464cc20ea6 --- /dev/null +++ b/test/files/pos/t5542.flags @@ -0,0 +1 @@ +-Xfatal-warnings -unchecked
\ No newline at end of file diff --git a/test/files/pos/t5542.scala b/test/files/pos/t5542.scala new file mode 100644 index 0000000000..80b8cef030 --- /dev/null +++ b/test/files/pos/t5542.scala @@ -0,0 +1,3 @@ +class Test { + Option(3) match { case Some(n) => n; case None => 0 } +}
\ No newline at end of file diff --git a/test/files/pos/t5626.scala b/test/files/pos/t5626.scala new file mode 100644 index 0000000000..c501dfbe60 --- /dev/null +++ b/test/files/pos/t5626.scala @@ -0,0 +1,12 @@ +class C { + val blob = { + new { case class Foo() } + } + val blub = { + class Inner { case class Foo() } + new Inner + } + + val foo = blob.Foo() + val bar = blub.Foo() +} diff --git a/test/files/pos/t5654.scala b/test/files/pos/t5654.scala new file mode 100644 index 0000000000..1f8d05bfed --- /dev/null +++ b/test/files/pos/t5654.scala @@ -0,0 +1,13 @@ +class T(val a: Array[_]) + +class U { + val a = Array(Array(1, 2), Array("a","b")) +} + +class T1 { val a: Array[_] = Array(1) } + +case class Bomb(a: Array[_]) +case class Bomb2(a: Array[T] forSome { type T }) +class Okay1(a: Array[_]) +case class Okay2(s: Seq[_]) + diff --git a/test/files/pos/t5667.scala b/test/files/pos/t5667.scala new file mode 100644 index 0000000000..513de5b663 --- /dev/null +++ b/test/files/pos/t5667.scala @@ -0,0 +1,6 @@ +object Main { + implicit class C(val s: String) extends AnyVal + implicit class C2(val s: String) extends AnyRef + + implicit case class Foo(i: Int) +} diff --git a/test/files/pos/t5702-pos-infix-star.scala b/test/files/pos/t5702-pos-infix-star.scala new file mode 100644 index 0000000000..756bcdd8de --- /dev/null +++ b/test/files/pos/t5702-pos-infix-star.scala @@ -0,0 +1,15 @@ + +object Test { + case class *(a: Int, b: Int) + type Star = * + case class P(a: Int, b: Star) // alias still required + + def main(args: Array[String]) { + val v = new *(6,7) + val x * y = v + printf("%d,%d\n",x,y) + val p = P(5, v) + val P(a, b * c) = p + printf("%d,%d,%d\n",a,b,c) + } +} diff --git a/test/files/pos/t5703/Base.java b/test/files/pos/t5703/Base.java new file mode 100644 index 0000000000..fa75cc3bdd --- /dev/null +++ b/test/files/pos/t5703/Base.java @@ -0,0 +1,3 @@ +public abstract class Base<Params> { + public abstract void func(Params[] params); +}
\ No newline at end of file diff --git a/test/files/pos/t5703/Impl.scala b/test/files/pos/t5703/Impl.scala new file mode 100644 index 0000000000..ee22d8fb4b --- /dev/null +++ b/test/files/pos/t5703/Impl.scala @@ -0,0 +1,3 @@ +class Implementation extends Base[Object] { + def func(params: Array[Object]): Unit = {} +}
\ No newline at end of file diff --git a/test/files/pos/t5706.flags b/test/files/pos/t5706.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/files/pos/t5706.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/pos/t5706.scala b/test/files/pos/t5706.scala new file mode 100644 index 0000000000..847acb693f --- /dev/null +++ b/test/files/pos/t5706.scala @@ -0,0 +1,10 @@ +import scala.reflect.makro.Context + +class Logger { + def error(message: String) = macro Impls.error +} + +object Impls { + type LoggerContext = Context { type PrefixType = Logger } + def error(c: LoggerContext)(message: c.Expr[String]): c.Expr[Unit] = ??? +} diff --git a/test/files/pos/t5720-ownerous.scala b/test/files/pos/t5720-ownerous.scala new file mode 100644 index 0000000000..ad4d4c171d --- /dev/null +++ b/test/files/pos/t5720-ownerous.scala @@ -0,0 +1,56 @@ + +/* + * The block under qual$1 must be owned by it. + * In the sample bug, the first default arg generates x$4, + * the second default arg generates qual$1, hence the maximal + * minimization. + * + <method> <triedcooking> def model: C.this.M = { + val qual$1: C.this.M = scala.Option.apply[C.this.M]({ + val x$1: lang.this.String("foo") = "foo"; + val x$2: String = C.this.M.apply$default$2("foo"); + C.this.M.apply("foo")(x$2) +}).getOrElse[C.this.M]({ + val x$3: lang.this.String("bar") = "bar"; + val x$4: String = C.this.M.apply$default$2("bar"); + C.this.M.apply("bar")(x$4) + }); + val x$5: lang.this.String("baz") = "baz"; + val x$6: String = qual$1.copy$default$2("baz"); + qual$1.copy("baz")(x$6) + } + */ +class C { + case class M(currentUser: String = "anon")(val message: String = "empty") + val m = M("foo")() + + // reported + //def model = Option(M("foo")()).getOrElse(M("bar")()).copy(currentUser = "")() + + // the bug + def model = Option(m).getOrElse(M("bar")()).copy("baz")("empty") + + // style points for this version + def modish = ((null: Option[M]) getOrElse new M()()).copy()("empty") + + // various simplifications are too simple + case class N(currentUser: String = "anon") + val n = N("fun") + def nudel = Option(n).getOrElse(N()).copy() +} + +object Test { + def main(args: Array[String]) { + val c = new C + println(c.model.currentUser) + println(c.model.message) + } +} +/* +symbol value x$4$1 does not exist in badcopy.C.model +at scala.reflect.internal.SymbolTable.abort(SymbolTable.scala:45) +at scala.tools.nsc.Global.abort(Global.scala:202) +at scala.tools.nsc.backend.icode.GenICode$ICodePhase.liftedTree2$1(GenICode.scala:998) +at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:992) +*/ + diff --git a/test/files/pos/t5727.scala b/test/files/pos/t5727.scala new file mode 100644 index 0000000000..e091d827b4 --- /dev/null +++ b/test/files/pos/t5727.scala @@ -0,0 +1,31 @@ + +/* + * We like operators, bar none. + */ +object Test { + + trait SomeInfo + case object NoInfo extends SomeInfo + + sealed abstract class Res[+T] + case object NotRes extends Res[Nothing] + + + abstract class Base[+T] { + def apply(f: String): Res[T] + // 'i' crashes the compiler, similarly if we use currying + //def |[U >: T](a: => Base[U], i: SomeInfo = NoInfo): Base[U] = null + def bar[U >: T](a: => Base[U], i: SomeInfo = NoInfo): Base[U] = null + } + + implicit def fromStringToBase(a: String): Base[String] = new Base[String] { def apply(in: String) = NotRes } + + // bug + //def Sample: Base[Any] = ( rep("foo" | "bar") | "sth") + def Sample: Base[Any] = ( rep("foo" bar "bar") bar "sth") + + def rep[T](p: => Base[T]): Base[T] = null // whatever + + def main(args: Array[String]) { + } +} diff --git a/test/files/pos/t5729.scala b/test/files/pos/t5729.scala new file mode 100644 index 0000000000..9fd9c9ffbb --- /dev/null +++ b/test/files/pos/t5729.scala @@ -0,0 +1,6 @@ +trait T[X] +object Test { + def join(in: Seq[T[_]]): Int = ??? + def join[S](in: Seq[T[S]]): String = ??? + join(null: Seq[T[_]]) +}
\ No newline at end of file diff --git a/test/files/pos/t5769.scala b/test/files/pos/t5769.scala new file mode 100644 index 0000000000..723d37bfee --- /dev/null +++ b/test/files/pos/t5769.scala @@ -0,0 +1,8 @@ +// a.scala + +class A { + type AI = Array[Int] + + def f1 = arrayTag[Array[Int]] + def f2 = arrayTag[AI] +}
\ No newline at end of file diff --git a/test/files/pos/t5777.scala b/test/files/pos/t5777.scala new file mode 100644 index 0000000000..24cea36163 --- /dev/null +++ b/test/files/pos/t5777.scala @@ -0,0 +1,45 @@ +// /scala/trac/5777/a.scala +// Wed May 9 08:44:57 PDT 2012 + +trait Ring { + trait E +} + +class Poly[C <: Ring](val ring: C) extends Ring +// This definition of Poly triggers the same failure on *both* versions +// class Poly(val ring: Ring) extends Ring + +object BigInt extends Ring + +object MyApp { + val r = new Poly(BigInt) + + implicitly[r.ring.E <:< BigInt.E] + + // fail on 2.10, works on 2.9.2 + (null.asInstanceOf[BigInt.E] : r.ring.E) + + // works on both versions + val r1 = new Poly[BigInt.type](BigInt) + (null.asInstanceOf[BigInt.E] : r1.ring.E) + + // Oddly, -Xprint:typer reports that r and r1 have the same inferred type. + // + // private[this] val r: Poly[BigInt.type] = new Poly[BigInt.type](BigInt); + // <stable> <accessor> def r: Poly[BigInt.type] = MyApp.this.r; + // (null.asInstanceOf[BigInt.E]: MyApp.r.ring.E); + // private[this] val r1: Poly[BigInt.type] = new Poly[BigInt.type](BigInt); + // <stable> <accessor> def r1: Poly[BigInt.type] = MyApp.this.r1; + // (null.asInstanceOf[BigInt.E]: MyApp.r1.ring.E) + + // diff typer-2.9.2.txt typer-2.10.txt + // ... + // --- + // > object MyApp extends scala.AnyRef { + // > def <init>(): MyApp.type = { + // > MyApp.super.<init>(); + // 30c30 + // < scala.this.Predef.implicitly[<:<[BigInt.E,MyApp.r.ring.E]](scala.this.Predef.conforms[BigInt.E]); + // --- + // > scala.this.Predef.implicitly[<:<[BigInt.E,MyApp.r.ring.E]](); +} diff --git a/test/files/pos/t5779-numeq-warn.scala b/test/files/pos/t5779-numeq-warn.scala new file mode 100644 index 0000000000..76ef2970fd --- /dev/null +++ b/test/files/pos/t5779-numeq-warn.scala @@ -0,0 +1,13 @@ + +object Test { + def main(args: Array[String]) { + val d: Double = (BigInt(1) << 64).toDouble + val f: Float = d.toFloat + val n: java.lang.Number = d.toFloat + assert (d == f) // ok + assert (d == n) // was: comparing values of types Double and Number using `==' will always yield false + assert (n == d) // was: Number and Double are unrelated: they will most likely never compare equal + assert (f == n) + assert (n == f) + } +} diff --git a/test/files/pos/t5796.scala b/test/files/pos/t5796.scala new file mode 100644 index 0000000000..d05350c535 --- /dev/null +++ b/test/files/pos/t5796.scala @@ -0,0 +1,8 @@ +object Bug { + def foo() { + val v = { + lazy val s = 0 + s + } + } +} diff --git a/test/files/pos/t5809.flags b/test/files/pos/t5809.flags new file mode 100644 index 0000000000..e93641e931 --- /dev/null +++ b/test/files/pos/t5809.flags @@ -0,0 +1 @@ +-Xlint -Xfatal-warnings
\ No newline at end of file diff --git a/test/files/pos/t5809.scala b/test/files/pos/t5809.scala new file mode 100644 index 0000000000..8f6ce708d2 --- /dev/null +++ b/test/files/pos/t5809.scala @@ -0,0 +1,10 @@ +package scala.reflect + +package object api { + implicit class PimpedExpr[T](expr: Universe # Expr[T]) { + def runtimeEval: T = { + println("hello, dear") + expr.eval + } + } +}
\ No newline at end of file diff --git a/test/files/pos/t5829.scala b/test/files/pos/t5829.scala new file mode 100644 index 0000000000..236045ed11 --- /dev/null +++ b/test/files/pos/t5829.scala @@ -0,0 +1,18 @@ +trait Universe { + type Tree + + type SymTree <: Tree + type NameTree <: Tree + type RefTree <: SymTree with NameTree + + type Ident <: RefTree + type Select <: RefTree +} + +object Test extends App { + val universe: Universe = null + import universe._ + def select: Select = ??? + def ident: Ident = ??? + List(select, ident) +}
\ No newline at end of file diff --git a/test/files/pos/value-class-override-no-spec.flags b/test/files/pos/value-class-override-no-spec.flags new file mode 100644 index 0000000000..a7e64e4f0c --- /dev/null +++ b/test/files/pos/value-class-override-no-spec.flags @@ -0,0 +1 @@ +-no-specialization
\ No newline at end of file diff --git a/test/files/pos/value-class-override-no-spec.scala b/test/files/pos/value-class-override-no-spec.scala new file mode 100644 index 0000000000..79de5d9305 --- /dev/null +++ b/test/files/pos/value-class-override-no-spec.scala @@ -0,0 +1,9 @@ +// There are two versions of this tests: one with and one without specialization. +// The bug was only exposed *without* specialization. +trait T extends Any { + def x: Any +} + +final class StringOps(val repr0: String) extends AnyVal with T { + def x = () +} diff --git a/test/files/pos/value-class-override-spec.scala b/test/files/pos/value-class-override-spec.scala new file mode 100644 index 0000000000..79de5d9305 --- /dev/null +++ b/test/files/pos/value-class-override-spec.scala @@ -0,0 +1,9 @@ +// There are two versions of this tests: one with and one without specialization. +// The bug was only exposed *without* specialization. +trait T extends Any { + def x: Any +} + +final class StringOps(val repr0: String) extends AnyVal with T { + def x = () +} diff --git a/test/files/pos/virtpatmat_alts_subst.flags b/test/files/pos/virtpatmat_alts_subst.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/pos/virtpatmat_alts_subst.flags +++ b/test/files/pos/virtpatmat_alts_subst.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/pos/virtpatmat_anonfun_for.flags b/test/files/pos/virtpatmat_anonfun_for.flags index 23e3dc7d26..e69de29bb2 100644 --- a/test/files/pos/virtpatmat_anonfun_for.flags +++ b/test/files/pos/virtpatmat_anonfun_for.flags @@ -1 +0,0 @@ --Yvirtpatmat
\ No newline at end of file diff --git a/test/files/pos/virtpatmat_binding_opt.flags b/test/files/pos/virtpatmat_binding_opt.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/pos/virtpatmat_binding_opt.flags +++ b/test/files/pos/virtpatmat_binding_opt.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/pos/virtpatmat_castbinder.flags b/test/files/pos/virtpatmat_castbinder.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/pos/virtpatmat_castbinder.flags +++ b/test/files/pos/virtpatmat_castbinder.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/pos/virtpatmat_exhaust.scala b/test/files/pos/virtpatmat_exhaust.scala new file mode 100644 index 0000000000..a2f47c88c8 --- /dev/null +++ b/test/files/pos/virtpatmat_exhaust.scala @@ -0,0 +1,24 @@ +sealed trait Option {} +case class Choice(a: Option, b: Option) extends Option; +case class Some(x: Boolean) extends Option; +case object None extends Option; + +object test { + +// drop any case and it will report an error +// note that booleans are taken into account + def f(opt: Option) = opt match { + case Choice(None, None) => 1; + case Choice(None, Some(_)) => 1; + case Choice(None, Choice(_, _)) => 1; + case Choice(Some(true), None) => 1; + case Choice(Some(false), None) => 1; + case Choice(Some(_), Some(_)) => 1; + case Choice(Some(_), Choice(_, _)) => 1; + case Choice(Choice(_, _), None) => 1; + case Choice(Choice(_, _), Some(_)) => 1; + case Choice(Choice(_, _), Choice(_, _)) => 1; + case Some(b) => 4; + case None => 5; + } +} diff --git a/test/files/pos/virtpatmat_exhaust_unchecked.flags b/test/files/pos/virtpatmat_exhaust_unchecked.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/pos/virtpatmat_exhaust_unchecked.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/pos/virtpatmat_exhaust_unchecked.scala b/test/files/pos/virtpatmat_exhaust_unchecked.scala new file mode 100644 index 0000000000..641f2b4f9a --- /dev/null +++ b/test/files/pos/virtpatmat_exhaust_unchecked.scala @@ -0,0 +1,24 @@ +sealed trait Option {} +case class Choice(a: Option, b: Option) extends Option; +case class Some(x: Boolean) extends Option; +case object None extends Option; + +object test { + +// drop any case and it will report an error +// note that booleans are taken into account + def f(opt: Option) = (opt: @unchecked) match { + case Choice(None, None) => 1; + case Choice(None, Some(_)) => 1; + case Choice(None, Choice(_, _)) => 1; + case Choice(Some(true), None) => 1; + // case Choice(Some(false), None) => 1; + case Choice(Some(_), Some(_)) => 1; + case Choice(Some(_), Choice(_, _)) => 1; + case Choice(Choice(_, _), None) => 1; + case Choice(Choice(_, _), Some(_)) => 1; + case Choice(Choice(_, _), Choice(_, _)) => 1; + case Some(b) => 4; + case None => 5; + } +} diff --git a/test/files/pos/virtpatmat_exist1.flags b/test/files/pos/virtpatmat_exist1.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/pos/virtpatmat_exist1.flags +++ b/test/files/pos/virtpatmat_exist1.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/pos/virtpatmat_exist2.flags b/test/files/pos/virtpatmat_exist2.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/pos/virtpatmat_exist2.flags +++ b/test/files/pos/virtpatmat_exist2.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/pos/virtpatmat_exist3.flags b/test/files/pos/virtpatmat_exist3.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/pos/virtpatmat_exist3.flags +++ b/test/files/pos/virtpatmat_exist3.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/pos/virtpatmat_exist_uncurry.scala b/test/files/pos/virtpatmat_exist_uncurry.scala new file mode 100644 index 0000000000..e017da6343 --- /dev/null +++ b/test/files/pos/virtpatmat_exist_uncurry.scala @@ -0,0 +1,6 @@ +object Test { + trait Leaf[T] { + def collect[U](f: PartialFunction[Leaf[_], U]): List[U] + def leaves: List[Leaf[T]] = collect { case l: Leaf[T] => l } + } +}
\ No newline at end of file diff --git a/test/files/pos/virtpatmat_gadt_array.flags b/test/files/pos/virtpatmat_gadt_array.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/pos/virtpatmat_gadt_array.flags +++ b/test/files/pos/virtpatmat_gadt_array.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/pos/virtpatmat_infer_single_1.flags b/test/files/pos/virtpatmat_infer_single_1.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/pos/virtpatmat_infer_single_1.flags +++ b/test/files/pos/virtpatmat_infer_single_1.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/pos/virtpatmat_instof_valuetype.flags b/test/files/pos/virtpatmat_instof_valuetype.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/pos/virtpatmat_instof_valuetype.flags +++ b/test/files/pos/virtpatmat_instof_valuetype.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/pos/virtpatmat_obj_in_case.flags b/test/files/pos/virtpatmat_obj_in_case.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/pos/virtpatmat_obj_in_case.flags +++ b/test/files/pos/virtpatmat_obj_in_case.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/pos/virtpatmat_partialfun_nsdnho.scala b/test/files/pos/virtpatmat_partialfun_nsdnho.scala new file mode 100644 index 0000000000..f79e82813c --- /dev/null +++ b/test/files/pos/virtpatmat_partialfun_nsdnho.scala @@ -0,0 +1,18 @@ +class Test { + // m.$minus(1) + // at scala.Predef$.assert(Predef.scala:185) + // at scala.tools.nsc.Global.assert(Global.scala:187) + // at scala.tools.nsc.typechecker.SuperAccessors$SuperAccTransformer.transform(SuperAccessors.scala:291) + val a: (Map[Int, Int] => (Any => Any)) = { m => { case _ => m - 1} } + + // patmat-crash.scala:9: error: erroneous or inaccessible type + val b: (Int => (Any => Any)) = { m => { case _ => m } } + + // no-symbol does not have an owner (this is a bug: scala version 2.10.0-20120420-170445-56c1f29250) + // at scala.reflect.internal.SymbolTable.abort(SymbolTable.scala:45) + // at scala.tools.nsc.Global.abort(Global.scala:202) + // at scala.reflect.internal.Symbols$NoSymbol.owner(Symbols.scala:3031) + // at scala.tools.nsc.typechecker.SuperAccessors$SuperAccTransformer.hostForAccessorOf(SuperAccessors.scala:474) + // at scala.tools.nsc.typechecker.SuperAccessors$SuperAccTransformer.needsProtectedAccessor(SuperAccessors.scala:457) + val c: (Int => (Any => Any)) = { m => { case _ => m.toInt } } +}
\ No newline at end of file diff --git a/test/files/pos/virtpatmat_reach_const.scala b/test/files/pos/virtpatmat_reach_const.scala new file mode 100644 index 0000000000..b55b7cb229 --- /dev/null +++ b/test/files/pos/virtpatmat_reach_const.scala @@ -0,0 +1,11 @@ +// check the interaction between constants and type tests in creating the equality axioms +object Test { + type Formula = List[String] + val TrueF: Formula = List() + def distribute(a: Formula, b: Formula) = (a, b) match { + case (TrueF, _) => + case (_, TrueF) => // bug: considered unreachable + case (a :: Nil, b :: Nil) => + case _ => + } +}
\ No newline at end of file diff --git a/test/files/pos/z1730.flags b/test/files/pos/z1730.flags new file mode 100644 index 0000000000..5319681590 --- /dev/null +++ b/test/files/pos/z1730.flags @@ -0,0 +1 @@ +-Ycheck:all
\ No newline at end of file diff --git a/test/files/pos/z1730.scala b/test/files/pos/z1730.scala new file mode 100644 index 0000000000..0c5875a818 --- /dev/null +++ b/test/files/pos/z1730.scala @@ -0,0 +1,13 @@ +// /scala/trac/z1730/a.scala +// Wed May 23 07:41:25 PDT 2012 + +class X[R] { + def xx(value: => R, addTweak: Boolean = true) = 0 +} + +class Boo { + implicit def toX[R](v: R) : X[R] = null + def goo2 { + 3.xx(34) + } +} diff --git a/test/files/presentation/callcc-interpreter.check b/test/files/presentation/callcc-interpreter.check index c50e171b4e..3a08e2a2ea 100644 --- a/test/files/presentation/callcc-interpreter.check +++ b/test/files/presentation/callcc-interpreter.check @@ -4,66 +4,66 @@ askTypeCompletion at CallccInterpreter.scala(51,38) ================================================================================ [response] aksTypeCompletion at (51,38) retrieved 64 members -`class AddcallccInterpreter.Add` -`class AppcallccInterpreter.App` -`class CcccallccInterpreter.Ccc` -`class ConcallccInterpreter.Con` -`class FuncallccInterpreter.Fun` -`class LamcallccInterpreter.Lam` -`class McallccInterpreter.M` -`class NumcallccInterpreter.Num` -`class VarcallccInterpreter.Var` -`method !=(x$1: Any)Boolean` -`method !=(x$1: AnyRef)Boolean` -`method ##()Int` -`method +(other: String)String` -`method ->[B](y: B)(callccInterpreter.type, B)` -`method ==(x$1: Any)Boolean` -`method ==(x$1: AnyRef)Boolean` -`method add(a: callccInterpreter.Value, b: callccInterpreter.Value)callccInterpreter.M[_ >: callccInterpreter.Num with callccInterpreter.Wrong.type <: Product with Serializable with callccInterpreter.Value]` -`method apply(a: callccInterpreter.Value, b: callccInterpreter.Value)callccInterpreter.M[callccInterpreter.Value]` -`method asInstanceOf[T0]=> T0` -`method callCC[A](h: (A => callccInterpreter.M[A]) => callccInterpreter.M[A])callccInterpreter.M[A]` -`method clone()Object` -`method ensuring(cond: Boolean)callccInterpreter.type` -`method ensuring(cond: Boolean, msg: => Any)callccInterpreter.type` -`method ensuring(cond: callccInterpreter.type => Boolean)callccInterpreter.type` -`method ensuring(cond: callccInterpreter.type => Boolean, msg: => Any)callccInterpreter.type` -`method eq(x$1: AnyRef)Boolean` -`method equals(x$1: Any)Boolean` -`method finalize()Unit` -`method formatted(fmtstr: String)String` -`method hashCode()Int` -`method id[A]=> A => A` -`method interp(t: callccInterpreter.Term, e: callccInterpreter.Environment)callccInterpreter.M[callccInterpreter.Value]` -`method isInstanceOf[T0]=> Boolean` -`method lookup(x: callccInterpreter.Name, e: callccInterpreter.Environment)callccInterpreter.M[callccInterpreter.Value]` -`method main(args: Array[String])Unit` -`method ne(x$1: AnyRef)Boolean` -`method notify()Unit` -`method notifyAll()Unit` -`method showM(m: callccInterpreter.M[callccInterpreter.Value])String` -`method synchronized[T0](x$1: T0)T0` -`method test(t: callccInterpreter.Term)String` -`method toString()String` -`method unitM[A](a: A)callccInterpreter.M[A]` -`method wait()Unit` -`method wait(x$1: Long)Unit` -`method wait(x$1: Long, x$2: Int)Unit` -`method x=> callccInterpreter.type` -`method →[B](y: B)(callccInterpreter.type, B)` -`object WrongcallccInterpreter.Wrong.type` -`trait TermcallccInterpreter.Term` -`trait ValuecallccInterpreter.Value` -`type AnswercallccInterpreter.Answer` -`type EnvironmentcallccInterpreter.Environment` -`type NamecallccInterpreter.Name` -`value __leftOfArrowcallccInterpreter.type` -`value __resultOfEnsuringcallccInterpreter.type` -`value selfAny` -`value term0callccInterpreter.App` -`value term1callccInterpreter.App` -`value term2callccInterpreter.Add` +[accessible: true] `class AddcallccInterpreter.Add` +[accessible: true] `class AppcallccInterpreter.App` +[accessible: true] `class CcccallccInterpreter.Ccc` +[accessible: true] `class ConcallccInterpreter.Con` +[accessible: true] `class FuncallccInterpreter.Fun` +[accessible: true] `class LamcallccInterpreter.Lam` +[accessible: true] `class McallccInterpreter.M` +[accessible: true] `class NumcallccInterpreter.Num` +[accessible: true] `class VarcallccInterpreter.Var` +[accessible: true] `method !=(x$1: Any)Boolean` +[accessible: true] `method !=(x$1: AnyRef)Boolean` +[accessible: true] `method ##()Int` +[accessible: true] `method +(other: String)String` +[accessible: true] `method ->[B](y: B)(callccInterpreter.type, B)` +[accessible: true] `method ==(x$1: Any)Boolean` +[accessible: true] `method ==(x$1: AnyRef)Boolean` +[accessible: true] `method add(a: callccInterpreter.Value, b: callccInterpreter.Value)callccInterpreter.M[_ >: callccInterpreter.Num with callccInterpreter.Wrong.type <: Product with Serializable with callccInterpreter.Value]` +[accessible: true] `method apply(a: callccInterpreter.Value, b: callccInterpreter.Value)callccInterpreter.M[callccInterpreter.Value]` +[accessible: true] `method asInstanceOf[T0]=> T0` +[accessible: true] `method callCC[A](h: (A => callccInterpreter.M[A]) => callccInterpreter.M[A])callccInterpreter.M[A]` +[accessible: true] `method clone()Object` +[accessible: true] `method ensuring(cond: Boolean)callccInterpreter.type` +[accessible: true] `method ensuring(cond: Boolean, msg: => Any)callccInterpreter.type` +[accessible: true] `method ensuring(cond: callccInterpreter.type => Boolean)callccInterpreter.type` +[accessible: true] `method ensuring(cond: callccInterpreter.type => Boolean, msg: => Any)callccInterpreter.type` +[accessible: true] `method eq(x$1: AnyRef)Boolean` +[accessible: true] `method equals(x$1: Any)Boolean` +[accessible: true] `method finalize()Unit` +[accessible: true] `method formatted(fmtstr: String)String` +[accessible: true] `method hashCode()Int` +[accessible: true] `method id[A]=> A => A` +[accessible: true] `method interp(t: callccInterpreter.Term, e: callccInterpreter.Environment)callccInterpreter.M[callccInterpreter.Value]` +[accessible: true] `method isInstanceOf[T0]=> Boolean` +[accessible: true] `method lookup(x: callccInterpreter.Name, e: callccInterpreter.Environment)callccInterpreter.M[callccInterpreter.Value]` +[accessible: true] `method main(args: Array[String])Unit` +[accessible: true] `method ne(x$1: AnyRef)Boolean` +[accessible: true] `method notify()Unit` +[accessible: true] `method notifyAll()Unit` +[accessible: true] `method showM(m: callccInterpreter.M[callccInterpreter.Value])String` +[accessible: true] `method synchronized[T0](x$1: T0)T0` +[accessible: true] `method test(t: callccInterpreter.Term)String` +[accessible: true] `method toString()String` +[accessible: true] `method unitM[A](a: A)callccInterpreter.M[A]` +[accessible: true] `method wait()Unit` +[accessible: true] `method wait(x$1: Long)Unit` +[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` +[accessible: true] `method x=> callccInterpreter.type` +[accessible: true] `method →[B](y: B)(callccInterpreter.type, B)` +[accessible: true] `object WrongcallccInterpreter.Wrong.type` +[accessible: true] `trait TermcallccInterpreter.Term` +[accessible: true] `trait ValuecallccInterpreter.Value` +[accessible: true] `type AnswercallccInterpreter.Answer` +[accessible: true] `type EnvironmentcallccInterpreter.Environment` +[accessible: true] `type NamecallccInterpreter.Name` +[accessible: true] `value __leftOfArrowcallccInterpreter.type` +[accessible: true] `value __resultOfEnsuringcallccInterpreter.type` +[accessible: true] `value selfAny` +[accessible: true] `value term0callccInterpreter.App` +[accessible: true] `value term1callccInterpreter.App` +[accessible: true] `value term2callccInterpreter.Add` ================================================================================ askType at CallccInterpreter.scala(14,21) diff --git a/test/files/presentation/hyperlinks.check b/test/files/presentation/hyperlinks.check new file mode 100644 index 0000000000..85d295dd7d --- /dev/null +++ b/test/files/presentation/hyperlinks.check @@ -0,0 +1,46 @@ +reload: NameDefaultTests.scala, PatMatTests.scala + +askHyperlinkPos for `someOtherInt` at (14,24) NameDefaultTests.scala +================================================================================ +[response] found askHyperlinkPos for `someOtherInt` at (12,9) NameDefaultTests.scala +================================================================================ + +askHyperlinkPos for `someString` at (14,45) NameDefaultTests.scala +================================================================================ +[response] found askHyperlinkPos for `someString` at (3,7) NameDefaultTests.scala +================================================================================ + +askHyperlinkPos for `CaseOne` at (12,18) PatMatTests.scala +================================================================================ +[response] found askHyperlinkPos for `CaseOne` at (5,12) PatMatTests.scala +================================================================================ + +askHyperlinkPos for `first` at (14,21) PatMatTests.scala +================================================================================ +[response] found askHyperlinkPos for `first` at (12,29) PatMatTests.scala +================================================================================ + +askHyperlinkPos for `tmp` at (15,19) PatMatTests.scala +================================================================================ +[response] found askHyperlinkPos for `tmp` at (13,13) PatMatTests.scala +================================================================================ + +askHyperlinkPos for `CaseTwo` at (17,18) PatMatTests.scala +================================================================================ +[response] found askHyperlinkPos for `CaseTwo` at (6,12) PatMatTests.scala +================================================================================ + +askHyperlinkPos for `mystring` at (18,24) PatMatTests.scala +================================================================================ +[response] found askHyperlinkPos for `mystring` at (17,25) PatMatTests.scala +================================================================================ + +askHyperlinkPos for `x` at (25,13) PatMatTests.scala +================================================================================ +[response] found askHyperlinkPos for `x` at (23,10) PatMatTests.scala +================================================================================ + +askHyperlinkPos for `y` at (25,21) PatMatTests.scala +================================================================================ +[response] found askHyperlinkPos for `y` at (23,13) PatMatTests.scala +================================================================================ diff --git a/test/files/presentation/hyperlinks.flags b/test/files/presentation/hyperlinks.flags new file mode 100644 index 0000000000..dc13682c5e --- /dev/null +++ b/test/files/presentation/hyperlinks.flags @@ -0,0 +1,2 @@ +# This test will fail in the new pattern matcher because +# it generates trees whose positions are not transparent diff --git a/test/files/presentation/hyperlinks/Runner.scala b/test/files/presentation/hyperlinks/Runner.scala new file mode 100644 index 0000000000..3d19f2d948 --- /dev/null +++ b/test/files/presentation/hyperlinks/Runner.scala @@ -0,0 +1,11 @@ +import scala.tools.nsc.interactive.tests.InteractiveTest + +object Test extends InteractiveTest { + override def runTests() { + // make sure typer is done.. the virtual pattern matcher might translate + // some trees and mess up positions. But we'll catch it red handed! + sourceFiles foreach (src => askLoadedTyped(src).get) + super.runTests() + } + +}
\ No newline at end of file diff --git a/test/files/presentation/hyperlinks/src/NameDefaultTests.scala b/test/files/presentation/hyperlinks/src/NameDefaultTests.scala new file mode 100644 index 0000000000..b218040fe3 --- /dev/null +++ b/test/files/presentation/hyperlinks/src/NameDefaultTests.scala @@ -0,0 +1,16 @@ + +class NameDefaults { + val someString = "abc" + val someInt = 42 + + def foo(x: String, y: Int)(implicit logger: Int): Int = y + + implicit val l = 42 + + def bar { + println() + val someOtherInt = 10 + + foo(y = someOtherInt/*#*/, x = someString/*#*/) + } +} diff --git a/test/files/presentation/hyperlinks/src/PatMatTests.scala b/test/files/presentation/hyperlinks/src/PatMatTests.scala new file mode 100644 index 0000000000..bbd0f2e7ed --- /dev/null +++ b/test/files/presentation/hyperlinks/src/PatMatTests.scala @@ -0,0 +1,28 @@ +package patmat + +abstract class BaseType + +case class CaseOne(x: Int, y: List[Int]) extends BaseType +case class CaseTwo(str: String) extends BaseType + +class PatMatTests { + + def foo(x: BaseType) { + x match { + case CaseOne/*#*/(10, first :: second :: Nil) => + val tmp = 23 + println(first/*#*/) + println(tmp/*#*/) + + case CaseTwo/*#*/(mystring) => + println(mystring/*#*/) + } + } + + def multipleAssign() { + val (x, y) = ("abc", "def") + + println(x/*#*/, y/*#*/) + } + +}
\ No newline at end of file diff --git a/test/files/presentation/ide-bug-1000349.check b/test/files/presentation/ide-bug-1000349.check index 9c070ef24e..44a3207d75 100644 --- a/test/files/presentation/ide-bug-1000349.check +++ b/test/files/presentation/ide-bug-1000349.check @@ -4,37 +4,37 @@ askTypeCompletion at CompletionOnEmptyArgMethod.scala(2,17) ================================================================================ [response] aksTypeCompletion at (2,17) retrieved 37 members -`method !=(x$1: Any)Boolean` -`method !=(x$1: AnyRef)Boolean` -`method ##()Int` -`method +(other: String)String` -`method ->[B](y: B)(Foo, B)` -`method ==(x$1: Any)Boolean` -`method ==(x$1: AnyRef)Boolean` -`method asInstanceOf[T0]=> T0` -`method clone()Object` -`method ensuring(cond: Boolean)Foo` -`method ensuring(cond: Boolean, msg: => Any)Foo` -`method ensuring(cond: Foo => Boolean)Foo` -`method ensuring(cond: Foo => Boolean, msg: => Any)Foo` -`method eq(x$1: AnyRef)Boolean` -`method equals(x$1: Any)Boolean` -`method finalize()Unit` -`method foo=> Foo` -`method formatted(fmtstr: String)String` -`method hashCode()Int` -`method isInstanceOf[T0]=> Boolean` -`method ne(x$1: AnyRef)Boolean` -`method notify()Unit` -`method notifyAll()Unit` -`method synchronized[T0](x$1: T0)T0` -`method toString()String` -`method wait()Unit` -`method wait(x$1: Long)Unit` -`method wait(x$1: Long, x$2: Int)Unit` -`method x=> Foo` -`method →[B](y: B)(Foo, B)` -`value __leftOfArrowFoo` -`value __resultOfEnsuringFoo` -`value selfAny` -================================================================================
\ No newline at end of file +[accessible: true] `method !=(x$1: Any)Boolean` +[accessible: true] `method !=(x$1: AnyRef)Boolean` +[accessible: true] `method ##()Int` +[accessible: true] `method +(other: String)String` +[accessible: true] `method ->[B](y: B)(Foo, B)` +[accessible: true] `method ==(x$1: Any)Boolean` +[accessible: true] `method ==(x$1: AnyRef)Boolean` +[accessible: true] `method asInstanceOf[T0]=> T0` +[accessible: true] `method clone()Object` +[accessible: true] `method ensuring(cond: Boolean)Foo` +[accessible: true] `method ensuring(cond: Boolean, msg: => Any)Foo` +[accessible: true] `method ensuring(cond: Foo => Boolean)Foo` +[accessible: true] `method ensuring(cond: Foo => Boolean, msg: => Any)Foo` +[accessible: true] `method eq(x$1: AnyRef)Boolean` +[accessible: true] `method equals(x$1: Any)Boolean` +[accessible: true] `method finalize()Unit` +[accessible: true] `method foo=> Foo` +[accessible: true] `method formatted(fmtstr: String)String` +[accessible: true] `method hashCode()Int` +[accessible: true] `method isInstanceOf[T0]=> Boolean` +[accessible: true] `method ne(x$1: AnyRef)Boolean` +[accessible: true] `method notify()Unit` +[accessible: true] `method notifyAll()Unit` +[accessible: true] `method synchronized[T0](x$1: T0)T0` +[accessible: true] `method toString()String` +[accessible: true] `method wait()Unit` +[accessible: true] `method wait(x$1: Long)Unit` +[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` +[accessible: true] `method x=> Foo` +[accessible: true] `method →[B](y: B)(Foo, B)` +[accessible: true] `value __leftOfArrowFoo` +[accessible: true] `value __resultOfEnsuringFoo` +[accessible: true] `value selfAny` +================================================================================ diff --git a/test/files/presentation/ide-bug-1000475.check b/test/files/presentation/ide-bug-1000475.check index 1718119385..34c3b557d8 100644 --- a/test/files/presentation/ide-bug-1000475.check +++ b/test/files/presentation/ide-bug-1000475.check @@ -4,112 +4,112 @@ askTypeCompletion at Foo.scala(3,7) ================================================================================ [response] aksTypeCompletion at (3,7) retrieved 36 members -`method !=(x$1: Any)Boolean` -`method !=(x$1: AnyRef)Boolean` -`method ##()Int` -`method +(other: String)String` -`method ->[B](y: B)(Object, B)` -`method ==(x$1: Any)Boolean` -`method ==(x$1: AnyRef)Boolean` -`method asInstanceOf[T0]=> T0` -`method clone()Object` -`method ensuring(cond: Boolean)Object` -`method ensuring(cond: Boolean, msg: => Any)Object` -`method ensuring(cond: Object => Boolean)Object` -`method ensuring(cond: Object => Boolean, msg: => Any)Object` -`method eq(x$1: AnyRef)Boolean` -`method equals(x$1: Any)Boolean` -`method finalize()Unit` -`method formatted(fmtstr: String)String` -`method hashCode()Int` -`method isInstanceOf[T0]=> Boolean` -`method ne(x$1: AnyRef)Boolean` -`method notify()Unit` -`method notifyAll()Unit` -`method synchronized[T0](x$1: T0)T0` -`method toString()String` -`method wait()Unit` -`method wait(x$1: Long)Unit` -`method wait(x$1: Long, x$2: Int)Unit` -`method x=> Object` -`method →[B](y: B)(Object, B)` -`value __leftOfArrowObject` -`value __resultOfEnsuringObject` -`value selfAny` +[accessible: true] `method !=(x$1: Any)Boolean` +[accessible: true] `method !=(x$1: AnyRef)Boolean` +[accessible: true] `method ##()Int` +[accessible: true] `method +(other: String)String` +[accessible: true] `method ->[B](y: B)(Object, B)` +[accessible: true] `method ==(x$1: Any)Boolean` +[accessible: true] `method ==(x$1: AnyRef)Boolean` +[accessible: true] `method asInstanceOf[T0]=> T0` +[accessible: true] `method ensuring(cond: Boolean)Object` +[accessible: true] `method ensuring(cond: Boolean, msg: => Any)Object` +[accessible: true] `method ensuring(cond: Object => Boolean)Object` +[accessible: true] `method ensuring(cond: Object => Boolean, msg: => Any)Object` +[accessible: true] `method eq(x$1: AnyRef)Boolean` +[accessible: true] `method equals(x$1: Any)Boolean` +[accessible: true] `method formatted(fmtstr: String)String` +[accessible: true] `method hashCode()Int` +[accessible: true] `method isInstanceOf[T0]=> Boolean` +[accessible: true] `method ne(x$1: AnyRef)Boolean` +[accessible: true] `method notify()Unit` +[accessible: true] `method notifyAll()Unit` +[accessible: true] `method synchronized[T0](x$1: T0)T0` +[accessible: true] `method toString()String` +[accessible: true] `method wait()Unit` +[accessible: true] `method wait(x$1: Long)Unit` +[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` +[accessible: true] `method x=> Object` +[accessible: true] `method →[B](y: B)(Object, B)` +[accessible: true] `value __leftOfArrowObject` +[accessible: true] `value __resultOfEnsuringObject` +[accessible: true] `value selfAny` +[accessible: false] `method clone()Object` +[accessible: false] `method finalize()Unit` ================================================================================ askTypeCompletion at Foo.scala(6,10) ================================================================================ [response] aksTypeCompletion at (6,10) retrieved 36 members -`method !=(x$1: Any)Boolean` -`method !=(x$1: AnyRef)Boolean` -`method ##()Int` -`method +(other: String)String` -`method ->[B](y: B)(Object, B)` -`method ==(x$1: Any)Boolean` -`method ==(x$1: AnyRef)Boolean` -`method asInstanceOf[T0]=> T0` -`method clone()Object` -`method ensuring(cond: Boolean)Object` -`method ensuring(cond: Boolean, msg: => Any)Object` -`method ensuring(cond: Object => Boolean)Object` -`method ensuring(cond: Object => Boolean, msg: => Any)Object` -`method eq(x$1: AnyRef)Boolean` -`method equals(x$1: Any)Boolean` -`method finalize()Unit` -`method formatted(fmtstr: String)String` -`method hashCode()Int` -`method isInstanceOf[T0]=> Boolean` -`method ne(x$1: AnyRef)Boolean` -`method notify()Unit` -`method notifyAll()Unit` -`method synchronized[T0](x$1: T0)T0` -`method toString()String` -`method wait()Unit` -`method wait(x$1: Long)Unit` -`method wait(x$1: Long, x$2: Int)Unit` -`method x=> Object` -`method →[B](y: B)(Object, B)` -`value __leftOfArrowObject` -`value __resultOfEnsuringObject` -`value selfAny` +[accessible: true] `method !=(x$1: Any)Boolean` +[accessible: true] `method !=(x$1: AnyRef)Boolean` +[accessible: true] `method ##()Int` +[accessible: true] `method +(other: String)String` +[accessible: true] `method ->[B](y: B)(Object, B)` +[accessible: true] `method ==(x$1: Any)Boolean` +[accessible: true] `method ==(x$1: AnyRef)Boolean` +[accessible: true] `method asInstanceOf[T0]=> T0` +[accessible: true] `method ensuring(cond: Boolean)Object` +[accessible: true] `method ensuring(cond: Boolean, msg: => Any)Object` +[accessible: true] `method ensuring(cond: Object => Boolean)Object` +[accessible: true] `method ensuring(cond: Object => Boolean, msg: => Any)Object` +[accessible: true] `method eq(x$1: AnyRef)Boolean` +[accessible: true] `method equals(x$1: Any)Boolean` +[accessible: true] `method formatted(fmtstr: String)String` +[accessible: true] `method hashCode()Int` +[accessible: true] `method isInstanceOf[T0]=> Boolean` +[accessible: true] `method ne(x$1: AnyRef)Boolean` +[accessible: true] `method notify()Unit` +[accessible: true] `method notifyAll()Unit` +[accessible: true] `method synchronized[T0](x$1: T0)T0` +[accessible: true] `method toString()String` +[accessible: true] `method wait()Unit` +[accessible: true] `method wait(x$1: Long)Unit` +[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` +[accessible: true] `method x=> Object` +[accessible: true] `method →[B](y: B)(Object, B)` +[accessible: true] `value __leftOfArrowObject` +[accessible: true] `value __resultOfEnsuringObject` +[accessible: true] `value selfAny` +[accessible: false] `method clone()Object` +[accessible: false] `method finalize()Unit` ================================================================================ askTypeCompletion at Foo.scala(7,7) ================================================================================ [response] aksTypeCompletion at (7,7) retrieved 36 members -`method !=(x$1: Any)Boolean` -`method !=(x$1: AnyRef)Boolean` -`method ##()Int` -`method +(other: String)String` -`method ->[B](y: B)(Object, B)` -`method ==(x$1: Any)Boolean` -`method ==(x$1: AnyRef)Boolean` -`method asInstanceOf[T0]=> T0` -`method clone()Object` -`method ensuring(cond: Boolean)Object` -`method ensuring(cond: Boolean, msg: => Any)Object` -`method ensuring(cond: Object => Boolean)Object` -`method ensuring(cond: Object => Boolean, msg: => Any)Object` -`method eq(x$1: AnyRef)Boolean` -`method equals(x$1: Any)Boolean` -`method finalize()Unit` -`method formatted(fmtstr: String)String` -`method hashCode()Int` -`method isInstanceOf[T0]=> Boolean` -`method ne(x$1: AnyRef)Boolean` -`method notify()Unit` -`method notifyAll()Unit` -`method synchronized[T0](x$1: T0)T0` -`method toString()String` -`method wait()Unit` -`method wait(x$1: Long)Unit` -`method wait(x$1: Long, x$2: Int)Unit` -`method x=> Object` -`method →[B](y: B)(Object, B)` -`value __leftOfArrowObject` -`value __resultOfEnsuringObject` -`value selfAny` +[accessible: true] `method !=(x$1: Any)Boolean` +[accessible: true] `method !=(x$1: AnyRef)Boolean` +[accessible: true] `method ##()Int` +[accessible: true] `method +(other: String)String` +[accessible: true] `method ->[B](y: B)(Object, B)` +[accessible: true] `method ==(x$1: Any)Boolean` +[accessible: true] `method ==(x$1: AnyRef)Boolean` +[accessible: true] `method asInstanceOf[T0]=> T0` +[accessible: true] `method ensuring(cond: Boolean)Object` +[accessible: true] `method ensuring(cond: Boolean, msg: => Any)Object` +[accessible: true] `method ensuring(cond: Object => Boolean)Object` +[accessible: true] `method ensuring(cond: Object => Boolean, msg: => Any)Object` +[accessible: true] `method eq(x$1: AnyRef)Boolean` +[accessible: true] `method equals(x$1: Any)Boolean` +[accessible: true] `method formatted(fmtstr: String)String` +[accessible: true] `method hashCode()Int` +[accessible: true] `method isInstanceOf[T0]=> Boolean` +[accessible: true] `method ne(x$1: AnyRef)Boolean` +[accessible: true] `method notify()Unit` +[accessible: true] `method notifyAll()Unit` +[accessible: true] `method synchronized[T0](x$1: T0)T0` +[accessible: true] `method toString()String` +[accessible: true] `method wait()Unit` +[accessible: true] `method wait(x$1: Long)Unit` +[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` +[accessible: true] `method x=> Object` +[accessible: true] `method →[B](y: B)(Object, B)` +[accessible: true] `value __leftOfArrowObject` +[accessible: true] `value __resultOfEnsuringObject` +[accessible: true] `value selfAny` +[accessible: false] `method clone()Object` +[accessible: false] `method finalize()Unit` ================================================================================ diff --git a/test/files/presentation/ide-bug-1000531.check b/test/files/presentation/ide-bug-1000531.check index ae202001eb..dcbd440801 100644 --- a/test/files/presentation/ide-bug-1000531.check +++ b/test/files/presentation/ide-bug-1000531.check @@ -3,124 +3,125 @@ reload: CrashOnLoad.scala askTypeCompletion at CrashOnLoad.scala(6,12) ================================================================================ [response] aksTypeCompletion at (6,12) -retrieved 123 members -`class GroupedIteratorIterator[B]#GroupedIterator` -`method !=(x$1: Any)Boolean` -`method !=(x$1: AnyRef)Boolean` -`method ##()Int` -`method +(other: String)String` -`method ++[B >: B](that: => scala.collection.GenTraversableOnce[B])Iterator[B]` -`method ->[B](y: B)(java.util.Iterator[B], B)` -`method /:[B](z: B)(op: (B, B) => B)B` -`method /:\[A1 >: B](z: A1)(op: (A1, A1) => A1)A1` -`method :\[B](z: B)(op: (B, B) => B)B` -`method ==(x$1: Any)Boolean` -`method ==(x$1: AnyRef)Boolean` -`method addString(b: StringBuilder)StringBuilder` -`method addString(b: StringBuilder, sep: String)StringBuilder` -`method addString(b: StringBuilder, start: String, sep: String, end: String)StringBuilder` -`method aggregate[B](z: B)(seqop: (B, B) => B, combop: (B, B) => B)B` -`method asInstanceOf[T0]=> T0` -`method buffered=> scala.collection.BufferedIterator[B]` -`method clone()Object` -`method collectFirst[B](pf: PartialFunction[B,B])Option[B]` -`method collect[B](pf: PartialFunction[B,B])Iterator[B]` -`method contains(elem: Any)Boolean` -`method copyToArray[B >: B](xs: Array[B])Unit` -`method copyToArray[B >: B](xs: Array[B], start: Int)Unit` -`method copyToArray[B >: B](xs: Array[B], start: Int, len: Int)Unit` -`method copyToBuffer[B >: B](dest: scala.collection.mutable.Buffer[B])Unit` -`method count(p: B => Boolean)Int` -`method drop(n: Int)Iterator[B]` -`method dropWhile(p: B => Boolean)Iterator[B]` -`method duplicate=> (Iterator[B], Iterator[B])` -`method ensuring(cond: Boolean)java.util.Iterator[B]` -`method ensuring(cond: Boolean, msg: => Any)java.util.Iterator[B]` -`method ensuring(cond: java.util.Iterator[B] => Boolean)java.util.Iterator[B]` -`method ensuring(cond: java.util.Iterator[B] => Boolean, msg: => Any)java.util.Iterator[B]` -`method eq(x$1: AnyRef)Boolean` -`method equals(x$1: Any)Boolean` -`method exists(p: B => Boolean)Boolean` -`method filter(p: B => Boolean)Iterator[B]` -`method filterNot(p: B => Boolean)Iterator[B]` -`method finalize()Unit` -`method find(p: B => Boolean)Option[B]` -`method flatMap[B](f: B => scala.collection.GenTraversableOnce[B])Iterator[B]` -`method foldLeft[B](z: B)(op: (B, B) => B)B` -`method foldRight[B](z: B)(op: (B, B) => B)B` -`method fold[A1 >: B](z: A1)(op: (A1, A1) => A1)A1` -`method forall(p: B => Boolean)Boolean` -`method foreach[U](f: B => U)Unit` -`method formatted(fmtstr: String)String` -`method grouped[B >: B](size: Int)Iterator[B]#GroupedIterator[B]` -`method hasDefiniteSize=> Boolean` -`method hasNext()Boolean` -`method hashCode()Int` -`method indexOf[B >: B](elem: B)Int` -`method indexWhere(p: B => Boolean)Int` -`method isEmpty=> Boolean` -`method isInstanceOf[T0]=> Boolean` -`method isTraversableAgain=> Boolean` -`method length=> Int` -`method map[B](f: B => B)Iterator[B]` -`method maxBy[B](f: B => B)(implicit cmp: Ordering[B])B` -`method max[B >: B](implicit cmp: Ordering[B])B` -`method minBy[B](f: B => B)(implicit cmp: Ordering[B])B` -`method min[B >: B](implicit cmp: Ordering[B])B` -`method mkString(sep: String)String` -`method mkString(start: String, sep: String, end: String)String` -`method mkString=> String` -`method ne(x$1: AnyRef)Boolean` -`method next()B` -`method nonEmpty=> Boolean` -`method notify()Unit` -`method notifyAll()Unit` -`method padTo[A1 >: B](len: Int, elem: A1)Iterator[A1]` -`method partition(p: B => Boolean)(Iterator[B], Iterator[B])` -`method patch[B >: B](from: Int, patchElems: Iterator[B], replaced: Int)Iterator[B]` -`method product[B >: B](implicit num: Numeric[B])B` -`method reduceLeftOption[B >: B](op: (B, B) => B)Option[B]` -`method reduceLeft[B >: B](op: (B, B) => B)B` -`method reduceOption[A1 >: B](op: (A1, A1) => A1)Option[A1]` -`method reduceRightOption[B >: B](op: (B, B) => B)Option[B]` -`method reduceRight[B >: B](op: (B, B) => B)B` -`method reduce[A1 >: B](op: (A1, A1) => A1)A1` -`method remove()Unit` -`method reversed=> List[B]` -`method sameElements(that: Iterator[_])Boolean` -`method scanLeft[B](z: B)(op: (B, B) => B)Iterator[B]` -`method scanRight[B](z: B)(op: (B, B) => B)Iterator[B]` -`method seq=> Iterator[B]` -`method size=> Int` -`method slice(from: Int, until: Int)Iterator[B]` -`method sliding[B >: B](size: Int, step: Int)Iterator[B]#GroupedIterator[B]` -`method span(p: B => Boolean)(Iterator[B], Iterator[B])` -`method sum[B >: B](implicit num: Numeric[B])B` -`method synchronized[T0](x$1: T0)T0` -`method take(n: Int)Iterator[B]` -`method takeWhile(p: B => Boolean)Iterator[B]` -`method toArray[B >: B](implicit evidence$1: ClassManifest[B])Array[B]` -`method toBuffer[B >: B]=> scala.collection.mutable.Buffer[B]` -`method toIndexedSeq=> scala.collection.immutable.IndexedSeq[B]` -`method toIterable=> Iterable[B]` -`method toIterator=> Iterator[B]` -`method toList=> List[B]` -`method toMap[T, U](implicit ev: <:<[B,(T, U)])scala.collection.immutable.Map[T,U]` -`method toSeq=> Seq[B]` -`method toSet[B >: B]=> scala.collection.immutable.Set[B]` -`method toStream=> scala.collection.immutable.Stream[B]` -`method toString()String` -`method toTraversable=> Traversable[B]` -`method wait()Unit` -`method wait(x$1: Long)Unit` -`method wait(x$1: Long, x$2: Int)Unit` -`method withFilter(p: B => Boolean)Iterator[B]` -`method x=> java.util.Iterator[B]` -`method zipAll[B, A1 >: B, B1 >: B](that: Iterator[B], thisElem: A1, thatElem: B1)Iterator[(A1, B1)]` -`method zipWithIndex=> Iterator[(B, Int)]` -`method zip[B](that: Iterator[B])Iterator[(B, B)]` -`method →[B](y: B)(java.util.Iterator[B], B)` -`value __leftOfArrowjava.util.Iterator[B]` -`value __resultOfEnsuringjava.util.Iterator[B]` -`value selfAny` +retrieved 124 members +[accessible: true] `class GroupedIteratorIterator[B]#GroupedIterator` +[accessible: true] `method !=(x$1: Any)Boolean` +[accessible: true] `method !=(x$1: AnyRef)Boolean` +[accessible: true] `method ##()Int` +[accessible: true] `method +(other: String)String` +[accessible: true] `method ++[B >: B](that: => scala.collection.GenTraversableOnce[B])Iterator[B]` +[accessible: true] `method ->[B](y: B)(java.util.Iterator[B], B)` +[accessible: true] `method /:[B](z: B)(op: (B, B) => B)B` +[accessible: true] `method /:\[A1 >: B](z: A1)(op: (A1, A1) => A1)A1` +[accessible: true] `method :\[B](z: B)(op: (B, B) => B)B` +[accessible: true] `method ==(x$1: Any)Boolean` +[accessible: true] `method ==(x$1: AnyRef)Boolean` +[accessible: true] `method addString(b: StringBuilder)StringBuilder` +[accessible: true] `method addString(b: StringBuilder, sep: String)StringBuilder` +[accessible: true] `method addString(b: StringBuilder, start: String, sep: String, end: String)StringBuilder` +[accessible: true] `method aggregate[B](z: B)(seqop: (B, B) => B, combop: (B, B) => B)B` +[accessible: true] `method asInstanceOf[T0]=> T0` +[accessible: true] `method buffered=> scala.collection.BufferedIterator[B]` +[accessible: true] `method collectFirst[B](pf: PartialFunction[B,B])Option[B]` +[accessible: true] `method collect[B](pf: PartialFunction[B,B])Iterator[B]` +[accessible: true] `method contains(elem: Any)Boolean` +[accessible: true] `method copyToArray[B >: B](xs: Array[B])Unit` +[accessible: true] `method copyToArray[B >: B](xs: Array[B], start: Int)Unit` +[accessible: true] `method copyToArray[B >: B](xs: Array[B], start: Int, len: Int)Unit` +[accessible: true] `method copyToBuffer[B >: B](dest: scala.collection.mutable.Buffer[B])Unit` +[accessible: true] `method corresponds[B](that: scala.collection.GenTraversableOnce[B])(p: (B, B) => Boolean)Boolean` +[accessible: true] `method count(p: B => Boolean)Int` +[accessible: true] `method drop(n: Int)Iterator[B]` +[accessible: true] `method dropWhile(p: B => Boolean)Iterator[B]` +[accessible: true] `method duplicate=> (Iterator[B], Iterator[B])` +[accessible: true] `method ensuring(cond: Boolean)java.util.Iterator[B]` +[accessible: true] `method ensuring(cond: Boolean, msg: => Any)java.util.Iterator[B]` +[accessible: true] `method ensuring(cond: java.util.Iterator[B] => Boolean)java.util.Iterator[B]` +[accessible: true] `method ensuring(cond: java.util.Iterator[B] => Boolean, msg: => Any)java.util.Iterator[B]` +[accessible: true] `method eq(x$1: AnyRef)Boolean` +[accessible: true] `method equals(x$1: Any)Boolean` +[accessible: true] `method exists(p: B => Boolean)Boolean` +[accessible: true] `method filter(p: B => Boolean)Iterator[B]` +[accessible: true] `method filterNot(p: B => Boolean)Iterator[B]` +[accessible: true] `method find(p: B => Boolean)Option[B]` +[accessible: true] `method flatMap[B](f: B => scala.collection.GenTraversableOnce[B])Iterator[B]` +[accessible: true] `method foldLeft[B](z: B)(op: (B, B) => B)B` +[accessible: true] `method foldRight[B](z: B)(op: (B, B) => B)B` +[accessible: true] `method fold[A1 >: B](z: A1)(op: (A1, A1) => A1)A1` +[accessible: true] `method forall(p: B => Boolean)Boolean` +[accessible: true] `method foreach[U](f: B => U)Unit` +[accessible: true] `method formatted(fmtstr: String)String` +[accessible: true] `method grouped[B >: B](size: Int)Iterator[B]#GroupedIterator[B]` +[accessible: true] `method hasDefiniteSize=> Boolean` +[accessible: true] `method hasNext()Boolean` +[accessible: true] `method hashCode()Int` +[accessible: true] `method indexOf[B >: B](elem: B)Int` +[accessible: true] `method indexWhere(p: B => Boolean)Int` +[accessible: true] `method isEmpty=> Boolean` +[accessible: true] `method isInstanceOf[T0]=> Boolean` +[accessible: true] `method isTraversableAgain=> Boolean` +[accessible: true] `method length=> Int` +[accessible: true] `method map[B](f: B => B)Iterator[B]` +[accessible: true] `method maxBy[B](f: B => B)(implicit cmp: Ordering[B])B` +[accessible: true] `method max[B >: B](implicit cmp: Ordering[B])B` +[accessible: true] `method minBy[B](f: B => B)(implicit cmp: Ordering[B])B` +[accessible: true] `method min[B >: B](implicit cmp: Ordering[B])B` +[accessible: true] `method mkString(sep: String)String` +[accessible: true] `method mkString(start: String, sep: String, end: String)String` +[accessible: true] `method mkString=> String` +[accessible: true] `method ne(x$1: AnyRef)Boolean` +[accessible: true] `method next()B` +[accessible: true] `method nonEmpty=> Boolean` +[accessible: true] `method notify()Unit` +[accessible: true] `method notifyAll()Unit` +[accessible: true] `method padTo[A1 >: B](len: Int, elem: A1)Iterator[A1]` +[accessible: true] `method partition(p: B => Boolean)(Iterator[B], Iterator[B])` +[accessible: true] `method patch[B >: B](from: Int, patchElems: Iterator[B], replaced: Int)Iterator[B]` +[accessible: true] `method product[B >: B](implicit num: Numeric[B])B` +[accessible: true] `method reduceLeftOption[B >: B](op: (B, B) => B)Option[B]` +[accessible: true] `method reduceLeft[B >: B](op: (B, B) => B)B` +[accessible: true] `method reduceOption[A1 >: B](op: (A1, A1) => A1)Option[A1]` +[accessible: true] `method reduceRightOption[B >: B](op: (B, B) => B)Option[B]` +[accessible: true] `method reduceRight[B >: B](op: (B, B) => B)B` +[accessible: true] `method reduce[A1 >: B](op: (A1, A1) => A1)A1` +[accessible: true] `method remove()Unit` +[accessible: true] `method sameElements(that: Iterator[_])Boolean` +[accessible: true] `method scanLeft[B](z: B)(op: (B, B) => B)Iterator[B]` +[accessible: true] `method scanRight[B](z: B)(op: (B, B) => B)Iterator[B]` +[accessible: true] `method seq=> Iterator[B]` +[accessible: true] `method size=> Int` +[accessible: true] `method slice(from: Int, until: Int)Iterator[B]` +[accessible: true] `method sliding[B >: B](size: Int, step: Int)Iterator[B]#GroupedIterator[B]` +[accessible: true] `method span(p: B => Boolean)(Iterator[B], Iterator[B])` +[accessible: true] `method sum[B >: B](implicit num: Numeric[B])B` +[accessible: true] `method synchronized[T0](x$1: T0)T0` +[accessible: true] `method take(n: Int)Iterator[B]` +[accessible: true] `method takeWhile(p: B => Boolean)Iterator[B]` +[accessible: true] `method toArray[B >: B](implicit evidence$1: ArrayTag[B])Array[B]` +[accessible: true] `method toBuffer[B >: B]=> scala.collection.mutable.Buffer[B]` +[accessible: true] `method toIndexedSeq=> scala.collection.immutable.IndexedSeq[B]` +[accessible: true] `method toIterable=> Iterable[B]` +[accessible: true] `method toIterator=> Iterator[B]` +[accessible: true] `method toList=> List[B]` +[accessible: true] `method toMap[T, U](implicit ev: <:<[B,(T, U)])scala.collection.immutable.Map[T,U]` +[accessible: true] `method toSeq=> Seq[B]` +[accessible: true] `method toSet[B >: B]=> scala.collection.immutable.Set[B]` +[accessible: true] `method toStream=> scala.collection.immutable.Stream[B]` +[accessible: true] `method toString()String` +[accessible: true] `method toTraversable=> Traversable[B]` +[accessible: true] `method wait()Unit` +[accessible: true] `method wait(x$1: Long)Unit` +[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` +[accessible: true] `method withFilter(p: B => Boolean)Iterator[B]` +[accessible: true] `method x=> java.util.Iterator[B]` +[accessible: true] `method zipAll[B, A1 >: B, B1 >: B](that: Iterator[B], thisElem: A1, thatElem: B1)Iterator[(A1, B1)]` +[accessible: true] `method zipWithIndex=> Iterator[(B, Int)]` +[accessible: true] `method zip[B](that: Iterator[B])Iterator[(B, B)]` +[accessible: true] `method →[B](y: B)(java.util.Iterator[B], B)` +[accessible: true] `value __leftOfArrowjava.util.Iterator[B]` +[accessible: true] `value __resultOfEnsuringjava.util.Iterator[B]` +[accessible: true] `value selfAny` +[accessible: false] `method clone()Object` +[accessible: false] `method finalize()Unit` +[accessible: false] `method reversed=> List[B]` ================================================================================ diff --git a/test/files/presentation/implicit-member.check b/test/files/presentation/implicit-member.check index e8e656f12a..05d6f61699 100644 --- a/test/files/presentation/implicit-member.check +++ b/test/files/presentation/implicit-member.check @@ -4,39 +4,39 @@ askTypeCompletion at ImplicitMember.scala(7,7) ================================================================================ [response] aksTypeCompletion at (7,7) retrieved 39 members -`class AppliedImplicitImplicit.AppliedImplicit` -`method !=(x$1: Any)Boolean` -`method !=(x$1: AnyRef)Boolean` -`method ##()Int` -`method +(other: String)String` -`method ->[B](y: B)(Implicit.type, B)` -`method ==(x$1: Any)Boolean` -`method ==(x$1: AnyRef)Boolean` -`method AppliedImplicit[A](x: A)Implicit.AppliedImplicit[A]` -`method asInstanceOf[T0]=> T0` -`method clone()Object` -`method ensuring(cond: Boolean)Implicit.type` -`method ensuring(cond: Boolean, msg: => Any)Implicit.type` -`method ensuring(cond: Implicit.type => Boolean)Implicit.type` -`method ensuring(cond: Implicit.type => Boolean, msg: => Any)Implicit.type` -`method eq(x$1: AnyRef)Boolean` -`method equals(x$1: Any)Boolean` -`method finalize()Unit` -`method formatted(fmtstr: String)String` -`method hashCode()Int` -`method isInstanceOf[T0]=> Boolean` -`method ne(x$1: AnyRef)Boolean` -`method notify()Unit` -`method notifyAll()Unit` -`method synchronized[T0](x$1: T0)T0` -`method toString()String` -`method wait()Unit` -`method wait(x$1: Long)Unit` -`method wait(x$1: Long, x$2: Int)Unit` -`method x=> Implicit.type` -`method →[B](y: B)(Implicit.type, B)` -`value __leftOfArrowImplicit.type` -`value __resultOfEnsuringImplicit.type` -`value selfAny` -`value xImplicit.type` +[accessible: true] `class AppliedImplicitImplicit.AppliedImplicit` +[accessible: true] `method !=(x$1: Any)Boolean` +[accessible: true] `method !=(x$1: AnyRef)Boolean` +[accessible: true] `method ##()Int` +[accessible: true] `method +(other: String)String` +[accessible: true] `method ->[B](y: B)(Implicit.type, B)` +[accessible: true] `method ==(x$1: Any)Boolean` +[accessible: true] `method ==(x$1: AnyRef)Boolean` +[accessible: true] `method AppliedImplicit[A](x: A)Implicit.AppliedImplicit[A]` +[accessible: true] `method asInstanceOf[T0]=> T0` +[accessible: true] `method clone()Object` +[accessible: true] `method ensuring(cond: Boolean)Implicit.type` +[accessible: true] `method ensuring(cond: Boolean, msg: => Any)Implicit.type` +[accessible: true] `method ensuring(cond: Implicit.type => Boolean)Implicit.type` +[accessible: true] `method ensuring(cond: Implicit.type => Boolean, msg: => Any)Implicit.type` +[accessible: true] `method eq(x$1: AnyRef)Boolean` +[accessible: true] `method equals(x$1: Any)Boolean` +[accessible: true] `method finalize()Unit` +[accessible: true] `method formatted(fmtstr: String)String` +[accessible: true] `method hashCode()Int` +[accessible: true] `method isInstanceOf[T0]=> Boolean` +[accessible: true] `method ne(x$1: AnyRef)Boolean` +[accessible: true] `method notify()Unit` +[accessible: true] `method notifyAll()Unit` +[accessible: true] `method synchronized[T0](x$1: T0)T0` +[accessible: true] `method toString()String` +[accessible: true] `method wait()Unit` +[accessible: true] `method wait(x$1: Long)Unit` +[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` +[accessible: true] `method x=> Implicit.type` +[accessible: true] `method →[B](y: B)(Implicit.type, B)` +[accessible: true] `value __leftOfArrowImplicit.type` +[accessible: true] `value __resultOfEnsuringImplicit.type` +[accessible: true] `value selfAny` +[accessible: true] `value xImplicit.type` ================================================================================ diff --git a/test/files/presentation/ping-pong.check b/test/files/presentation/ping-pong.check index 38040bdacf..b666d51de5 100644 --- a/test/files/presentation/ping-pong.check +++ b/test/files/presentation/ping-pong.check @@ -4,83 +4,83 @@ askTypeCompletion at PingPong.scala(10,23) ================================================================================ [response] aksTypeCompletion at (10,23) retrieved 40 members -`method !=(x$1: Any)Boolean` -`method !=(x$1: AnyRef)Boolean` -`method ##()Int` -`method +(other: String)String` -`method ->[B](y: B)(Pong, B)` -`method ==(x$1: Any)Boolean` -`method ==(x$1: AnyRef)Boolean` -`method asInstanceOf[T0]=> T0` -`method clone()Object` -`method ensuring(cond: Boolean)Pong` -`method ensuring(cond: Boolean, msg: => Any)Pong` -`method ensuring(cond: Pong => Boolean)Pong` -`method ensuring(cond: Pong => Boolean, msg: => Any)Pong` -`method eq(x$1: AnyRef)Boolean` -`method equals(x$1: Any)Boolean` -`method finalize()Unit` -`method formatted(fmtstr: String)String` -`method hashCode()Int` -`method isInstanceOf[T0]=> Boolean` -`method ne(x$1: AnyRef)Boolean` -`method notify()Unit` -`method notifyAll()Unit` -`method poke()Unit` -`method synchronized[T0](x$1: T0)T0` -`method toString()String` -`method wait()Unit` -`method wait(x$1: Long)Unit` -`method wait(x$1: Long, x$2: Int)Unit` -`method x=> Pong` -`method →[B](y: B)(Pong, B)` -`value __leftOfArrowPong` -`value __resultOfEnsuringPong` -`value nameString` -`value pingPing` -`value selfAny` +[accessible: true] `method !=(x$1: Any)Boolean` +[accessible: true] `method !=(x$1: AnyRef)Boolean` +[accessible: true] `method ##()Int` +[accessible: true] `method +(other: String)String` +[accessible: true] `method ->[B](y: B)(Pong, B)` +[accessible: true] `method ==(x$1: Any)Boolean` +[accessible: true] `method ==(x$1: AnyRef)Boolean` +[accessible: true] `method asInstanceOf[T0]=> T0` +[accessible: true] `method ensuring(cond: Boolean)Pong` +[accessible: true] `method ensuring(cond: Boolean, msg: => Any)Pong` +[accessible: true] `method ensuring(cond: Pong => Boolean)Pong` +[accessible: true] `method ensuring(cond: Pong => Boolean, msg: => Any)Pong` +[accessible: true] `method eq(x$1: AnyRef)Boolean` +[accessible: true] `method equals(x$1: Any)Boolean` +[accessible: true] `method formatted(fmtstr: String)String` +[accessible: true] `method hashCode()Int` +[accessible: true] `method isInstanceOf[T0]=> Boolean` +[accessible: true] `method ne(x$1: AnyRef)Boolean` +[accessible: true] `method notify()Unit` +[accessible: true] `method notifyAll()Unit` +[accessible: true] `method poke()Unit` +[accessible: true] `method synchronized[T0](x$1: T0)T0` +[accessible: true] `method toString()String` +[accessible: true] `method wait()Unit` +[accessible: true] `method wait(x$1: Long)Unit` +[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` +[accessible: true] `method x=> Pong` +[accessible: true] `method →[B](y: B)(Pong, B)` +[accessible: true] `value __leftOfArrowPong` +[accessible: true] `value __resultOfEnsuringPong` +[accessible: true] `value nameString` +[accessible: true] `value selfAny` +[accessible: false] `method clone()Object` +[accessible: false] `method finalize()Unit` +[accessible: false] `value pingPing` ================================================================================ askTypeCompletion at PingPong.scala(19,20) ================================================================================ [response] aksTypeCompletion at (19,20) retrieved 40 members -`method !=(x$1: Any)Boolean` -`method !=(x$1: AnyRef)Boolean` -`method ##()Int` -`method +(other: String)String` -`method ->[B](y: B)(Ping, B)` -`method ==(x$1: Any)Boolean` -`method ==(x$1: AnyRef)Boolean` -`method asInstanceOf[T0]=> T0` -`method clone()Object` -`method ensuring(cond: Boolean)Ping` -`method ensuring(cond: Boolean, msg: => Any)Ping` -`method ensuring(cond: Ping => Boolean)Ping` -`method ensuring(cond: Ping => Boolean, msg: => Any)Ping` -`method eq(x$1: AnyRef)Boolean` -`method equals(x$1: Any)Boolean` -`method finalize()Unit` -`method formatted(fmtstr: String)String` -`method hashCode()Int` -`method isInstanceOf[T0]=> Boolean` -`method loop=> Unit` -`method name=> String` -`method ne(x$1: AnyRef)Boolean` -`method notify()Unit` -`method notifyAll()Unit` -`method poke=> Unit` -`method synchronized[T0](x$1: T0)T0` -`method toString()String` -`method wait()Unit` -`method wait(x$1: Long)Unit` -`method wait(x$1: Long, x$2: Int)Unit` -`method x=> Ping` -`method →[B](y: B)(Ping, B)` -`value __leftOfArrowPing` -`value __resultOfEnsuringPing` -`value pongPong` -`value selfAny` +[accessible: true] `method !=(x$1: Any)Boolean` +[accessible: true] `method !=(x$1: AnyRef)Boolean` +[accessible: true] `method ##()Int` +[accessible: true] `method +(other: String)String` +[accessible: true] `method ->[B](y: B)(Ping, B)` +[accessible: true] `method ==(x$1: Any)Boolean` +[accessible: true] `method ==(x$1: AnyRef)Boolean` +[accessible: true] `method asInstanceOf[T0]=> T0` +[accessible: true] `method ensuring(cond: Boolean)Ping` +[accessible: true] `method ensuring(cond: Boolean, msg: => Any)Ping` +[accessible: true] `method ensuring(cond: Ping => Boolean)Ping` +[accessible: true] `method ensuring(cond: Ping => Boolean, msg: => Any)Ping` +[accessible: true] `method eq(x$1: AnyRef)Boolean` +[accessible: true] `method equals(x$1: Any)Boolean` +[accessible: true] `method formatted(fmtstr: String)String` +[accessible: true] `method hashCode()Int` +[accessible: true] `method isInstanceOf[T0]=> Boolean` +[accessible: true] `method loop=> Unit` +[accessible: true] `method name=> String` +[accessible: true] `method ne(x$1: AnyRef)Boolean` +[accessible: true] `method notify()Unit` +[accessible: true] `method notifyAll()Unit` +[accessible: true] `method poke=> Unit` +[accessible: true] `method synchronized[T0](x$1: T0)T0` +[accessible: true] `method toString()String` +[accessible: true] `method wait()Unit` +[accessible: true] `method wait(x$1: Long)Unit` +[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` +[accessible: true] `method x=> Ping` +[accessible: true] `method →[B](y: B)(Ping, B)` +[accessible: true] `value __leftOfArrowPing` +[accessible: true] `value __resultOfEnsuringPing` +[accessible: true] `value pongPong` +[accessible: true] `value selfAny` +[accessible: false] `method clone()Object` +[accessible: false] `method finalize()Unit` ================================================================================ askType at PingPong.scala(8,10) diff --git a/test/files/presentation/t5708.check b/test/files/presentation/t5708.check new file mode 100644 index 0000000000..c6d4762635 --- /dev/null +++ b/test/files/presentation/t5708.check @@ -0,0 +1,47 @@ +reload: Completions.scala + +askTypeCompletion at Completions.scala(17,9) +================================================================================ +[response] aksTypeCompletion at (17,9) +retrieved 44 members +[accessible: true] `lazy value fooInt` +[accessible: true] `method !=(x$1: Any)Boolean` +[accessible: true] `method !=(x$1: AnyRef)Boolean` +[accessible: true] `method ##()Int` +[accessible: true] `method +(other: String)String` +[accessible: true] `method ->[B](y: B)(test.Compat.type, B)` +[accessible: true] `method ==(x$1: Any)Boolean` +[accessible: true] `method ==(x$1: AnyRef)Boolean` +[accessible: true] `method asInstanceOf[T0]=> T0` +[accessible: true] `method ensuring(cond: Boolean)test.Compat.type` +[accessible: true] `method ensuring(cond: Boolean, msg: => Any)test.Compat.type` +[accessible: true] `method ensuring(cond: test.Compat.type => Boolean)test.Compat.type` +[accessible: true] `method ensuring(cond: test.Compat.type => Boolean, msg: => Any)test.Compat.type` +[accessible: true] `method eq(x$1: AnyRef)Boolean` +[accessible: true] `method equals(x$1: Any)Boolean` +[accessible: true] `method formatted(fmtstr: String)String` +[accessible: true] `method hashCode()Int` +[accessible: true] `method isInstanceOf[T0]=> Boolean` +[accessible: true] `method ne(x$1: AnyRef)Boolean` +[accessible: true] `method notify()Unit` +[accessible: true] `method notifyAll()Unit` +[accessible: true] `method pkgPrivateM=> String` +[accessible: true] `method synchronized[T0](x$1: T0)T0` +[accessible: true] `method toString()String` +[accessible: true] `method wait()Unit` +[accessible: true] `method wait(x$1: Long)Unit` +[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` +[accessible: true] `method x=> test.Compat.type` +[accessible: true] `method →[B](y: B)(test.Compat.type, B)` +[accessible: true] `value CONST_STRINGString("constant")` +[accessible: true] `value __leftOfArrowtest.Compat.type` +[accessible: true] `value __resultOfEnsuringtest.Compat.type` +[accessible: true] `value pkgPrivateVString` +[accessible: true] `value selfAny` +[accessible: false] `method clone()Object` +[accessible: false] `method finalize()Unit` +[accessible: false] `method privateM=> String` +[accessible: false] `method protectedValM=> String` +[accessible: false] `value privateVString` +[accessible: false] `value protectedVString` +================================================================================ diff --git a/test/files/presentation/t5708/Test.scala b/test/files/presentation/t5708/Test.scala new file mode 100644 index 0000000000..96e758d974 --- /dev/null +++ b/test/files/presentation/t5708/Test.scala @@ -0,0 +1,5 @@ +import scala.tools.nsc.interactive.tests.InteractiveTest + +object Test extends InteractiveTest { + +}
\ No newline at end of file diff --git a/test/files/presentation/t5708/src/Completions.scala b/test/files/presentation/t5708/src/Completions.scala new file mode 100644 index 0000000000..1e9e5d5eb1 --- /dev/null +++ b/test/files/presentation/t5708/src/Completions.scala @@ -0,0 +1,18 @@ +package test + +object Compat { + final val CONST_STRING = "constant" + lazy val foo = 4 + + private val privateV = "" + private[test] val pkgPrivateV = "" + protected val protectedV = "" + + private def privateM = "" + private[test] def pkgPrivateM = "" + protected def protectedValM = "" +} + +class Foo { + Compat./*!*/CONST_STRING // its 'accessible' flag is false +} diff --git a/test/files/presentation/visibility.check b/test/files/presentation/visibility.check new file mode 100644 index 0000000000..3026e58f7e --- /dev/null +++ b/test/files/presentation/visibility.check @@ -0,0 +1,221 @@ +reload: Completions.scala + +askTypeCompletion at Completions.scala(14,12) +================================================================================ +[response] aksTypeCompletion at (14,12) +retrieved 42 members +[accessible: true] `method !=(x$1: Any)Boolean` +[accessible: true] `method !=(x$1: AnyRef)Boolean` +[accessible: true] `method ##()Int` +[accessible: true] `method +(other: String)String` +[accessible: true] `method ->[B](y: B)(accessibility.Foo, B)` +[accessible: true] `method ==(x$1: Any)Boolean` +[accessible: true] `method ==(x$1: AnyRef)Boolean` +[accessible: true] `method asInstanceOf[T0]=> T0` +[accessible: true] `method clone()Object` +[accessible: true] `method ensuring(cond: Boolean)accessibility.Foo` +[accessible: true] `method ensuring(cond: Boolean, msg: => Any)accessibility.Foo` +[accessible: true] `method ensuring(cond: accessibility.Foo => Boolean)accessibility.Foo` +[accessible: true] `method ensuring(cond: accessibility.Foo => Boolean, msg: => Any)accessibility.Foo` +[accessible: true] `method eq(x$1: AnyRef)Boolean` +[accessible: true] `method equals(x$1: Any)Boolean` +[accessible: true] `method finalize()Unit` +[accessible: true] `method formatted(fmtstr: String)String` +[accessible: true] `method hashCode()Int` +[accessible: true] `method isInstanceOf[T0]=> Boolean` +[accessible: true] `method ne(x$1: AnyRef)Boolean` +[accessible: true] `method notify()Unit` +[accessible: true] `method notifyAll()Unit` +[accessible: true] `method secretPrivate()Unit` +[accessible: true] `method secretProtected()Unit` +[accessible: true] `method secretProtectedInPackage()Unit` +[accessible: true] `method secretPublic()Unit` +[accessible: true] `method someTests(other: accessibility.Foo)Unit` +[accessible: true] `method synchronized[T0](x$1: T0)T0` +[accessible: true] `method toString()String` +[accessible: true] `method wait()Unit` +[accessible: true] `method wait(x$1: Long)Unit` +[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` +[accessible: true] `method x=> accessibility.Foo` +[accessible: true] `method →[B](y: B)(accessibility.Foo, B)` +[accessible: true] `value __leftOfArrowaccessibility.Foo` +[accessible: true] `value __resultOfEnsuringaccessibility.Foo` +[accessible: true] `value selfAny` +[accessible: false] `method secretPrivateThis()Unit` +================================================================================ + +askTypeCompletion at Completions.scala(16,11) +================================================================================ +[response] aksTypeCompletion at (16,11) +retrieved 42 members +[accessible: true] `method !=(x$1: Any)Boolean` +[accessible: true] `method !=(x$1: AnyRef)Boolean` +[accessible: true] `method ##()Int` +[accessible: true] `method +(other: String)String` +[accessible: true] `method ->[B](y: B)(accessibility.Foo, B)` +[accessible: true] `method ==(x$1: Any)Boolean` +[accessible: true] `method ==(x$1: AnyRef)Boolean` +[accessible: true] `method asInstanceOf[T0]=> T0` +[accessible: true] `method clone()Object` +[accessible: true] `method ensuring(cond: Boolean)accessibility.Foo` +[accessible: true] `method ensuring(cond: Boolean, msg: => Any)accessibility.Foo` +[accessible: true] `method ensuring(cond: accessibility.Foo => Boolean)accessibility.Foo` +[accessible: true] `method ensuring(cond: accessibility.Foo => Boolean, msg: => Any)accessibility.Foo` +[accessible: true] `method eq(x$1: AnyRef)Boolean` +[accessible: true] `method equals(x$1: Any)Boolean` +[accessible: true] `method finalize()Unit` +[accessible: true] `method formatted(fmtstr: String)String` +[accessible: true] `method hashCode()Int` +[accessible: true] `method isInstanceOf[T0]=> Boolean` +[accessible: true] `method ne(x$1: AnyRef)Boolean` +[accessible: true] `method notify()Unit` +[accessible: true] `method notifyAll()Unit` +[accessible: true] `method secretPrivate()Unit` +[accessible: true] `method secretPrivateThis()Unit` +[accessible: true] `method secretProtected()Unit` +[accessible: true] `method secretProtectedInPackage()Unit` +[accessible: true] `method secretPublic()Unit` +[accessible: true] `method someTests(other: accessibility.Foo)Unit` +[accessible: true] `method synchronized[T0](x$1: T0)T0` +[accessible: true] `method toString()String` +[accessible: true] `method wait()Unit` +[accessible: true] `method wait(x$1: Long)Unit` +[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` +[accessible: true] `method x=> accessibility.Foo` +[accessible: true] `method →[B](y: B)(accessibility.Foo, B)` +[accessible: true] `value __leftOfArrowaccessibility.Foo` +[accessible: true] `value __resultOfEnsuringaccessibility.Foo` +[accessible: true] `value selfAny` +================================================================================ + +askTypeCompletion at Completions.scala(22,11) +================================================================================ +[response] aksTypeCompletion at (22,11) +retrieved 42 members +[accessible: true] `method !=(x$1: Any)Boolean` +[accessible: true] `method !=(x$1: AnyRef)Boolean` +[accessible: true] `method ##()Int` +[accessible: true] `method +(other: String)String` +[accessible: true] `method ->[B](y: B)(accessibility.AccessibilityChecks, B)` +[accessible: true] `method ==(x$1: Any)Boolean` +[accessible: true] `method ==(x$1: AnyRef)Boolean` +[accessible: true] `method asInstanceOf[T0]=> T0` +[accessible: true] `method clone()Object` +[accessible: true] `method ensuring(cond: Boolean)accessibility.AccessibilityChecks` +[accessible: true] `method ensuring(cond: Boolean, msg: => Any)accessibility.AccessibilityChecks` +[accessible: true] `method ensuring(cond: accessibility.AccessibilityChecks => Boolean)accessibility.AccessibilityChecks` +[accessible: true] `method ensuring(cond: accessibility.AccessibilityChecks => Boolean, msg: => Any)accessibility.AccessibilityChecks` +[accessible: true] `method eq(x$1: AnyRef)Boolean` +[accessible: true] `method equals(x$1: Any)Boolean` +[accessible: true] `method finalize()Unit` +[accessible: true] `method formatted(fmtstr: String)String` +[accessible: true] `method hashCode()Int` +[accessible: true] `method isInstanceOf[T0]=> Boolean` +[accessible: true] `method ne(x$1: AnyRef)Boolean` +[accessible: true] `method notify()Unit` +[accessible: true] `method notifyAll()Unit` +[accessible: true] `method secretProtected()Unit` +[accessible: true] `method secretProtectedInPackage()Unit` +[accessible: true] `method secretPublic()Unit` +[accessible: true] `method someTests(other: accessibility.Foo)Unit` +[accessible: true] `method someTests=> Unit` +[accessible: true] `method synchronized[T0](x$1: T0)T0` +[accessible: true] `method toString()String` +[accessible: true] `method wait()Unit` +[accessible: true] `method wait(x$1: Long)Unit` +[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` +[accessible: true] `method x=> accessibility.AccessibilityChecks` +[accessible: true] `method →[B](y: B)(accessibility.AccessibilityChecks, B)` +[accessible: true] `value __leftOfArrowaccessibility.AccessibilityChecks` +[accessible: true] `value __resultOfEnsuringaccessibility.AccessibilityChecks` +[accessible: true] `value selfAny` +[accessible: false] `method secretPrivate()Unit` +================================================================================ + +askTypeCompletion at Completions.scala(28,10) +================================================================================ +[response] aksTypeCompletion at (28,10) +retrieved 42 members +[accessible: true] `method !=(x$1: Any)Boolean` +[accessible: true] `method !=(x$1: AnyRef)Boolean` +[accessible: true] `method ##()Int` +[accessible: true] `method +(other: String)String` +[accessible: true] `method ->[B](y: B)(accessibility.Foo, B)` +[accessible: true] `method ==(x$1: Any)Boolean` +[accessible: true] `method ==(x$1: AnyRef)Boolean` +[accessible: true] `method asInstanceOf[T0]=> T0` +[accessible: true] `method ensuring(cond: Boolean)accessibility.Foo` +[accessible: true] `method ensuring(cond: Boolean, msg: => Any)accessibility.Foo` +[accessible: true] `method ensuring(cond: accessibility.Foo => Boolean)accessibility.Foo` +[accessible: true] `method ensuring(cond: accessibility.Foo => Boolean, msg: => Any)accessibility.Foo` +[accessible: true] `method eq(x$1: AnyRef)Boolean` +[accessible: true] `method equals(x$1: Any)Boolean` +[accessible: true] `method formatted(fmtstr: String)String` +[accessible: true] `method hashCode()Int` +[accessible: true] `method isInstanceOf[T0]=> Boolean` +[accessible: true] `method ne(x$1: AnyRef)Boolean` +[accessible: true] `method notify()Unit` +[accessible: true] `method notifyAll()Unit` +[accessible: true] `method secretProtectedInPackage()Unit` +[accessible: true] `method secretPublic()Unit` +[accessible: true] `method someTests(other: accessibility.Foo)Unit` +[accessible: true] `method synchronized[T0](x$1: T0)T0` +[accessible: true] `method toString()String` +[accessible: true] `method wait()Unit` +[accessible: true] `method wait(x$1: Long)Unit` +[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` +[accessible: true] `method x=> accessibility.Foo` +[accessible: true] `method →[B](y: B)(accessibility.Foo, B)` +[accessible: true] `value __leftOfArrowaccessibility.Foo` +[accessible: true] `value __resultOfEnsuringaccessibility.Foo` +[accessible: true] `value selfAny` +[accessible: false] `method clone()Object` +[accessible: false] `method finalize()Unit` +[accessible: false] `method secretPrivate()Unit` +[accessible: false] `method secretPrivateThis()Unit` +[accessible: false] `method secretProtected()Unit` +================================================================================ + +askTypeCompletion at Completions.scala(37,8) +================================================================================ +[response] aksTypeCompletion at (37,8) +retrieved 42 members +[accessible: true] `method !=(x$1: Any)Boolean` +[accessible: true] `method !=(x$1: AnyRef)Boolean` +[accessible: true] `method ##()Int` +[accessible: true] `method +(other: String)String` +[accessible: true] `method ->[B](y: B)(accessibility.Foo, B)` +[accessible: true] `method ==(x$1: Any)Boolean` +[accessible: true] `method ==(x$1: AnyRef)Boolean` +[accessible: true] `method asInstanceOf[T0]=> T0` +[accessible: true] `method ensuring(cond: Boolean)accessibility.Foo` +[accessible: true] `method ensuring(cond: Boolean, msg: => Any)accessibility.Foo` +[accessible: true] `method ensuring(cond: accessibility.Foo => Boolean)accessibility.Foo` +[accessible: true] `method ensuring(cond: accessibility.Foo => Boolean, msg: => Any)accessibility.Foo` +[accessible: true] `method eq(x$1: AnyRef)Boolean` +[accessible: true] `method equals(x$1: Any)Boolean` +[accessible: true] `method formatted(fmtstr: String)String` +[accessible: true] `method hashCode()Int` +[accessible: true] `method isInstanceOf[T0]=> Boolean` +[accessible: true] `method ne(x$1: AnyRef)Boolean` +[accessible: true] `method notify()Unit` +[accessible: true] `method notifyAll()Unit` +[accessible: true] `method secretPublic()Unit` +[accessible: true] `method someTests(other: accessibility.Foo)Unit` +[accessible: true] `method synchronized[T0](x$1: T0)T0` +[accessible: true] `method toString()String` +[accessible: true] `method wait()Unit` +[accessible: true] `method wait(x$1: Long)Unit` +[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` +[accessible: true] `method x=> accessibility.Foo` +[accessible: true] `method →[B](y: B)(accessibility.Foo, B)` +[accessible: true] `value __leftOfArrowaccessibility.Foo` +[accessible: true] `value __resultOfEnsuringaccessibility.Foo` +[accessible: true] `value selfAny` +[accessible: false] `method clone()Object` +[accessible: false] `method finalize()Unit` +[accessible: false] `method secretPrivate()Unit` +[accessible: false] `method secretPrivateThis()Unit` +[accessible: false] `method secretProtected()Unit` +[accessible: false] `method secretProtectedInPackage()Unit` +================================================================================ diff --git a/test/files/presentation/visibility/Test.scala b/test/files/presentation/visibility/Test.scala new file mode 100644 index 0000000000..96e758d974 --- /dev/null +++ b/test/files/presentation/visibility/Test.scala @@ -0,0 +1,5 @@ +import scala.tools.nsc.interactive.tests.InteractiveTest + +object Test extends InteractiveTest { + +}
\ No newline at end of file diff --git a/test/files/presentation/visibility/src/Completions.scala b/test/files/presentation/visibility/src/Completions.scala new file mode 100644 index 0000000000..098b98a0fd --- /dev/null +++ b/test/files/presentation/visibility/src/Completions.scala @@ -0,0 +1,40 @@ +package accessibility { + + class Foo { + private def secretPrivate(): Unit = () + private[this] def secretPrivateThis(): Unit = () + + protected def secretProtected(): Unit + + protected[accessibility] def secretProtectedInPackage(): Unit + + def secretPublic(): Unit + + def someTests(other: Foo) { + other./*!*/secretPrivate // should be all but scretThis + + this./*!*/secretProtected // should hit five completions + } + } + + class AccessibilityChecks extends Foo { + def someTests { + this./*!*/ // should not list secretPrivate* + } + } + + class UnrelatedClass { + def someTests(foo: Foo) { + foo./*!*/ // should list public and protected[accessiblity] + } + } + +} + +package other { + class SomeChecsk { + def foo(o: accessibility.Foo) { + o./*!*/ // should only match secretPublic + } + } +}
\ No newline at end of file diff --git a/test/files/run/Course-2002-01-msil.check b/test/files/run/Course-2002-01-msil.check deleted file mode 100644 index ca9d7ac54b..0000000000 --- a/test/files/run/Course-2002-01-msil.check +++ /dev/null @@ -1,34 +0,0 @@ -232 -667 -11 -10 -62.8318 -62.8318 -62.8318 -4 -81 -256 -25 -1 -737 -1 -0 -1 -76 -1.41421568627451 -1.73214285714286 -2.00000009292229 -1.41421568627451 -1.73214285714286 -2.00000009292229 -1.41421568627451 -1.73214285714286 -2.00000009292229 -sqrt(2) = 1.41421356237469 -sqrt(2) = 1.41421356237469 -cbrt(2) = 1.25992105001777 -1 -1 1 -1 2 1 -1 3 3 1 -1 4 6 4 1 diff --git a/test/files/run/Course-2002-02-msil.check b/test/files/run/Course-2002-02-msil.check deleted file mode 100644 index 12ac0b1739..0000000000 --- a/test/files/run/Course-2002-02-msil.check +++ /dev/null @@ -1,187 +0,0 @@ -7 -120 - -10 -100 -2.08333333333333 -3025.76877140318 -pi = 3.16597927284322 - -10 -100 -2.08333333333333 -3025.76877140318 -pi = 3.16597927284322 - -10 -100 -2.08333333333333 -3025.76877140318 -pi = 3.16597927284322 - -10 -100 -2.08333333333333 -3025.76877140318 -pi = 3.16597927284322 - -10 -100 -2.08333333333333 -3025.76877140318 -pi = 3.16597927284322 - -10 -100 -2.08333333333333 -3025.76877140318 -pi = 3.16597927284322 - -10 -100 -2.08333333333333 -3025.76877140318 -pi = 3.16597927284322 - -pi = 3.18110488557771 -pi = 3.18110488557771 - -10 -100 -2.08333333333333 -3025.76877140318 -pi = 3.16597927284322 -pi = 3.18110488557771 -pi = 3.18110488557771 - -1.5 -1.41666666666667 -1.41421568627451 -1.41421356237469 -sqrt(2) = 1.41421356237469 - -1.5 -1.41666666666667 -1.41421568627451 -1.41421356237469 -sqrt(2) = 1.41421356237469 - -1 + 2 + .. + 5 = 15 -1 * 2 * .. * 5 = 120 - -1^2 + 2^2 + .. + 5^2 = 55 -1^2 * 2^2 * .. * 5^2 = 14400 - -factorial(0) = 1 -factorial(1) = 1 -factorial(2) = 2 -factorial(3) = 6 -factorial(4) = 24 -factorial(5) = 120 - -1 + 2 + .. + 5 = 15 -1 * 2 * .. * 5 = 120 - -1^2 + 2^2 + .. + 5^2 = 55 -1^2 * 2^2 * .. * 5^2 = 14400 - -factorial(0) = 1 -factorial(1) = 1 -factorial(2) = 2 -factorial(3) = 6 -factorial(4) = 24 -factorial(5) = 120 - -1 + 2 + .. + 5 = 15 -1 * 2 * .. * 5 = 120 - -1^2 + 2^2 + .. + 5^2 = 55 -1^2 * 2^2 * .. * 5^2 = 14400 - -factorial(0) = 1 -factorial(1) = 1 -factorial(2) = 2 -factorial(3) = 6 -factorial(4) = 24 -factorial(5) = 120 - -fib(0) = 0 -fib(1) = 1 -fib(2) = 1 -fib(3) = 2 -fib(4) = 3 -fib(5) = 5 -fib(6) = 8 -fib(7) = 13 -fib(8) = 21 -fib(9) = 34 -fib(0) = 0 -fib(1) = 1 -fib(2) = 1 -fib(3) = 2 -fib(4) = 3 -fib(5) = 5 -fib(6) = 8 -fib(7) = 13 -fib(8) = 21 -fib(9) = 34 -power(0,0) = 1 -power(0,1) = 0 -power(0,2) = 0 -power(0,3) = 0 -power(0,4) = 0 -power(0,5) = 0 -power(0,6) = 0 -power(0,7) = 0 -power(0,8) = 0 - -power(1,0) = 1 -power(1,1) = 1 -power(1,2) = 1 -power(1,3) = 1 -power(1,4) = 1 -power(1,5) = 1 -power(1,6) = 1 -power(1,7) = 1 -power(1,8) = 1 - -power(2,0) = 1 -power(2,1) = 2 -power(2,2) = 4 -power(2,3) = 8 -power(2,4) = 16 -power(2,5) = 32 -power(2,6) = 64 -power(2,7) = 128 -power(2,8) = 256 - -power(3,0) = 1 -power(3,1) = 3 -power(3,2) = 9 -power(3,3) = 27 -power(3,4) = 81 -power(3,5) = 243 -power(3,6) = 729 -power(3,7) = 2187 -power(3,8) = 6561 - -power(4,0) = 1 -power(4,1) = 4 -power(4,2) = 16 -power(4,3) = 64 -power(4,4) = 256 -power(4,5) = 1024 -power(4,6) = 4096 -power(4,7) = 16384 -power(4,8) = 65536 - -power(5,0) = 1 -power(5,1) = 5 -power(5,2) = 25 -power(5,3) = 125 -power(5,4) = 625 -power(5,5) = 3125 -power(5,6) = 15625 -power(5,7) = 78125 -power(5,8) = 390625 - diff --git a/test/files/run/Course-2002-03-msil.check b/test/files/run/Course-2002-03-msil.check deleted file mode 100644 index 3556893e16..0000000000 --- a/test/files/run/Course-2002-03-msil.check +++ /dev/null @@ -1,67 +0,0 @@ -1 -2 -1/2 -5/6 - -1/3 -5/7 -3/2 -66/42 - -1/3 -5/7 -3/2 -11/7 - -11/7 -7/11 -11/7 -11/7 - -13/36 - -False -True -True -False - -set0 = [] -set1 = [1] -set2 = [1,2] -set3 = [1,2,3] -set4 = [1,2,3,4] - -set2 contains the following elements: -1 -2 - -set3 contains the following elements: -1 -2 -3 - -set4 contains the following elements: -1 -2 -3 -4 - -2 <- set2: True -3 <- set2: False - -setx = [-10,-1,0,3,5,21] -setx * 2 = [-20,-2,0,6,10,42] - -setx = [-10,-1,0,3,5,21] -sety = [-9,-5,-1,0,3,7,8] -setx & sety = [-1,0,3] -sety & setx = [-1,0,3] -setx > 0 = [3,5,21] -sety > 0 = [3,7,8] -setx & sety = [-1,0,3] -sety & setx = [-1,0,3] - -1/1 -1/1 -1/1 - diff --git a/test/files/run/Course-2002-04-msil.check b/test/files/run/Course-2002-04-msil.check deleted file mode 100644 index fc6ad96eed..0000000000 --- a/test/files/run/Course-2002-04-msil.check +++ /dev/null @@ -1,64 +0,0 @@ -list0 = List(6, 3, 1, 8, 7, 1, 2, 5, 8, 4, 3, 4, 8) -list1 = List(1, 1, 2, 3, 3, 4, 4, 5, 6, 7, 8, 8, 8) -list2 = List(1, 1, 2, 3, 3, 4, 4, 5, 6, 7, 8, 8, 8) -list3 = List(1, 1, 2, 3, 3, 4, 4, 5, 6, 7, 8, 8, 8) -list4 = List(1, 1, 2, 3, 3, 4, 4, 5, 6, 7, 8, 8, 8) -list5 = List(8, 8, 8, 7, 6, 5, 4, 4, 3, 3, 2, 1, 1) -list6 = List(8, 8, 8, 7, 6, 5, 4, 4, 3, 3, 2, 1, 1) - -list0: List() -> List() -list1: List(0) -> List(0) -list2: List(0, 1) -> List(0, 1) -list3: List(1, 0) -> List(0, 1) -list4: List(0, 1, 2) -> List(0, 1, 2) -list5: List(1, 0, 2) -> List(0, 1, 2) -list6: List(0, 1, 2) -> List(0, 1, 2) -list7: List(1, 0, 2) -> List(0, 1, 2) -list8: List(2, 0, 1) -> List(0, 1, 2) -list9: List(2, 1, 0) -> List(0, 1, 2) -listA: List(6, 3, 1, 8, 7, 1, 2, 5, 8, 4) -> List(1, 1, 2, 3, 4, 5, 6, 7, 8, 8) - -f(x) = 5x^3+7x^2+5x+9 -f(0) = 9 -f(1) = 26 -f(2) = 87 -f(3) = 222 - -v1 = List(2, 3, 4) -v2 = List(6, 7, 8) - -id = List(List(1, 0, 0), List(0, 1, 0), List(0, 0, 1)) -m1 = List(List(2, 0, 0), List(0, 2, 0), List(0, 0, 2)) -m2 = List(List(1, 2, 3), List(4, 5, 6), List(7, 8, 9)) - -v1 * v1 = 29 -v1 * v2 = 65 -v2 * v1 = 65 -v1 * v2 = 65 - -id * v1 = List(2, 3, 4) -m1 * v1 = List(4, 6, 8) -m2 * v1 = List(20, 47, 74) - -trn(id) = List(List(1, 0, 0), List(0, 1, 0), List(0, 0, 1)) -trn(m1) = List(List(2, 0, 0), List(0, 2, 0), List(0, 0, 2)) -trn(m2) = List(List(1, 4, 7), List(2, 5, 8), List(3, 6, 9)) - -List(v1) * id = List(List(2, 3, 4)) -List(v1) * m1 = List(List(4, 6, 8)) -List(v1) * m2 = List(List(42, 51, 60)) - -id * List(v1) = List(List(2, 3, 4), List(0, 0, 0), List(0, 0, 0)) -m1 * List(v1) = List(List(4, 6, 8), List(0, 0, 0), List(0, 0, 0)) -m2 * List(v1) = List(List(2, 3, 4), List(8, 12, 16), List(14, 21, 28)) - -id * id = List(List(1, 0, 0), List(0, 1, 0), List(0, 0, 1)) -id * m1 = List(List(2, 0, 0), List(0, 2, 0), List(0, 0, 2)) -m1 * id = List(List(2, 0, 0), List(0, 2, 0), List(0, 0, 2)) -m1 * m1 = List(List(4, 0, 0), List(0, 4, 0), List(0, 0, 4)) -id * m2 = List(List(1, 2, 3), List(4, 5, 6), List(7, 8, 9)) -m2 * id = List(List(1, 2, 3), List(4, 5, 6), List(7, 8, 9)) -m1 * m2 = List(List(2, 4, 6), List(8, 10, 12), List(14, 16, 18)) -m2 * m1 = List(List(2, 4, 6), List(8, 10, 12), List(14, 16, 18)) -m2 * m2 = List(List(30, 36, 42), List(66, 81, 96), List(102, 126, 150)) - diff --git a/test/files/run/Course-2002-08-msil.check b/test/files/run/Course-2002-08-msil.check deleted file mode 100644 index c5b26c719b..0000000000 --- a/test/files/run/Course-2002-08-msil.check +++ /dev/null @@ -1,171 +0,0 @@ -x = abc -count = 111 -x = hello -count = 112 - -account deposit 50 -> () -account withdraw 20 -> 30 -account withdraw 20 -> 10 -account withdraw 15 -> - -x deposit 30 -> () -y withdraw 20 -> - -x deposit 30 -> () -x withdraw 20 -> 10 - -x deposit 30 -> () -y withdraw 20 -> 10 - -2^0 = 1 -2^1 = 2 -2^2 = 4 -2^3 = 8 - -2^0 = 1 -2^1 = 2 -2^2 = 4 -2^3 = 8 - -1 2 3 -List(1,2,3) - -out 0 new-value = False -*** simulation started *** -out 1 new-value = True -!0 = 1 - -*** simulation started *** -out 2 new-value = False -!1 = 0 - -out 2 new-value = False - -*** simulation started *** -0 & 0 = 0 - -*** simulation started *** -0 & 1 = 0 - -*** simulation started *** -out 11 new-value = True -out 11 new-value = False -1 & 0 = 0 - -*** simulation started *** -out 14 new-value = True -1 & 1 = 1 - -out 14 new-value = False - -*** simulation started *** -0 | 0 = 0 - -*** simulation started *** -out 24 new-value = True -0 | 1 = 1 - -*** simulation started *** -1 | 0 = 1 - -*** simulation started *** -1 | 1 = 1 - -sum 34 new-value = False -carry 34 new-value = False - -*** simulation started *** -0 + 0 = 0 - -*** simulation started *** -sum 47 new-value = True -0 + 1 = 1 - -*** simulation started *** -carry 50 new-value = True -carry 50 new-value = False -sum 54 new-value = False -sum 54 new-value = True -1 + 0 = 1 - -*** simulation started *** -carry 57 new-value = True -sum 61 new-value = False -1 + 1 = 2 - -sum 61 new-value = False -carry 61 new-value = False - -*** simulation started *** -0 + 0 + 0 = 0 - -*** simulation started *** -sum 82 new-value = True -0 + 0 + 1 = 1 - -*** simulation started *** -sum 89 new-value = False -carry 90 new-value = True -sum 97 new-value = True -carry 98 new-value = False -0 + 1 + 0 = 1 - -*** simulation started *** -sum 113 new-value = False -carry 114 new-value = True -0 + 1 + 1 = 2 - -*** simulation started *** -sum 121 new-value = True -carry 122 new-value = False -sum 129 new-value = False -sum 129 new-value = True -1 + 0 + 0 = 1 - -*** simulation started *** -carry 137 new-value = True -sum 144 new-value = False -1 + 0 + 1 = 2 - -*** simulation started *** -carry 152 new-value = False -sum 152 new-value = True -sum 158 new-value = False -carry 159 new-value = True -1 + 1 + 0 = 2 - -*** simulation started *** -sum 173 new-value = True -1 + 1 + 1 = 3 - -in 0 new-value = False -ctrl0 0 new-value = False -ctrl1 0 new-value = False -ctrl2 0 new-value = False -out0 0 new-value = False -out1 0 new-value = False -out2 0 new-value = False -out3 0 new-value = False -out4 0 new-value = False -out5 0 new-value = False -out6 0 new-value = False -out7 0 new-value = False -in 0 new-value = True -*** simulation started *** -out0 10 new-value = True -ctrl0 10 new-value = True -*** simulation started *** -out1 13 new-value = True -out0 14 new-value = False -ctrl1 14 new-value = True -*** simulation started *** -out3 20 new-value = True -out1 21 new-value = False -ctrl2 21 new-value = True -*** simulation started *** -out7 30 new-value = True -out3 31 new-value = False -ctrl0 31 new-value = False -*** simulation started *** -out7 34 new-value = False -out6 35 new-value = True diff --git a/test/files/run/Course-2002-09-msil.check b/test/files/run/Course-2002-09-msil.check deleted file mode 100644 index c921361db7..0000000000 --- a/test/files/run/Course-2002-09-msil.check +++ /dev/null @@ -1,50 +0,0 @@ -Probe: f = 32 -Probe: c = 0 -Probe: f = ? -Probe: c = ? - -Probe: f = 212 -Probe: c = 100 -Probe: f = ? -Probe: c = ? - -Probe: c = 0 -Probe: f = 32 -Probe: c = ? -Probe: f = ? - -Probe: c = 100 -Probe: f = 212 -Probe: c = ? -Probe: f = ? - -0 Celsius -> 32 Fahrenheits -100 Celsius -> 212 Fahrenheits -32 Fahrenheits -> 0 Celsius -212 Fahrenheits -> 100 Celsius - -a = ?, b = ?, c = ? => ? * ? = ? -a = 2, b = ?, c = ? => 2 * ? = ? -a = ?, b = 3, c = ? => ? * 3 = ? -a = ?, b = ?, c = 6 => ? * ? = 6 -a = 2, b = 3, c = ? => 2 * 3 = 6 -a = 2, b = ?, c = 6 => 2 * 3 = 6 -a = ?, b = 3, c = 6 => 2 * 3 = 6 -a = 2, b = 3, c = 6 => 2 * 3 = 6 - -a = 0, b = ?, c = ? => 0 * ? = 0 -a = ?, b = 0, c = ? => ? * 0 = 0 -a = ?, b = ?, c = 0 => ? * ? = 0 -a = 0, b = 7, c = ? => 0 * 7 = 0 -a = 7, b = 0, c = ? => 7 * 0 = 0 -a = 0, b = 0, c = ? => 0 * 0 = 0 -a = 0, b = ?, c = 0 => 0 * ? = 0 -a = ?, b = 0, c = 0 => ? * 0 = 0 -a = 0, b = 7, c = 0 => 0 * 7 = 0 -a = 7, b = 0, c = 0 => 7 * 0 = 0 -a = 0, b = 0, c = 0 => 0 * 0 = 0 - -a = 3, b = 4 => c = 5 -a = 3, c = 5 => b = 4 -b = 4, c = 5 => a = 3 - diff --git a/test/files/run/Course-2002-10-msil.check b/test/files/run/Course-2002-10-msil.check deleted file mode 100644 index bbd9414370..0000000000 --- a/test/files/run/Course-2002-10-msil.check +++ /dev/null @@ -1,46 +0,0 @@ -fib(0) = 0 -fib(1) = 1 -fib(2) = 1 -fib(3) = 2 -fib(4) = 3 -fib(5) = 5 -fib(6) = 8 -fib(7) = 13 -fib(8) = 21 -fib(9) = 34 -fib(10) = 55 -fib(11) = 89 -fib(12) = 144 -fib(13) = 233 -fib(14) = 377 -fib(15) = 610 -fib(16) = 987 -fib(17) = 1597 -fib(18) = 2584 -fib(19) = 4181 - -pi(0) = 4 , 3.16666666666667 , 4 -pi(1) = 2.66666666666667 , 3.13333333333333 , 3.16666666666667 -pi(2) = 3.46666666666667 , 3.1452380952381 , 3.1421052631579 -pi(3) = 2.8952380952381 , 3.13968253968254 , 3.141599357319 -pi(4) = 3.33968253968254 , 3.14271284271284 , 3.14159271403378 -pi(5) = 2.97604617604618 , 3.14088134088134 , 3.14159265397529 -pi(6) = 3.28373848373848 , 3.14207181707182 , 3.14159265359118 -pi(7) = 3.01707181707182 , 3.14125482360776 , 3.14159265358978 -pi(8) = 3.25236593471888 , 3.1418396189294 , 3.14159265358979 -pi(9) = 3.0418396189294 , 3.1414067184965 , 3.14159265358979 -pi = 3.14159265358979 , 3.14159265358979 , 3.14159265358979 - -ln(0) = 1 , 0.7 , 1 -ln(1) = 0.5 , 0.69047619047619 , 0.7 -ln(2) = 0.833333333333333 , 0.694444444444444 , 0.69327731092437 -ln(3) = 0.583333333333333 , 0.692424242424242 , 0.693148869332925 -ln(4) = 0.783333333333333 , 0.693589743589744 , 0.693147196073549 -ln(5) = 0.616666666666667 , 0.692857142857143 , 0.693147180663564 -ln(6) = 0.759523809523809 , 0.693347338935574 , 0.693147180560404 -ln(7) = 0.634523809523809 , 0.693003341687552 , 0.693147180559944 -ln(8) = 0.745634920634921 , 0.693253968253968 , 0.693147180559943 -ln(9) = 0.645634920634921 , 0.693065750674446 , 0.693147180559945 -ln = 0.693147180559945 , 0.693147180559945 , 0.693147180559945 - -prime numbers: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 diff --git a/test/files/run/Meter.check b/test/files/run/Meter.check index 7562f9a1bf..b7e2eac125 100644 --- a/test/files/run/Meter.check +++ b/test/files/run/Meter.check @@ -11,11 +11,3 @@ Array(1.0m, 2.0m) 1.0m >>>1.0m<<< 1.0m >>>2.0m<<< 2.0m -testing wrapped arrays -FlatArray(1.0m, 2.0m) -1.0m ->>>1.0m<<< 1.0m ->>>2.0m<<< 2.0m -FlatArray(2.0m, 3.0m) -ArrayBuffer(1.0, 2.0) -FlatArray(0.3048ft, 0.6096ft) diff --git a/test/files/run/Meter.scala b/test/files/run/Meter.scala index 515e46de24..d94f338ca9 100644 --- a/test/files/run/Meter.scala +++ b/test/files/run/Meter.scala @@ -80,23 +80,23 @@ object Test extends App { println(m) foo(arr) } - - { println("testing wrapped arrays") - import collection.mutable.FlatArray - val arr = FlatArray(x, y + x) - println(arr) - def foo(x: FlatArray[Meter]) { - for (i <- 0 until x.length) { x(i).print; println(" "+x(i)) } - } - val m = arr(0) - println(m) - foo(arr) - val ys: Seq[Meter] = arr map (_ + new Meter(1)) - println(ys) - val zs = arr map (_ / Meter(1)) - println(zs) - val fs = arr map (_.toFoot) - println(fs) - } + // + // { println("testing wrapped arrays") + // import collection.mutable.FlatArray + // val arr = FlatArray(x, y + x) + // println(arr) + // def foo(x: FlatArray[Meter]) { + // for (i <- 0 until x.length) { x(i).print; println(" "+x(i)) } + // } + // val m = arr(0) + // println(m) + // foo(arr) + // val ys: Seq[Meter] = arr map (_ + new Meter(1)) + // println(ys) + // val zs = arr map (_ / Meter(1)) + // println(zs) + // val fs = arr map (_.toFoot) + // println(fs) + // } } diff --git a/test/files/run/MeterCaseClass.check b/test/files/run/MeterCaseClass.check index 08370d2097..2528753657 100644 --- a/test/files/run/MeterCaseClass.check +++ b/test/files/run/MeterCaseClass.check @@ -11,11 +11,3 @@ Array(Meter(1.0), Meter(2.0)) Meter(1.0) >>>Meter(1.0)<<< Meter(1.0) >>>Meter(2.0)<<< Meter(2.0) -testing wrapped arrays -FlatArray(Meter(1.0), Meter(2.0)) -Meter(1.0) ->>>Meter(1.0)<<< Meter(1.0) ->>>Meter(2.0)<<< Meter(2.0) -FlatArray(Meter(2.0), Meter(3.0)) -ArrayBuffer(1.0, 2.0) -FlatArray(0.3048ft, 0.6096ft) diff --git a/test/files/run/MeterCaseClass.scala b/test/files/run/MeterCaseClass.scala index 8459163f31..e5979cf761 100644 --- a/test/files/run/MeterCaseClass.scala +++ b/test/files/run/MeterCaseClass.scala @@ -77,23 +77,23 @@ object Test extends App { println(m) foo(arr) } - - { println("testing wrapped arrays") - import collection.mutable.FlatArray - val arr = FlatArray(x, y + x) - println(arr) - def foo(x: FlatArray[Meter]) { - for (i <- 0 until x.length) { x(i).print; println(" "+x(i)) } - } - val m = arr(0) - println(m) - foo(arr) - val ys: Seq[Meter] = arr map (_ + new Meter(1)) - println(ys) - val zs = arr map (_ / Meter(1)) - println(zs) - val fs = arr map (_.toFoot) - println(fs) - } + // + // { println("testing wrapped arrays") + // import collection.mutable.FlatArray + // val arr = FlatArray(x, y + x) + // println(arr) + // def foo(x: FlatArray[Meter]) { + // for (i <- 0 until x.length) { x(i).print; println(" "+x(i)) } + // } + // val m = arr(0) + // println(m) + // foo(arr) + // val ys: Seq[Meter] = arr map (_ + new Meter(1)) + // println(ys) + // val zs = arr map (_ / Meter(1)) + // println(zs) + // val fs = arr map (_.toFoot) + // println(fs) + // } } diff --git a/test/files/run/absoverride-msil.check b/test/files/run/absoverride-msil.check deleted file mode 100644 index 938f62221f..0000000000 --- a/test/files/run/absoverride-msil.check +++ /dev/null @@ -1,20 +0,0 @@ -<sync> -next: m -</sync> -log: m -m -<sync> -next: s -</sync> -log: s -s -<sync> -next: i -</sync> -log: i -i -<sync> -next: l -</sync> -log: l -l diff --git a/test/files/run/applydynamic_sip.check b/test/files/run/applydynamic_sip.check new file mode 100644 index 0000000000..d94db4417e --- /dev/null +++ b/test/files/run/applydynamic_sip.check @@ -0,0 +1,22 @@ +qual.applyDynamic(sel)() +qual.applyDynamic(sel)(a) +qual.applyDynamic(sel)(a) +.apply(a2) +qual.applyDynamic(sel)(a) +qual.applyDynamic(sel)(a) +.apply(a2) +qual.applyDynamicNamed(sel)((arg,a)) +qual.applyDynamicNamed(sel)((arg,a)) +qual.applyDynamicNamed(sel)((,a), (arg2,a2)) +qual.updateDynamic(sel)(expr) +qual.selectDynamic(sel) +qual.selectDynamic(sel) +qual.selectDynamic(sel) +.update(1, expr) +qual.selectDynamic(sel) +.update(expr) +qual.selectDynamic(sel) +.apply(1) +qual.selectDynamic(sel) +.apply +.update(1, 1) diff --git a/test/files/run/applydynamic_sip.scala b/test/files/run/applydynamic_sip.scala new file mode 100644 index 0000000000..57cb4349f7 --- /dev/null +++ b/test/files/run/applydynamic_sip.scala @@ -0,0 +1,58 @@ +object Test extends App { + object stubUpdate { + def update(as: Any*) = println(".update"+as.toList.mkString("(",", ", ")")) + } + + object stub { + def apply = {println(".apply"); stubUpdate} + def apply(as: Any*) = println(".apply"+as.toList.mkString("(",", ", ")")) + def update(as: Any*) = println(".update"+as.toList.mkString("(",", ", ")")) + } + class MyDynamic extends Dynamic { + def applyDynamic[T](n: String)(as: Any*) = {println("qual.applyDynamic("+ n +")"+ as.toList.mkString("(",", ", ")")); stub} + def applyDynamicNamed[T](n: String)(as: (String, Any)*) = {println("qual.applyDynamicNamed("+ n +")"+ as.toList.mkString("(",", ", ")")); stub} + def selectDynamic[T](n: String) = {println("qual.selectDynamic("+ n +")"); stub} + def updateDynamic(n: String)(x: Any): Unit = {println("qual.updateDynamic("+ n +")("+ x +")")} + } + val qual = new MyDynamic + val expr = "expr" + val a = "a" + val a2 = "a2" + type T = String + + // If qual.sel is followed by a potential type argument list [Ts] and an argument list (arg1, …, argn) where none of the arguments argi are named: + // qual.applyDynamic(“sel”)(arg1, …, argn) + qual.sel() + qual.sel(a) + // qual.sel(a, a2: _*) -- should not accept varargs? + qual.sel(a)(a2) + qual.sel[T](a) + qual.sel[T](a)(a2) + + // If qual.sel is followed by a potential type argument list [Ts] + // and a non-empty named argument list (x1 = arg1, …, xn = argn) where some name prefixes xi = might be missing: + // qual.applyDynamicNamed(“sel”)(xs1 -> arg1, …, xsn -> argn) + qual.sel(arg = a) + qual.sel[T](arg = a) + qual.sel(a, arg2 = "a2") + // qual.sel(a)(a2, arg2 = "a2") + // qual.sel[T](a)(a2, arg2 = "a2") + // qual.sel(arg = a, a2: _*) + // qual.sel(arg, arg2 = "a2", a2: _*) + + // If qual.sel appears immediately on the left-hand side of an assigment + // qual.updateDynamic(“sel”)(expr) + qual.sel = expr + + // If qual.sel, possibly applied to type arguments, but is + // not applied to explicit value arguments, + // nor immediately followed by an assignment operator: + // qual.selectDynamic[Ts](“sel”) + qual.sel + qual.sel[T] + + qual.sel(1) = expr // parser turns this into qual.sel.update(1, expr) + qual.sel() = expr // parser turns this into qual.sel.update(expr) + qual.sel.apply(1) + qual.sel.apply(1) = 1 +}
\ No newline at end of file diff --git a/test/files/run/array-charSeq.check b/test/files/run/array-charSeq.check new file mode 100644 index 0000000000..f1f374f63e --- /dev/null +++ b/test/files/run/array-charSeq.check @@ -0,0 +1,248 @@ + +[check 'abcdefghi'] len = 9 +sub(0, 9) == 'abcdefghi' +sub(0, 0) == '' +sub(1, 9) == 'bcdefghi' +sub(0, 1) == 'a' +sub(2, 9) == 'cdefghi' +sub(0, 2) == 'ab' +sub(3, 9) == 'defghi' +sub(0, 3) == 'abc' +sub(4, 9) == 'efghi' +sub(0, 4) == 'abcd' +sub(5, 9) == 'fghi' +sub(0, 5) == 'abcde' +sub(6, 9) == 'ghi' +sub(0, 6) == 'abcdef' +sub(7, 9) == 'hi' +sub(0, 7) == 'abcdefg' +sub(8, 9) == 'i' +sub(0, 8) == 'abcdefgh' + +[check 'bcdefgh'] len = 7 +sub(0, 7) == 'bcdefgh' +sub(0, 0) == '' +sub(1, 7) == 'cdefgh' +sub(0, 1) == 'b' +sub(2, 7) == 'defgh' +sub(0, 2) == 'bc' +sub(3, 7) == 'efgh' +sub(0, 3) == 'bcd' +sub(4, 7) == 'fgh' +sub(0, 4) == 'bcde' +sub(5, 7) == 'gh' +sub(0, 5) == 'bcdef' +sub(6, 7) == 'h' +sub(0, 6) == 'bcdefg' + +[check 'cdefg'] len = 5 +sub(0, 5) == 'cdefg' +sub(0, 0) == '' +sub(1, 5) == 'defg' +sub(0, 1) == 'c' +sub(2, 5) == 'efg' +sub(0, 2) == 'cd' +sub(3, 5) == 'fg' +sub(0, 3) == 'cde' +sub(4, 5) == 'g' +sub(0, 4) == 'cdef' + +[check 'def'] len = 3 +sub(0, 3) == 'def' +sub(0, 0) == '' +sub(1, 3) == 'ef' +sub(0, 1) == 'd' +sub(2, 3) == 'f' +sub(0, 2) == 'de' + +[check 'e'] len = 1 +sub(0, 1) == 'e' +sub(0, 0) == '' + +[check 'abcdefgh'] len = 8 +sub(0, 8) == 'abcdefgh' +sub(0, 0) == '' +sub(1, 8) == 'bcdefgh' +sub(0, 1) == 'a' +sub(2, 8) == 'cdefgh' +sub(0, 2) == 'ab' +sub(3, 8) == 'defgh' +sub(0, 3) == 'abc' +sub(4, 8) == 'efgh' +sub(0, 4) == 'abcd' +sub(5, 8) == 'fgh' +sub(0, 5) == 'abcde' +sub(6, 8) == 'gh' +sub(0, 6) == 'abcdef' +sub(7, 8) == 'h' +sub(0, 7) == 'abcdefg' + +[check 'bcdefg'] len = 6 +sub(0, 6) == 'bcdefg' +sub(0, 0) == '' +sub(1, 6) == 'cdefg' +sub(0, 1) == 'b' +sub(2, 6) == 'defg' +sub(0, 2) == 'bc' +sub(3, 6) == 'efg' +sub(0, 3) == 'bcd' +sub(4, 6) == 'fg' +sub(0, 4) == 'bcde' +sub(5, 6) == 'g' +sub(0, 5) == 'bcdef' + +[check 'cdef'] len = 4 +sub(0, 4) == 'cdef' +sub(0, 0) == '' +sub(1, 4) == 'def' +sub(0, 1) == 'c' +sub(2, 4) == 'ef' +sub(0, 2) == 'cd' +sub(3, 4) == 'f' +sub(0, 3) == 'cde' + +[check 'de'] len = 2 +sub(0, 2) == 'de' +sub(0, 0) == '' +sub(1, 2) == 'e' +sub(0, 1) == 'd' + +[check ''] len = 0 + +[check 'abcdefg'] len = 7 +sub(0, 7) == 'abcdefg' +sub(0, 0) == '' +sub(1, 7) == 'bcdefg' +sub(0, 1) == 'a' +sub(2, 7) == 'cdefg' +sub(0, 2) == 'ab' +sub(3, 7) == 'defg' +sub(0, 3) == 'abc' +sub(4, 7) == 'efg' +sub(0, 4) == 'abcd' +sub(5, 7) == 'fg' +sub(0, 5) == 'abcde' +sub(6, 7) == 'g' +sub(0, 6) == 'abcdef' + +[check 'bcdef'] len = 5 +sub(0, 5) == 'bcdef' +sub(0, 0) == '' +sub(1, 5) == 'cdef' +sub(0, 1) == 'b' +sub(2, 5) == 'def' +sub(0, 2) == 'bc' +sub(3, 5) == 'ef' +sub(0, 3) == 'bcd' +sub(4, 5) == 'f' +sub(0, 4) == 'bcde' + +[check 'cde'] len = 3 +sub(0, 3) == 'cde' +sub(0, 0) == '' +sub(1, 3) == 'de' +sub(0, 1) == 'c' +sub(2, 3) == 'e' +sub(0, 2) == 'cd' + +[check 'd'] len = 1 +sub(0, 1) == 'd' +sub(0, 0) == '' + +[check 'abcdef'] len = 6 +sub(0, 6) == 'abcdef' +sub(0, 0) == '' +sub(1, 6) == 'bcdef' +sub(0, 1) == 'a' +sub(2, 6) == 'cdef' +sub(0, 2) == 'ab' +sub(3, 6) == 'def' +sub(0, 3) == 'abc' +sub(4, 6) == 'ef' +sub(0, 4) == 'abcd' +sub(5, 6) == 'f' +sub(0, 5) == 'abcde' + +[check 'bcde'] len = 4 +sub(0, 4) == 'bcde' +sub(0, 0) == '' +sub(1, 4) == 'cde' +sub(0, 1) == 'b' +sub(2, 4) == 'de' +sub(0, 2) == 'bc' +sub(3, 4) == 'e' +sub(0, 3) == 'bcd' + +[check 'cd'] len = 2 +sub(0, 2) == 'cd' +sub(0, 0) == '' +sub(1, 2) == 'd' +sub(0, 1) == 'c' + +[check ''] len = 0 + +[check 'abcde'] len = 5 +sub(0, 5) == 'abcde' +sub(0, 0) == '' +sub(1, 5) == 'bcde' +sub(0, 1) == 'a' +sub(2, 5) == 'cde' +sub(0, 2) == 'ab' +sub(3, 5) == 'de' +sub(0, 3) == 'abc' +sub(4, 5) == 'e' +sub(0, 4) == 'abcd' + +[check 'bcd'] len = 3 +sub(0, 3) == 'bcd' +sub(0, 0) == '' +sub(1, 3) == 'cd' +sub(0, 1) == 'b' +sub(2, 3) == 'd' +sub(0, 2) == 'bc' + +[check 'c'] len = 1 +sub(0, 1) == 'c' +sub(0, 0) == '' + +[check 'abcd'] len = 4 +sub(0, 4) == 'abcd' +sub(0, 0) == '' +sub(1, 4) == 'bcd' +sub(0, 1) == 'a' +sub(2, 4) == 'cd' +sub(0, 2) == 'ab' +sub(3, 4) == 'd' +sub(0, 3) == 'abc' + +[check 'bc'] len = 2 +sub(0, 2) == 'bc' +sub(0, 0) == '' +sub(1, 2) == 'c' +sub(0, 1) == 'b' + +[check ''] len = 0 + +[check 'abc'] len = 3 +sub(0, 3) == 'abc' +sub(0, 0) == '' +sub(1, 3) == 'bc' +sub(0, 1) == 'a' +sub(2, 3) == 'c' +sub(0, 2) == 'ab' + +[check 'b'] len = 1 +sub(0, 1) == 'b' +sub(0, 0) == '' + +[check 'ab'] len = 2 +sub(0, 2) == 'ab' +sub(0, 0) == '' +sub(1, 2) == 'b' +sub(0, 1) == 'a' + +[check ''] len = 0 + +[check 'a'] len = 1 +sub(0, 1) == 'a' +sub(0, 0) == '' diff --git a/test/files/run/array-charSeq.scala b/test/files/run/array-charSeq.scala new file mode 100644 index 0000000000..f7d0586f03 --- /dev/null +++ b/test/files/run/array-charSeq.scala @@ -0,0 +1,27 @@ +object Test { + val arr = Array[Char]('a' to 'i': _*) + var xs: CharSequence = arr + val hash = xs.hashCode + + def check(chars: CharSequence) { + println("\n[check '" + chars + "'] len = " + chars.length) + chars match { + case x: runtime.ArrayCharSequence => assert(x.xs eq arr, ((x.xs, arr))) + case x => assert(false, x) + } + + 0 until chars.length foreach { i => + println("sub(%s, %s) == '%s'".format(i, chars.length, chars.subSequence(i, chars.length))) + println("sub(%s, %s) == '%s'".format(0, i, chars.subSequence(0, i))) + } + if (chars.length >= 2) + check(chars.subSequence(1, chars.length - 1)) + } + + def main(args: Array[String]): Unit = { + while (xs.length > 0) { + check(xs) + xs = xs.subSequence(0, xs.length - 1) + } + } +} diff --git a/test/files/run/arrayclone-new.scala b/test/files/run/arrayclone-new.scala new file mode 100644 index 0000000000..a4ba021409 --- /dev/null +++ b/test/files/run/arrayclone-new.scala @@ -0,0 +1,106 @@ +object Test extends App{ + BooleanArrayClone; + ByteArrayClone; + ShortArrayClone; + CharArrayClone; + IntArrayClone; + LongArrayClone; + FloatArrayClone; + DoubleArrayClone; + ObjectArrayClone; + PolymorphicArrayClone; +} + +object BooleanArrayClone{ + val it : Array[Boolean] = Array(true, false); + val cloned = it.clone(); + assert(cloned.sameElements(it)); + cloned(0) = false; + assert(it(0) == true) +} + +object ByteArrayClone{ + val it : Array[Byte] = Array(1, 0); + val cloned = it.clone(); + assert(cloned.sameElements(it)); + cloned(0) = 0; + assert(it(0) == 1) +} + +object ShortArrayClone{ + val it : Array[Short] = Array(1, 0); + val cloned = it.clone(); + assert(cloned.sameElements(it)); + cloned(0) = 0; + assert(it(0) == 1) +} + +object CharArrayClone{ + val it : Array[Char] = Array(1, 0); + val cloned = it.clone(); + assert(cloned.sameElements(it)); + cloned(0) = 0; + assert(it(0) == 1) +} + +object IntArrayClone{ + val it : Array[Int] = Array(1, 0); + val cloned = it.clone(); + assert(cloned.sameElements(it)); + cloned(0) = 0; + assert(it(0) == 1) +} + +object LongArrayClone{ + val it : Array[Long] = Array(1, 0); + val cloned = it.clone(); + assert(cloned.sameElements(it)); + cloned(0) = 0; + assert(it(0) == 1) +} + +object FloatArrayClone{ + val it : Array[Float] = Array(1, 0); + val cloned = it.clone(); + assert(cloned.sameElements(it)); + cloned(0) = 0; + assert(it(0) == 1) +} + +object DoubleArrayClone{ + val it : Array[Double] = Array(1, 0); + val cloned = it.clone(); + assert(cloned.sameElements(it)); + cloned(0) = 0; + assert(it(0) == 1) +} + +object ObjectArrayClone{ + val it : Array[String] = Array("1", "0"); + val cloned = it.clone(); + assert(cloned.sameElements(it)); + cloned(0) = "0"; + assert(it(0) == "1") +} + +object PolymorphicArrayClone{ + def testIt[T](it : Array[T], one : T, zero : T) = { + val cloned = it.clone(); + assert(cloned.sameElements(it)); + cloned(0) = zero; + assert(it(0) == one) + } + + testIt(Array("one", "two"), "one", "two"); + + class Mangler[T: ArrayTag](ts : T*){ + // this will always be a BoxedAnyArray even after we've unboxed its contents. + val it = ts.toArray[T]; + } + + val mangled = new Mangler[Int](0, 1); + + val y : Array[Int] = mangled.it; // make sure it's unboxed + + testIt(mangled.it, 0, 1); +} diff --git a/test/files/run/arrayclone.scala b/test/files/run/arrayclone-old.scala index c9f7556b47..c9f7556b47 100644 --- a/test/files/run/arrayclone.scala +++ b/test/files/run/arrayclone-old.scala diff --git a/test/files/run/arraytags_basic.check b/test/files/run/arraytags_basic.check new file mode 100644 index 0000000000..92816b91bd --- /dev/null +++ b/test/files/run/arraytags_basic.check @@ -0,0 +1,36 @@ +class [I
+class [[I
+class [[[I
+class [Lscala.collection.immutable.List;
+class [[Lscala.collection.immutable.List;
+class [[[Lscala.collection.immutable.List;
+class [Lscala.collection.immutable.List;
+class [[Lscala.collection.immutable.List;
+class [[[Lscala.collection.immutable.List;
+class [Lscala.collection.immutable.Map;
+class [[Lscala.collection.immutable.Map;
+class [[[Lscala.collection.immutable.Map;
+class [[I
+class [[[I
+class [[[[I
+class [[Lscala.collection.immutable.List;
+class [[[Lscala.collection.immutable.List;
+class [[[[Lscala.collection.immutable.List;
+class [[Lscala.collection.immutable.List;
+class [[[Lscala.collection.immutable.List;
+class [[[[Lscala.collection.immutable.List;
+class [[Lscala.collection.immutable.Map;
+class [[[Lscala.collection.immutable.Map;
+class [[[[Lscala.collection.immutable.Map;
+class [[[I
+class [[[[I
+class [[[[[I
+class [[[Lscala.collection.immutable.List;
+class [[[[Lscala.collection.immutable.List;
+class [[[[[Lscala.collection.immutable.List;
+class [[[Lscala.collection.immutable.List;
+class [[[[Lscala.collection.immutable.List;
+class [[[[[Lscala.collection.immutable.List;
+class [[[Lscala.collection.immutable.Map;
+class [[[[Lscala.collection.immutable.Map;
+class [[[[[Lscala.collection.immutable.Map;
diff --git a/test/files/run/arraytags_basic.scala b/test/files/run/arraytags_basic.scala new file mode 100644 index 0000000000..edc20e9bc1 --- /dev/null +++ b/test/files/run/arraytags_basic.scala @@ -0,0 +1,22 @@ +object Test extends App { + def test[T: ArrayTag] = { + println(implicitly[ArrayTag[T]].newArray(10).getClass) + println(implicitly[ArrayTag[T]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[T]]].wrap.newArray(10).getClass) + } + + test[Int] + test[List[Int]] + test[List[String]] + test[Map[Int, String]] + + test[Array[Int]] + test[Array[List[Int]]] + test[Array[List[String]]] + test[Array[Map[Int, String]]] + + test[Array[Array[Int]]] + test[Array[Array[List[Int]]]] + test[Array[Array[List[String]]]] + test[Array[Array[Map[Int, String]]]] +}
\ No newline at end of file diff --git a/test/files/run/arraytags_core.check b/test/files/run/arraytags_core.check new file mode 100644 index 0000000000..82ed84ad78 --- /dev/null +++ b/test/files/run/arraytags_core.check @@ -0,0 +1,48 @@ +class [B
+class [[B
+class [[[B
+class [S
+class [[S
+class [[[S
+class [C
+class [[C
+class [[[C
+class [I
+class [[I
+class [[[I
+class [J
+class [[J
+class [[[J
+class [F
+class [[F
+class [[[F
+class [D
+class [[D
+class [[[D
+class [Z
+class [[Z
+class [[[Z
+class [Lscala.runtime.BoxedUnit;
+class [[Lscala.runtime.BoxedUnit;
+class [[[Lscala.runtime.BoxedUnit;
+class [Ljava.lang.Object;
+class [[Ljava.lang.Object;
+class [[[Ljava.lang.Object;
+class [Ljava.lang.Object;
+class [[Ljava.lang.Object;
+class [[[Ljava.lang.Object;
+class [Ljava.lang.Object;
+class [[Ljava.lang.Object;
+class [[[Ljava.lang.Object;
+class [Ljava.lang.Object;
+class [[Ljava.lang.Object;
+class [[[Ljava.lang.Object;
+class [Lscala.runtime.Null$;
+class [[Lscala.runtime.Null$;
+class [[[Lscala.runtime.Null$;
+class [Lscala.runtime.Nothing$;
+class [[Lscala.runtime.Nothing$;
+class [[[Lscala.runtime.Nothing$;
+class [Ljava.lang.String;
+class [[Ljava.lang.String;
+class [[[Ljava.lang.String;
diff --git a/test/files/run/arraytags_core.scala b/test/files/run/arraytags_core.scala new file mode 100644 index 0000000000..a59ae24f30 --- /dev/null +++ b/test/files/run/arraytags_core.scala @@ -0,0 +1,50 @@ +object Test extends App { + println(implicitly[ArrayTag[Byte]].newArray(10).getClass) + println(implicitly[ArrayTag[Byte]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Byte]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Short]].newArray(10).getClass) + println(implicitly[ArrayTag[Short]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Short]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Char]].newArray(10).getClass) + println(implicitly[ArrayTag[Char]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Char]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Int]].newArray(10).getClass) + println(implicitly[ArrayTag[Int]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Int]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Long]].newArray(10).getClass) + println(implicitly[ArrayTag[Long]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Long]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Float]].newArray(10).getClass) + println(implicitly[ArrayTag[Float]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Float]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Double]].newArray(10).getClass) + println(implicitly[ArrayTag[Double]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Double]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Boolean]].newArray(10).getClass) + println(implicitly[ArrayTag[Boolean]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Boolean]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Unit]].newArray(10).getClass) + println(implicitly[ArrayTag[Unit]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Unit]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Any]].newArray(10).getClass) + println(implicitly[ArrayTag[Any]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Any]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Object]].newArray(10).getClass) + println(implicitly[ArrayTag[Object]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Object]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[AnyVal]].newArray(10).getClass) + println(implicitly[ArrayTag[AnyVal]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[AnyVal]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[AnyRef]].newArray(10).getClass) + println(implicitly[ArrayTag[AnyRef]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[AnyRef]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Null]].newArray(10).getClass) + println(implicitly[ArrayTag[Null]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Null]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Nothing]].newArray(10).getClass) + println(implicitly[ArrayTag[Nothing]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Nothing]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[String]].newArray(10).getClass) + println(implicitly[ArrayTag[String]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[String]]].wrap.newArray(10).getClass) +}
\ No newline at end of file diff --git a/test/files/run/arraytags_usage.check b/test/files/run/arraytags_usage.check new file mode 100644 index 0000000000..b1d02b7bfe --- /dev/null +++ b/test/files/run/arraytags_usage.check @@ -0,0 +1,3 @@ +class [I
+class [I
+class [I
diff --git a/test/files/run/arraytags_usage.scala b/test/files/run/arraytags_usage.scala new file mode 100644 index 0000000000..60b0a8f218 --- /dev/null +++ b/test/files/run/arraytags_usage.scala @@ -0,0 +1,15 @@ +object Test extends App { + def foo[T] = { + class MyArrayTag extends ArrayTag[T] { + def wrap: ArrayTag[Array[T]] = ??? + def newArray(len: Int): Array[T] = new Array[Int](len).asInstanceOf[Array[T]] + } + + implicit val tag = new MyArrayTag() + println(Array[T]().getClass) + } + + foo[Int] + foo[String] + foo[Array[String]] +}
\ No newline at end of file diff --git a/test/files/run/backreferences.check b/test/files/run/backreferences.check new file mode 100644 index 0000000000..1d474d5255 --- /dev/null +++ b/test/files/run/backreferences.check @@ -0,0 +1,2 @@ +false +true diff --git a/test/files/run/backreferences.scala b/test/files/run/backreferences.scala new file mode 100644 index 0000000000..335cd6c7de --- /dev/null +++ b/test/files/run/backreferences.scala @@ -0,0 +1,13 @@ +case class Elem[T](x: T, y: T) + +object Test { + def unrolled[T](x: Any, y: Any, z: Any) = (x, y, z) match { + case (el: Elem[_], el.x, el.y) => true + case _ => false + } + + def main(args: Array[String]): Unit = { + println(unrolled(Elem("bippy", 5), "bippy", 6)) + println(unrolled(Elem("bippy", 5), "bippy", 5)) + } +} diff --git a/test/files/run/bitsets-msil.check b/test/files/run/bitsets-msil.check deleted file mode 100644 index b187571bff..0000000000 --- a/test/files/run/bitsets-msil.check +++ /dev/null @@ -1,33 +0,0 @@ -ms0 = BitSet(2) -ms1 = BitSet(2) -ms2 = BitSet(2) -mb0 = False -mb1 = True -mb2 = False -xs0 = List(2) -xs1 = List(2) -xs2 = List(2) -ma0 = List(2) -ma1 = List(2) -ma2 = List(2) -mi0 = BitSet(2) -mi1 = BitSet(2) -mi2 = BitSet(2) - -is0 = BitSet() -is1 = BitSet() -is2 = BitSet(2) -is3 = BitSet() -ib0 = False -ib1 = False -ib2 = True -ib3 = False -ys0 = List() -ys1 = List() -ys2 = List(2) -ys3 = List() -ia0 = List() -ia1 = List() -ia2 = List(2) -ia3 = List() - diff --git a/test/files/run/boolord-msil.check b/test/files/run/boolord-msil.check deleted file mode 100644 index e5f1daa0e5..0000000000 --- a/test/files/run/boolord-msil.check +++ /dev/null @@ -1,4 +0,0 @@ -false < false = False -false < true = True -true < false = False -true < true = False diff --git a/test/files/run/bugs-msil.check b/test/files/run/bugs-msil.check deleted file mode 100644 index 4e15409547..0000000000 --- a/test/files/run/bugs-msil.check +++ /dev/null @@ -1,96 +0,0 @@ -<<< bug 98 -mycase ->>> bug 98 - -<<< bug 120 -one -A -B -C ->>> bug 120 - -<<< bug 135 -Some(The answer) ->>> bug 135 - -<<< bug 142 -ok -ok -ok -ok -ok -ok -ok -ok ->>> bug 142 - -<<< bug 166 ->>> bug 166 - -<<< bug 167 ->>> bug 167 - -<<< bug 168 ->>> bug 168 - -<<< bug 174 ->>> bug 174 - -<<< bug 176 -1 ->>> bug 176 - -<<< bug 199 ->>> bug 199 - -<<< bug 213 -Cannot cast unit to Nothing -Cannot cast empty string to Null ->>> bug 213 - -<<< bug 217 ->>> bug 217 - -<<< bug 222 ->>> bug 222 - -<<< bug 225 ->>> bug 225 - -<<< bug 226 ->>> bug 226 - -<<< bug 233 -True ->>> bug 233 - -<<< bug 250 ->>> bug 250 - -<<< bug 257 -I should come 1st and 2nd -I should come 1st and 2nd -I should come last ->>> bug 257 - -<<< bug 266 -hello -4 ->>> bug 266 - -<<< bug 316 ->>> bug 316 - -<<< bug 328 ->>> bug 328 - -<<< bug 396 -A -B -C ->>> bug 396 - -<<< bug 399 -a ->>> bug 399 - diff --git a/test/files/run/bugs.scala b/test/files/run/bugs.scala index d5905af76c..ca598603bb 100644 --- a/test/files/run/bugs.scala +++ b/test/files/run/bugs.scala @@ -445,8 +445,7 @@ object Test { test; } catch { case exception => - val curr: String = currentThread.toString(); - Console.print("Exception in thread \"" + curr + "\" " + exception); + Console.print("Exception in thread \"" + Thread.currentThread + "\" " + exception); Console.println; errors += 1 } diff --git a/test/files/run/caseClassHash.check b/test/files/run/caseClassHash.check new file mode 100644 index 0000000000..b5a6f08e99 --- /dev/null +++ b/test/files/run/caseClassHash.check @@ -0,0 +1,9 @@ +Foo(true,-1,-1,d,-5,-10,500.0,500.0,List(),5.0) +Foo(true,-1,-1,d,-5,-10,500.0,500.0,List(),5) +1383698062 +1383698062 +true +## method 1: 1383698062 +## method 2: 1383698062 + Murmur 1: 1383698062 + Murmur 2: 1383698062 diff --git a/test/files/run/caseClassHash.scala b/test/files/run/caseClassHash.scala new file mode 100644 index 0000000000..7adfddedf8 --- /dev/null +++ b/test/files/run/caseClassHash.scala @@ -0,0 +1,37 @@ +case class Foo[T](a: Boolean, b: Byte, c: Short, d: Char, e: Int, f: Long, g: Double, h: Float, i: AnyRef, j: T) { } + +object Test { + def mkFoo[T](x: T) = Foo[T](true, -1, -1, 100, -5, -10, 500d, 500f, Nil, x) + + def main(args: Array[String]): Unit = { + val foo1 = mkFoo[Double](5.0d) + val foo2 = mkFoo[Long](5l) + + List(foo1, foo2, foo1.##, foo2.##, foo1 == foo2) foreach println + + println("## method 1: " + foo1.##) + println("## method 2: " + foo2.##) + println(" Murmur 1: " + scala.util.MurmurHash3.productHash(foo1)) + println(" Murmur 2: " + scala.util.MurmurHash3.productHash(foo2)) + } +} + +object Timing { + var hash = 0 + def mkFoo(i: Int) = Foo(i % 2 == 0, i.toByte, i.toShort, i.toChar, i, i, 1.1, 1.1f, this, this) + + def main(args: Array[String]): Unit = { + val reps = if (args.isEmpty) 100000000 else args(0).toInt + val start = System.nanoTime + + println("Warmup.") + 1 to 10000 foreach mkFoo + + hash = 0 + 1 to reps foreach (i => hash += mkFoo(i).##) + + val end = System.nanoTime + println("hash = " + hash) + println("Elapsed: " + ((end - start) / 1e6) + " ms.") + } +} diff --git a/test/files/run/classtags_core.check b/test/files/run/classtags_core.check index ce5a893b08..ebccfcd54c 100644 --- a/test/files/run/classtags_core.check +++ b/test/files/run/classtags_core.check @@ -1,30 +1,32 @@ -true
-ClassTag(byte)
-true
-ClassTag(short)
-true
-ClassTag(char)
-true
-ClassTag(int)
-true
-ClassTag(long)
-true
-ClassTag(float)
-true
-ClassTag(double)
-true
-ClassTag(boolean)
-true
-ClassTag(void)
-true
-ClassTag(class java.lang.Object)
-true
-ClassTag(class java.lang.Object)
-true
-ClassTag(class java.lang.Object)
-true
-ClassTag(class java.lang.Object)
-true
-ClassTag(class java.lang.Object)
-true
-ClassTag(class java.lang.Object)
+true +ClassTag[byte] +true +ClassTag[short] +true +ClassTag[char] +true +ClassTag[int] +true +ClassTag[long] +true +ClassTag[float] +true +ClassTag[double] +true +ClassTag[boolean] +true +ClassTag[void] +true +ClassTag[class java.lang.Object] +true +ClassTag[class java.lang.Object] +true +ClassTag[class java.lang.Object] +true +ClassTag[class java.lang.Object] +true +ClassTag[class scala.runtime.Null$] +true +ClassTag[class scala.runtime.Nothing$] +true +ClassTag[class java.lang.String] diff --git a/test/files/run/classtags_core.scala b/test/files/run/classtags_core.scala index 45c54b1fe0..9f2031377d 100644 --- a/test/files/run/classtags_core.scala +++ b/test/files/run/classtags_core.scala @@ -29,4 +29,6 @@ object Test extends App { println(implicitly[ClassTag[Null]]) println(implicitly[ClassTag[Nothing]] eq ClassTag.Nothing) println(implicitly[ClassTag[Nothing]]) + println(implicitly[ClassTag[String]] eq ClassTag.String) + println(implicitly[ClassTag[String]]) }
\ No newline at end of file diff --git a/test/files/run/classtags_multi.check b/test/files/run/classtags_multi.check new file mode 100644 index 0000000000..3a7f16c3a0 --- /dev/null +++ b/test/files/run/classtags_multi.check @@ -0,0 +1,5 @@ +ClassTag[int]
+ClassTag[class [I]
+ClassTag[class [[I]
+ClassTag[class [[[I]
+ClassTag[class [[[[I]
diff --git a/test/files/run/classtags_multi.scala b/test/files/run/classtags_multi.scala new file mode 100644 index 0000000000..5aafb55223 --- /dev/null +++ b/test/files/run/classtags_multi.scala @@ -0,0 +1,7 @@ +object Test extends App { + println(classTag[Int]) + println(classTag[Array[Int]]) + println(classTag[Array[Array[Int]]]) + println(classTag[Array[Array[Array[Int]]]]) + println(classTag[Array[Array[Array[Array[Int]]]]]) +}
\ No newline at end of file diff --git a/test/files/run/classtags_use_concretetypetags.scala b/test/files/run/classtags_use_concretetypetags.scala new file mode 100644 index 0000000000..57e7085cec --- /dev/null +++ b/test/files/run/classtags_use_concretetypetags.scala @@ -0,0 +1,3 @@ +object Test extends App { + def foo[T: ConcreteTypeTag] = Array[T]() +}
\ No newline at end of file diff --git a/test/files/run/color.check b/test/files/run/color.check deleted file mode 100644 index 598cc145f0..0000000000 --- a/test/files/run/color.check +++ /dev/null @@ -1,693 +0,0 @@ - -1 color -[30mthe quick brown fox[0m Black -[31mthe quick brown fox[0m Red -[32mthe quick brown fox[0m Green -[33mthe quick brown fox[0m Yellow -[34mthe quick brown fox[0m Blue -[35mthe quick brown fox[0m Magenta -[36mthe quick brown fox[0m Cyan -[37mthe quick brown fox[0m White - -1 effect -[0mthe quick brown fox[0m Reset -[1mthe quick brown fox[0m Bright -[2mthe quick brown fox[0m Faint -[3mthe quick brown fox[0m Italic -[4mthe quick brown fox[0m Underline -[5mthe quick brown fox[0m Blink -[7mthe quick brown fox[0m Inverse -[8mthe quick brown fox[0m Hidden -[9mthe quick brown fox[0m Strikethrough - -1 color 1 effect -[1;30mthe quick brown fox[0m Bright Black -[4;30mthe quick brown fox[0m Underline Black -[7;30mthe quick brown fox[0m Inverse Black -[1;31mthe quick brown fox[0m Bright Red -[4;31mthe quick brown fox[0m Underline Red -[7;31mthe quick brown fox[0m Inverse Red -[1;32mthe quick brown fox[0m Bright Green -[4;32mthe quick brown fox[0m Underline Green -[7;32mthe quick brown fox[0m Inverse Green -[1;33mthe quick brown fox[0m Bright Yellow -[4;33mthe quick brown fox[0m Underline Yellow -[7;33mthe quick brown fox[0m Inverse Yellow -[1;34mthe quick brown fox[0m Bright Blue -[4;34mthe quick brown fox[0m Underline Blue -[7;34mthe quick brown fox[0m Inverse Blue -[1;35mthe quick brown fox[0m Bright Magenta -[4;35mthe quick brown fox[0m Underline Magenta -[7;35mthe quick brown fox[0m Inverse Magenta -[1;36mthe quick brown fox[0m Bright Cyan -[4;36mthe quick brown fox[0m Underline Cyan -[7;36mthe quick brown fox[0m Inverse Cyan -[1;37mthe quick brown fox[0m Bright White -[4;37mthe quick brown fox[0m Underline White -[7;37mthe quick brown fox[0m Inverse White - -2 colors 0 effects -[30;40mthe quick brown fox[0m Black (on Black background) -[31;40mthe quick brown fox[0m Red (on Black background) -[32;40mthe quick brown fox[0m Green (on Black background) -[33;40mthe quick brown fox[0m Yellow (on Black background) -[34;40mthe quick brown fox[0m Blue (on Black background) -[35;40mthe quick brown fox[0m Magenta (on Black background) -[36;40mthe quick brown fox[0m Cyan (on Black background) -[37;40mthe quick brown fox[0m White (on Black background) -[30;41mthe quick brown fox[0m Black (on Red background) -[31;41mthe quick brown fox[0m Red (on Red background) -[32;41mthe quick brown fox[0m Green (on Red background) -[33;41mthe quick brown fox[0m Yellow (on Red background) -[34;41mthe quick brown fox[0m Blue (on Red background) -[35;41mthe quick brown fox[0m Magenta (on Red background) -[36;41mthe quick brown fox[0m Cyan (on Red background) -[37;41mthe quick brown fox[0m White (on Red background) -[30;42mthe quick brown fox[0m Black (on Green background) -[31;42mthe quick brown fox[0m Red (on Green background) -[32;42mthe quick brown fox[0m Green (on Green background) -[33;42mthe quick brown fox[0m Yellow (on Green background) -[34;42mthe quick brown fox[0m Blue (on Green background) -[35;42mthe quick brown fox[0m Magenta (on Green background) -[36;42mthe quick brown fox[0m Cyan (on Green background) -[37;42mthe quick brown fox[0m White (on Green background) -[30;43mthe quick brown fox[0m Black (on Yellow background) -[31;43mthe quick brown fox[0m Red (on Yellow background) -[32;43mthe quick brown fox[0m Green (on Yellow background) -[33;43mthe quick brown fox[0m Yellow (on Yellow background) -[34;43mthe quick brown fox[0m Blue (on Yellow background) -[35;43mthe quick brown fox[0m Magenta (on Yellow background) -[36;43mthe quick brown fox[0m Cyan (on Yellow background) -[37;43mthe quick brown fox[0m White (on Yellow background) -[30;44mthe quick brown fox[0m Black (on Blue background) -[31;44mthe quick brown fox[0m Red (on Blue background) -[32;44mthe quick brown fox[0m Green (on Blue background) -[33;44mthe quick brown fox[0m Yellow (on Blue background) -[34;44mthe quick brown fox[0m Blue (on Blue background) -[35;44mthe quick brown fox[0m Magenta (on Blue background) -[36;44mthe quick brown fox[0m Cyan (on Blue background) -[37;44mthe quick brown fox[0m White (on Blue background) -[30;45mthe quick brown fox[0m Black (on Magenta background) -[31;45mthe quick brown fox[0m Red (on Magenta background) -[32;45mthe quick brown fox[0m Green (on Magenta background) -[33;45mthe quick brown fox[0m Yellow (on Magenta background) -[34;45mthe quick brown fox[0m Blue (on Magenta background) -[35;45mthe quick brown fox[0m Magenta (on Magenta background) -[36;45mthe quick brown fox[0m Cyan (on Magenta background) -[37;45mthe quick brown fox[0m White (on Magenta background) -[30;46mthe quick brown fox[0m Black (on Cyan background) -[31;46mthe quick brown fox[0m Red (on Cyan background) -[32;46mthe quick brown fox[0m Green (on Cyan background) -[33;46mthe quick brown fox[0m Yellow (on Cyan background) -[34;46mthe quick brown fox[0m Blue (on Cyan background) -[35;46mthe quick brown fox[0m Magenta (on Cyan background) -[36;46mthe quick brown fox[0m Cyan (on Cyan background) -[37;46mthe quick brown fox[0m White (on Cyan background) -[30;47mthe quick brown fox[0m Black (on White background) -[31;47mthe quick brown fox[0m Red (on White background) -[32;47mthe quick brown fox[0m Green (on White background) -[33;47mthe quick brown fox[0m Yellow (on White background) -[34;47mthe quick brown fox[0m Blue (on White background) -[35;47mthe quick brown fox[0m Magenta (on White background) -[36;47mthe quick brown fox[0m Cyan (on White background) -[37;47mthe quick brown fox[0m White (on White background) - -2 colors 1 effect -[1;30;40mthe quick brown fox[0m Bright Black (on Black background) -[4;30;40mthe quick brown fox[0m Underline Black (on Black background) -[7;30;40mthe quick brown fox[0m Inverse Black (on Black background) -[1;31;40mthe quick brown fox[0m Bright Red (on Black background) -[4;31;40mthe quick brown fox[0m Underline Red (on Black background) -[7;31;40mthe quick brown fox[0m Inverse Red (on Black background) -[1;32;40mthe quick brown fox[0m Bright Green (on Black background) -[4;32;40mthe quick brown fox[0m Underline Green (on Black background) -[7;32;40mthe quick brown fox[0m Inverse Green (on Black background) -[1;33;40mthe quick brown fox[0m Bright Yellow (on Black background) -[4;33;40mthe quick brown fox[0m Underline Yellow (on Black background) -[7;33;40mthe quick brown fox[0m Inverse Yellow (on Black background) -[1;34;40mthe quick brown fox[0m Bright Blue (on Black background) -[4;34;40mthe quick brown fox[0m Underline Blue (on Black background) -[7;34;40mthe quick brown fox[0m Inverse Blue (on Black background) -[1;35;40mthe quick brown fox[0m Bright Magenta (on Black background) -[4;35;40mthe quick brown fox[0m Underline Magenta (on Black background) -[7;35;40mthe quick brown fox[0m Inverse Magenta (on Black background) -[1;36;40mthe quick brown fox[0m Bright Cyan (on Black background) -[4;36;40mthe quick brown fox[0m Underline Cyan (on Black background) -[7;36;40mthe quick brown fox[0m Inverse Cyan (on Black background) -[1;37;40mthe quick brown fox[0m Bright White (on Black background) -[4;37;40mthe quick brown fox[0m Underline White (on Black background) -[7;37;40mthe quick brown fox[0m Inverse White (on Black background) -[1;30;41mthe quick brown fox[0m Bright Black (on Red background) -[4;30;41mthe quick brown fox[0m Underline Black (on Red background) -[7;30;41mthe quick brown fox[0m Inverse Black (on Red background) -[1;31;41mthe quick brown fox[0m Bright Red (on Red background) -[4;31;41mthe quick brown fox[0m Underline Red (on Red background) -[7;31;41mthe quick brown fox[0m Inverse Red (on Red background) -[1;32;41mthe quick brown fox[0m Bright Green (on Red background) -[4;32;41mthe quick brown fox[0m Underline Green (on Red background) -[7;32;41mthe quick brown fox[0m Inverse Green (on Red background) -[1;33;41mthe quick brown fox[0m Bright Yellow (on Red background) -[4;33;41mthe quick brown fox[0m Underline Yellow (on Red background) -[7;33;41mthe quick brown fox[0m Inverse Yellow (on Red background) -[1;34;41mthe quick brown fox[0m Bright Blue (on Red background) -[4;34;41mthe quick brown fox[0m Underline Blue (on Red background) -[7;34;41mthe quick brown fox[0m Inverse Blue (on Red background) -[1;35;41mthe quick brown fox[0m Bright Magenta (on Red background) -[4;35;41mthe quick brown fox[0m Underline Magenta (on Red background) -[7;35;41mthe quick brown fox[0m Inverse Magenta (on Red background) -[1;36;41mthe quick brown fox[0m Bright Cyan (on Red background) -[4;36;41mthe quick brown fox[0m Underline Cyan (on Red background) -[7;36;41mthe quick brown fox[0m Inverse Cyan (on Red background) -[1;37;41mthe quick brown fox[0m Bright White (on Red background) -[4;37;41mthe quick brown fox[0m Underline White (on Red background) -[7;37;41mthe quick brown fox[0m Inverse White (on Red background) -[1;30;42mthe quick brown fox[0m Bright Black (on Green background) -[4;30;42mthe quick brown fox[0m Underline Black (on Green background) -[7;30;42mthe quick brown fox[0m Inverse Black (on Green background) -[1;31;42mthe quick brown fox[0m Bright Red (on Green background) -[4;31;42mthe quick brown fox[0m Underline Red (on Green background) -[7;31;42mthe quick brown fox[0m Inverse Red (on Green background) -[1;32;42mthe quick brown fox[0m Bright Green (on Green background) -[4;32;42mthe quick brown fox[0m Underline Green (on Green background) -[7;32;42mthe quick brown fox[0m Inverse Green (on Green background) -[1;33;42mthe quick brown fox[0m Bright Yellow (on Green background) -[4;33;42mthe quick brown fox[0m Underline Yellow (on Green background) -[7;33;42mthe quick brown fox[0m Inverse Yellow (on Green background) -[1;34;42mthe quick brown fox[0m Bright Blue (on Green background) -[4;34;42mthe quick brown fox[0m Underline Blue (on Green background) -[7;34;42mthe quick brown fox[0m Inverse Blue (on Green background) -[1;35;42mthe quick brown fox[0m Bright Magenta (on Green background) -[4;35;42mthe quick brown fox[0m Underline Magenta (on Green background) -[7;35;42mthe quick brown fox[0m Inverse Magenta (on Green background) -[1;36;42mthe quick brown fox[0m Bright Cyan (on Green background) -[4;36;42mthe quick brown fox[0m Underline Cyan (on Green background) -[7;36;42mthe quick brown fox[0m Inverse Cyan (on Green background) -[1;37;42mthe quick brown fox[0m Bright White (on Green background) -[4;37;42mthe quick brown fox[0m Underline White (on Green background) -[7;37;42mthe quick brown fox[0m Inverse White (on Green background) -[1;30;43mthe quick brown fox[0m Bright Black (on Yellow background) -[4;30;43mthe quick brown fox[0m Underline Black (on Yellow background) -[7;30;43mthe quick brown fox[0m Inverse Black (on Yellow background) -[1;31;43mthe quick brown fox[0m Bright Red (on Yellow background) -[4;31;43mthe quick brown fox[0m Underline Red (on Yellow background) -[7;31;43mthe quick brown fox[0m Inverse Red (on Yellow background) -[1;32;43mthe quick brown fox[0m Bright Green (on Yellow background) -[4;32;43mthe quick brown fox[0m Underline Green (on Yellow background) -[7;32;43mthe quick brown fox[0m Inverse Green (on Yellow background) -[1;33;43mthe quick brown fox[0m Bright Yellow (on Yellow background) -[4;33;43mthe quick brown fox[0m Underline Yellow (on Yellow background) -[7;33;43mthe quick brown fox[0m Inverse Yellow (on Yellow background) -[1;34;43mthe quick brown fox[0m Bright Blue (on Yellow background) -[4;34;43mthe quick brown fox[0m Underline Blue (on Yellow background) -[7;34;43mthe quick brown fox[0m Inverse Blue (on Yellow background) -[1;35;43mthe quick brown fox[0m Bright Magenta (on Yellow background) -[4;35;43mthe quick brown fox[0m Underline Magenta (on Yellow background) -[7;35;43mthe quick brown fox[0m Inverse Magenta (on Yellow background) -[1;36;43mthe quick brown fox[0m Bright Cyan (on Yellow background) -[4;36;43mthe quick brown fox[0m Underline Cyan (on Yellow background) -[7;36;43mthe quick brown fox[0m Inverse Cyan (on Yellow background) -[1;37;43mthe quick brown fox[0m Bright White (on Yellow background) -[4;37;43mthe quick brown fox[0m Underline White (on Yellow background) -[7;37;43mthe quick brown fox[0m Inverse White (on Yellow background) -[1;30;44mthe quick brown fox[0m Bright Black (on Blue background) -[4;30;44mthe quick brown fox[0m Underline Black (on Blue background) -[7;30;44mthe quick brown fox[0m Inverse Black (on Blue background) -[1;31;44mthe quick brown fox[0m Bright Red (on Blue background) -[4;31;44mthe quick brown fox[0m Underline Red (on Blue background) -[7;31;44mthe quick brown fox[0m Inverse Red (on Blue background) -[1;32;44mthe quick brown fox[0m Bright Green (on Blue background) -[4;32;44mthe quick brown fox[0m Underline Green (on Blue background) -[7;32;44mthe quick brown fox[0m Inverse Green (on Blue background) -[1;33;44mthe quick brown fox[0m Bright Yellow (on Blue background) -[4;33;44mthe quick brown fox[0m Underline Yellow (on Blue background) -[7;33;44mthe quick brown fox[0m Inverse Yellow (on Blue background) -[1;34;44mthe quick brown fox[0m Bright Blue (on Blue background) -[4;34;44mthe quick brown fox[0m Underline Blue (on Blue background) -[7;34;44mthe quick brown fox[0m Inverse Blue (on Blue background) -[1;35;44mthe quick brown fox[0m Bright Magenta (on Blue background) -[4;35;44mthe quick brown fox[0m Underline Magenta (on Blue background) -[7;35;44mthe quick brown fox[0m Inverse Magenta (on Blue background) -[1;36;44mthe quick brown fox[0m Bright Cyan (on Blue background) -[4;36;44mthe quick brown fox[0m Underline Cyan (on Blue background) -[7;36;44mthe quick brown fox[0m Inverse Cyan (on Blue background) -[1;37;44mthe quick brown fox[0m Bright White (on Blue background) -[4;37;44mthe quick brown fox[0m Underline White (on Blue background) -[7;37;44mthe quick brown fox[0m Inverse White (on Blue background) -[1;30;45mthe quick brown fox[0m Bright Black (on Magenta background) -[4;30;45mthe quick brown fox[0m Underline Black (on Magenta background) -[7;30;45mthe quick brown fox[0m Inverse Black (on Magenta background) -[1;31;45mthe quick brown fox[0m Bright Red (on Magenta background) -[4;31;45mthe quick brown fox[0m Underline Red (on Magenta background) -[7;31;45mthe quick brown fox[0m Inverse Red (on Magenta background) -[1;32;45mthe quick brown fox[0m Bright Green (on Magenta background) -[4;32;45mthe quick brown fox[0m Underline Green (on Magenta background) -[7;32;45mthe quick brown fox[0m Inverse Green (on Magenta background) -[1;33;45mthe quick brown fox[0m Bright Yellow (on Magenta background) -[4;33;45mthe quick brown fox[0m Underline Yellow (on Magenta background) -[7;33;45mthe quick brown fox[0m Inverse Yellow (on Magenta background) -[1;34;45mthe quick brown fox[0m Bright Blue (on Magenta background) -[4;34;45mthe quick brown fox[0m Underline Blue (on Magenta background) -[7;34;45mthe quick brown fox[0m Inverse Blue (on Magenta background) -[1;35;45mthe quick brown fox[0m Bright Magenta (on Magenta background) -[4;35;45mthe quick brown fox[0m Underline Magenta (on Magenta background) -[7;35;45mthe quick brown fox[0m Inverse Magenta (on Magenta background) -[1;36;45mthe quick brown fox[0m Bright Cyan (on Magenta background) -[4;36;45mthe quick brown fox[0m Underline Cyan (on Magenta background) -[7;36;45mthe quick brown fox[0m Inverse Cyan (on Magenta background) -[1;37;45mthe quick brown fox[0m Bright White (on Magenta background) -[4;37;45mthe quick brown fox[0m Underline White (on Magenta background) -[7;37;45mthe quick brown fox[0m Inverse White (on Magenta background) -[1;30;46mthe quick brown fox[0m Bright Black (on Cyan background) -[4;30;46mthe quick brown fox[0m Underline Black (on Cyan background) -[7;30;46mthe quick brown fox[0m Inverse Black (on Cyan background) -[1;31;46mthe quick brown fox[0m Bright Red (on Cyan background) -[4;31;46mthe quick brown fox[0m Underline Red (on Cyan background) -[7;31;46mthe quick brown fox[0m Inverse Red (on Cyan background) -[1;32;46mthe quick brown fox[0m Bright Green (on Cyan background) -[4;32;46mthe quick brown fox[0m Underline Green (on Cyan background) -[7;32;46mthe quick brown fox[0m Inverse Green (on Cyan background) -[1;33;46mthe quick brown fox[0m Bright Yellow (on Cyan background) -[4;33;46mthe quick brown fox[0m Underline Yellow (on Cyan background) -[7;33;46mthe quick brown fox[0m Inverse Yellow (on Cyan background) -[1;34;46mthe quick brown fox[0m Bright Blue (on Cyan background) -[4;34;46mthe quick brown fox[0m Underline Blue (on Cyan background) -[7;34;46mthe quick brown fox[0m Inverse Blue (on Cyan background) -[1;35;46mthe quick brown fox[0m Bright Magenta (on Cyan background) -[4;35;46mthe quick brown fox[0m Underline Magenta (on Cyan background) -[7;35;46mthe quick brown fox[0m Inverse Magenta (on Cyan background) -[1;36;46mthe quick brown fox[0m Bright Cyan (on Cyan background) -[4;36;46mthe quick brown fox[0m Underline Cyan (on Cyan background) -[7;36;46mthe quick brown fox[0m Inverse Cyan (on Cyan background) -[1;37;46mthe quick brown fox[0m Bright White (on Cyan background) -[4;37;46mthe quick brown fox[0m Underline White (on Cyan background) -[7;37;46mthe quick brown fox[0m Inverse White (on Cyan background) -[1;30;47mthe quick brown fox[0m Bright Black (on White background) -[4;30;47mthe quick brown fox[0m Underline Black (on White background) -[7;30;47mthe quick brown fox[0m Inverse Black (on White background) -[1;31;47mthe quick brown fox[0m Bright Red (on White background) -[4;31;47mthe quick brown fox[0m Underline Red (on White background) -[7;31;47mthe quick brown fox[0m Inverse Red (on White background) -[1;32;47mthe quick brown fox[0m Bright Green (on White background) -[4;32;47mthe quick brown fox[0m Underline Green (on White background) -[7;32;47mthe quick brown fox[0m Inverse Green (on White background) -[1;33;47mthe quick brown fox[0m Bright Yellow (on White background) -[4;33;47mthe quick brown fox[0m Underline Yellow (on White background) -[7;33;47mthe quick brown fox[0m Inverse Yellow (on White background) -[1;34;47mthe quick brown fox[0m Bright Blue (on White background) -[4;34;47mthe quick brown fox[0m Underline Blue (on White background) -[7;34;47mthe quick brown fox[0m Inverse Blue (on White background) -[1;35;47mthe quick brown fox[0m Bright Magenta (on White background) -[4;35;47mthe quick brown fox[0m Underline Magenta (on White background) -[7;35;47mthe quick brown fox[0m Inverse Magenta (on White background) -[1;36;47mthe quick brown fox[0m Bright Cyan (on White background) -[4;36;47mthe quick brown fox[0m Underline Cyan (on White background) -[7;36;47mthe quick brown fox[0m Inverse Cyan (on White background) -[1;37;47mthe quick brown fox[0m Bright White (on White background) -[4;37;47mthe quick brown fox[0m Underline White (on White background) -[7;37;47mthe quick brown fox[0m Inverse White (on White background) - -2 colors 2 effects -[1;4;30;40mthe quick brown fox[0m Bright Underline Black (on Black background) -[1;7;30;40mthe quick brown fox[0m Bright Inverse Black (on Black background) -[4;1;30;40mthe quick brown fox[0m Underline Bright Black (on Black background) -[4;7;30;40mthe quick brown fox[0m Underline Inverse Black (on Black background) -[7;1;30;40mthe quick brown fox[0m Inverse Bright Black (on Black background) -[7;4;30;40mthe quick brown fox[0m Inverse Underline Black (on Black background) -[1;4;31;40mthe quick brown fox[0m Bright Underline Red (on Black background) -[1;7;31;40mthe quick brown fox[0m Bright Inverse Red (on Black background) -[4;1;31;40mthe quick brown fox[0m Underline Bright Red (on Black background) -[4;7;31;40mthe quick brown fox[0m Underline Inverse Red (on Black background) -[7;1;31;40mthe quick brown fox[0m Inverse Bright Red (on Black background) -[7;4;31;40mthe quick brown fox[0m Inverse Underline Red (on Black background) -[1;4;32;40mthe quick brown fox[0m Bright Underline Green (on Black background) -[1;7;32;40mthe quick brown fox[0m Bright Inverse Green (on Black background) -[4;1;32;40mthe quick brown fox[0m Underline Bright Green (on Black background) -[4;7;32;40mthe quick brown fox[0m Underline Inverse Green (on Black background) -[7;1;32;40mthe quick brown fox[0m Inverse Bright Green (on Black background) -[7;4;32;40mthe quick brown fox[0m Inverse Underline Green (on Black background) -[1;4;33;40mthe quick brown fox[0m Bright Underline Yellow (on Black background) -[1;7;33;40mthe quick brown fox[0m Bright Inverse Yellow (on Black background) -[4;1;33;40mthe quick brown fox[0m Underline Bright Yellow (on Black background) -[4;7;33;40mthe quick brown fox[0m Underline Inverse Yellow (on Black background) -[7;1;33;40mthe quick brown fox[0m Inverse Bright Yellow (on Black background) -[7;4;33;40mthe quick brown fox[0m Inverse Underline Yellow (on Black background) -[1;4;34;40mthe quick brown fox[0m Bright Underline Blue (on Black background) -[1;7;34;40mthe quick brown fox[0m Bright Inverse Blue (on Black background) -[4;1;34;40mthe quick brown fox[0m Underline Bright Blue (on Black background) -[4;7;34;40mthe quick brown fox[0m Underline Inverse Blue (on Black background) -[7;1;34;40mthe quick brown fox[0m Inverse Bright Blue (on Black background) -[7;4;34;40mthe quick brown fox[0m Inverse Underline Blue (on Black background) -[1;4;35;40mthe quick brown fox[0m Bright Underline Magenta (on Black background) -[1;7;35;40mthe quick brown fox[0m Bright Inverse Magenta (on Black background) -[4;1;35;40mthe quick brown fox[0m Underline Bright Magenta (on Black background) -[4;7;35;40mthe quick brown fox[0m Underline Inverse Magenta (on Black background) -[7;1;35;40mthe quick brown fox[0m Inverse Bright Magenta (on Black background) -[7;4;35;40mthe quick brown fox[0m Inverse Underline Magenta (on Black background) -[1;4;36;40mthe quick brown fox[0m Bright Underline Cyan (on Black background) -[1;7;36;40mthe quick brown fox[0m Bright Inverse Cyan (on Black background) -[4;1;36;40mthe quick brown fox[0m Underline Bright Cyan (on Black background) -[4;7;36;40mthe quick brown fox[0m Underline Inverse Cyan (on Black background) -[7;1;36;40mthe quick brown fox[0m Inverse Bright Cyan (on Black background) -[7;4;36;40mthe quick brown fox[0m Inverse Underline Cyan (on Black background) -[1;4;37;40mthe quick brown fox[0m Bright Underline White (on Black background) -[1;7;37;40mthe quick brown fox[0m Bright Inverse White (on Black background) -[4;1;37;40mthe quick brown fox[0m Underline Bright White (on Black background) -[4;7;37;40mthe quick brown fox[0m Underline Inverse White (on Black background) -[7;1;37;40mthe quick brown fox[0m Inverse Bright White (on Black background) -[7;4;37;40mthe quick brown fox[0m Inverse Underline White (on Black background) -[1;4;30;41mthe quick brown fox[0m Bright Underline Black (on Red background) -[1;7;30;41mthe quick brown fox[0m Bright Inverse Black (on Red background) -[4;1;30;41mthe quick brown fox[0m Underline Bright Black (on Red background) -[4;7;30;41mthe quick brown fox[0m Underline Inverse Black (on Red background) -[7;1;30;41mthe quick brown fox[0m Inverse Bright Black (on Red background) -[7;4;30;41mthe quick brown fox[0m Inverse Underline Black (on Red background) -[1;4;31;41mthe quick brown fox[0m Bright Underline Red (on Red background) -[1;7;31;41mthe quick brown fox[0m Bright Inverse Red (on Red background) -[4;1;31;41mthe quick brown fox[0m Underline Bright Red (on Red background) -[4;7;31;41mthe quick brown fox[0m Underline Inverse Red (on Red background) -[7;1;31;41mthe quick brown fox[0m Inverse Bright Red (on Red background) -[7;4;31;41mthe quick brown fox[0m Inverse Underline Red (on Red background) -[1;4;32;41mthe quick brown fox[0m Bright Underline Green (on Red background) -[1;7;32;41mthe quick brown fox[0m Bright Inverse Green (on Red background) -[4;1;32;41mthe quick brown fox[0m Underline Bright Green (on Red background) -[4;7;32;41mthe quick brown fox[0m Underline Inverse Green (on Red background) -[7;1;32;41mthe quick brown fox[0m Inverse Bright Green (on Red background) -[7;4;32;41mthe quick brown fox[0m Inverse Underline Green (on Red background) -[1;4;33;41mthe quick brown fox[0m Bright Underline Yellow (on Red background) -[1;7;33;41mthe quick brown fox[0m Bright Inverse Yellow (on Red background) -[4;1;33;41mthe quick brown fox[0m Underline Bright Yellow (on Red background) -[4;7;33;41mthe quick brown fox[0m Underline Inverse Yellow (on Red background) -[7;1;33;41mthe quick brown fox[0m Inverse Bright Yellow (on Red background) -[7;4;33;41mthe quick brown fox[0m Inverse Underline Yellow (on Red background) -[1;4;34;41mthe quick brown fox[0m Bright Underline Blue (on Red background) -[1;7;34;41mthe quick brown fox[0m Bright Inverse Blue (on Red background) -[4;1;34;41mthe quick brown fox[0m Underline Bright Blue (on Red background) -[4;7;34;41mthe quick brown fox[0m Underline Inverse Blue (on Red background) -[7;1;34;41mthe quick brown fox[0m Inverse Bright Blue (on Red background) -[7;4;34;41mthe quick brown fox[0m Inverse Underline Blue (on Red background) -[1;4;35;41mthe quick brown fox[0m Bright Underline Magenta (on Red background) -[1;7;35;41mthe quick brown fox[0m Bright Inverse Magenta (on Red background) -[4;1;35;41mthe quick brown fox[0m Underline Bright Magenta (on Red background) -[4;7;35;41mthe quick brown fox[0m Underline Inverse Magenta (on Red background) -[7;1;35;41mthe quick brown fox[0m Inverse Bright Magenta (on Red background) -[7;4;35;41mthe quick brown fox[0m Inverse Underline Magenta (on Red background) -[1;4;36;41mthe quick brown fox[0m Bright Underline Cyan (on Red background) -[1;7;36;41mthe quick brown fox[0m Bright Inverse Cyan (on Red background) -[4;1;36;41mthe quick brown fox[0m Underline Bright Cyan (on Red background) -[4;7;36;41mthe quick brown fox[0m Underline Inverse Cyan (on Red background) -[7;1;36;41mthe quick brown fox[0m Inverse Bright Cyan (on Red background) -[7;4;36;41mthe quick brown fox[0m Inverse Underline Cyan (on Red background) -[1;4;37;41mthe quick brown fox[0m Bright Underline White (on Red background) -[1;7;37;41mthe quick brown fox[0m Bright Inverse White (on Red background) -[4;1;37;41mthe quick brown fox[0m Underline Bright White (on Red background) -[4;7;37;41mthe quick brown fox[0m Underline Inverse White (on Red background) -[7;1;37;41mthe quick brown fox[0m Inverse Bright White (on Red background) -[7;4;37;41mthe quick brown fox[0m Inverse Underline White (on Red background) -[1;4;30;42mthe quick brown fox[0m Bright Underline Black (on Green background) -[1;7;30;42mthe quick brown fox[0m Bright Inverse Black (on Green background) -[4;1;30;42mthe quick brown fox[0m Underline Bright Black (on Green background) -[4;7;30;42mthe quick brown fox[0m Underline Inverse Black (on Green background) -[7;1;30;42mthe quick brown fox[0m Inverse Bright Black (on Green background) -[7;4;30;42mthe quick brown fox[0m Inverse Underline Black (on Green background) -[1;4;31;42mthe quick brown fox[0m Bright Underline Red (on Green background) -[1;7;31;42mthe quick brown fox[0m Bright Inverse Red (on Green background) -[4;1;31;42mthe quick brown fox[0m Underline Bright Red (on Green background) -[4;7;31;42mthe quick brown fox[0m Underline Inverse Red (on Green background) -[7;1;31;42mthe quick brown fox[0m Inverse Bright Red (on Green background) -[7;4;31;42mthe quick brown fox[0m Inverse Underline Red (on Green background) -[1;4;32;42mthe quick brown fox[0m Bright Underline Green (on Green background) -[1;7;32;42mthe quick brown fox[0m Bright Inverse Green (on Green background) -[4;1;32;42mthe quick brown fox[0m Underline Bright Green (on Green background) -[4;7;32;42mthe quick brown fox[0m Underline Inverse Green (on Green background) -[7;1;32;42mthe quick brown fox[0m Inverse Bright Green (on Green background) -[7;4;32;42mthe quick brown fox[0m Inverse Underline Green (on Green background) -[1;4;33;42mthe quick brown fox[0m Bright Underline Yellow (on Green background) -[1;7;33;42mthe quick brown fox[0m Bright Inverse Yellow (on Green background) -[4;1;33;42mthe quick brown fox[0m Underline Bright Yellow (on Green background) -[4;7;33;42mthe quick brown fox[0m Underline Inverse Yellow (on Green background) -[7;1;33;42mthe quick brown fox[0m Inverse Bright Yellow (on Green background) -[7;4;33;42mthe quick brown fox[0m Inverse Underline Yellow (on Green background) -[1;4;34;42mthe quick brown fox[0m Bright Underline Blue (on Green background) -[1;7;34;42mthe quick brown fox[0m Bright Inverse Blue (on Green background) -[4;1;34;42mthe quick brown fox[0m Underline Bright Blue (on Green background) -[4;7;34;42mthe quick brown fox[0m Underline Inverse Blue (on Green background) -[7;1;34;42mthe quick brown fox[0m Inverse Bright Blue (on Green background) -[7;4;34;42mthe quick brown fox[0m Inverse Underline Blue (on Green background) -[1;4;35;42mthe quick brown fox[0m Bright Underline Magenta (on Green background) -[1;7;35;42mthe quick brown fox[0m Bright Inverse Magenta (on Green background) -[4;1;35;42mthe quick brown fox[0m Underline Bright Magenta (on Green background) -[4;7;35;42mthe quick brown fox[0m Underline Inverse Magenta (on Green background) -[7;1;35;42mthe quick brown fox[0m Inverse Bright Magenta (on Green background) -[7;4;35;42mthe quick brown fox[0m Inverse Underline Magenta (on Green background) -[1;4;36;42mthe quick brown fox[0m Bright Underline Cyan (on Green background) -[1;7;36;42mthe quick brown fox[0m Bright Inverse Cyan (on Green background) -[4;1;36;42mthe quick brown fox[0m Underline Bright Cyan (on Green background) -[4;7;36;42mthe quick brown fox[0m Underline Inverse Cyan (on Green background) -[7;1;36;42mthe quick brown fox[0m Inverse Bright Cyan (on Green background) -[7;4;36;42mthe quick brown fox[0m Inverse Underline Cyan (on Green background) -[1;4;37;42mthe quick brown fox[0m Bright Underline White (on Green background) -[1;7;37;42mthe quick brown fox[0m Bright Inverse White (on Green background) -[4;1;37;42mthe quick brown fox[0m Underline Bright White (on Green background) -[4;7;37;42mthe quick brown fox[0m Underline Inverse White (on Green background) -[7;1;37;42mthe quick brown fox[0m Inverse Bright White (on Green background) -[7;4;37;42mthe quick brown fox[0m Inverse Underline White (on Green background) -[1;4;30;43mthe quick brown fox[0m Bright Underline Black (on Yellow background) -[1;7;30;43mthe quick brown fox[0m Bright Inverse Black (on Yellow background) -[4;1;30;43mthe quick brown fox[0m Underline Bright Black (on Yellow background) -[4;7;30;43mthe quick brown fox[0m Underline Inverse Black (on Yellow background) -[7;1;30;43mthe quick brown fox[0m Inverse Bright Black (on Yellow background) -[7;4;30;43mthe quick brown fox[0m Inverse Underline Black (on Yellow background) -[1;4;31;43mthe quick brown fox[0m Bright Underline Red (on Yellow background) -[1;7;31;43mthe quick brown fox[0m Bright Inverse Red (on Yellow background) -[4;1;31;43mthe quick brown fox[0m Underline Bright Red (on Yellow background) -[4;7;31;43mthe quick brown fox[0m Underline Inverse Red (on Yellow background) -[7;1;31;43mthe quick brown fox[0m Inverse Bright Red (on Yellow background) -[7;4;31;43mthe quick brown fox[0m Inverse Underline Red (on Yellow background) -[1;4;32;43mthe quick brown fox[0m Bright Underline Green (on Yellow background) -[1;7;32;43mthe quick brown fox[0m Bright Inverse Green (on Yellow background) -[4;1;32;43mthe quick brown fox[0m Underline Bright Green (on Yellow background) -[4;7;32;43mthe quick brown fox[0m Underline Inverse Green (on Yellow background) -[7;1;32;43mthe quick brown fox[0m Inverse Bright Green (on Yellow background) -[7;4;32;43mthe quick brown fox[0m Inverse Underline Green (on Yellow background) -[1;4;33;43mthe quick brown fox[0m Bright Underline Yellow (on Yellow background) -[1;7;33;43mthe quick brown fox[0m Bright Inverse Yellow (on Yellow background) -[4;1;33;43mthe quick brown fox[0m Underline Bright Yellow (on Yellow background) -[4;7;33;43mthe quick brown fox[0m Underline Inverse Yellow (on Yellow background) -[7;1;33;43mthe quick brown fox[0m Inverse Bright Yellow (on Yellow background) -[7;4;33;43mthe quick brown fox[0m Inverse Underline Yellow (on Yellow background) -[1;4;34;43mthe quick brown fox[0m Bright Underline Blue (on Yellow background) -[1;7;34;43mthe quick brown fox[0m Bright Inverse Blue (on Yellow background) -[4;1;34;43mthe quick brown fox[0m Underline Bright Blue (on Yellow background) -[4;7;34;43mthe quick brown fox[0m Underline Inverse Blue (on Yellow background) -[7;1;34;43mthe quick brown fox[0m Inverse Bright Blue (on Yellow background) -[7;4;34;43mthe quick brown fox[0m Inverse Underline Blue (on Yellow background) -[1;4;35;43mthe quick brown fox[0m Bright Underline Magenta (on Yellow background) -[1;7;35;43mthe quick brown fox[0m Bright Inverse Magenta (on Yellow background) -[4;1;35;43mthe quick brown fox[0m Underline Bright Magenta (on Yellow background) -[4;7;35;43mthe quick brown fox[0m Underline Inverse Magenta (on Yellow background) -[7;1;35;43mthe quick brown fox[0m Inverse Bright Magenta (on Yellow background) -[7;4;35;43mthe quick brown fox[0m Inverse Underline Magenta (on Yellow background) -[1;4;36;43mthe quick brown fox[0m Bright Underline Cyan (on Yellow background) -[1;7;36;43mthe quick brown fox[0m Bright Inverse Cyan (on Yellow background) -[4;1;36;43mthe quick brown fox[0m Underline Bright Cyan (on Yellow background) -[4;7;36;43mthe quick brown fox[0m Underline Inverse Cyan (on Yellow background) -[7;1;36;43mthe quick brown fox[0m Inverse Bright Cyan (on Yellow background) -[7;4;36;43mthe quick brown fox[0m Inverse Underline Cyan (on Yellow background) -[1;4;37;43mthe quick brown fox[0m Bright Underline White (on Yellow background) -[1;7;37;43mthe quick brown fox[0m Bright Inverse White (on Yellow background) -[4;1;37;43mthe quick brown fox[0m Underline Bright White (on Yellow background) -[4;7;37;43mthe quick brown fox[0m Underline Inverse White (on Yellow background) -[7;1;37;43mthe quick brown fox[0m Inverse Bright White (on Yellow background) -[7;4;37;43mthe quick brown fox[0m Inverse Underline White (on Yellow background) -[1;4;30;44mthe quick brown fox[0m Bright Underline Black (on Blue background) -[1;7;30;44mthe quick brown fox[0m Bright Inverse Black (on Blue background) -[4;1;30;44mthe quick brown fox[0m Underline Bright Black (on Blue background) -[4;7;30;44mthe quick brown fox[0m Underline Inverse Black (on Blue background) -[7;1;30;44mthe quick brown fox[0m Inverse Bright Black (on Blue background) -[7;4;30;44mthe quick brown fox[0m Inverse Underline Black (on Blue background) -[1;4;31;44mthe quick brown fox[0m Bright Underline Red (on Blue background) -[1;7;31;44mthe quick brown fox[0m Bright Inverse Red (on Blue background) -[4;1;31;44mthe quick brown fox[0m Underline Bright Red (on Blue background) -[4;7;31;44mthe quick brown fox[0m Underline Inverse Red (on Blue background) -[7;1;31;44mthe quick brown fox[0m Inverse Bright Red (on Blue background) -[7;4;31;44mthe quick brown fox[0m Inverse Underline Red (on Blue background) -[1;4;32;44mthe quick brown fox[0m Bright Underline Green (on Blue background) -[1;7;32;44mthe quick brown fox[0m Bright Inverse Green (on Blue background) -[4;1;32;44mthe quick brown fox[0m Underline Bright Green (on Blue background) -[4;7;32;44mthe quick brown fox[0m Underline Inverse Green (on Blue background) -[7;1;32;44mthe quick brown fox[0m Inverse Bright Green (on Blue background) -[7;4;32;44mthe quick brown fox[0m Inverse Underline Green (on Blue background) -[1;4;33;44mthe quick brown fox[0m Bright Underline Yellow (on Blue background) -[1;7;33;44mthe quick brown fox[0m Bright Inverse Yellow (on Blue background) -[4;1;33;44mthe quick brown fox[0m Underline Bright Yellow (on Blue background) -[4;7;33;44mthe quick brown fox[0m Underline Inverse Yellow (on Blue background) -[7;1;33;44mthe quick brown fox[0m Inverse Bright Yellow (on Blue background) -[7;4;33;44mthe quick brown fox[0m Inverse Underline Yellow (on Blue background) -[1;4;34;44mthe quick brown fox[0m Bright Underline Blue (on Blue background) -[1;7;34;44mthe quick brown fox[0m Bright Inverse Blue (on Blue background) -[4;1;34;44mthe quick brown fox[0m Underline Bright Blue (on Blue background) -[4;7;34;44mthe quick brown fox[0m Underline Inverse Blue (on Blue background) -[7;1;34;44mthe quick brown fox[0m Inverse Bright Blue (on Blue background) -[7;4;34;44mthe quick brown fox[0m Inverse Underline Blue (on Blue background) -[1;4;35;44mthe quick brown fox[0m Bright Underline Magenta (on Blue background) -[1;7;35;44mthe quick brown fox[0m Bright Inverse Magenta (on Blue background) -[4;1;35;44mthe quick brown fox[0m Underline Bright Magenta (on Blue background) -[4;7;35;44mthe quick brown fox[0m Underline Inverse Magenta (on Blue background) -[7;1;35;44mthe quick brown fox[0m Inverse Bright Magenta (on Blue background) -[7;4;35;44mthe quick brown fox[0m Inverse Underline Magenta (on Blue background) -[1;4;36;44mthe quick brown fox[0m Bright Underline Cyan (on Blue background) -[1;7;36;44mthe quick brown fox[0m Bright Inverse Cyan (on Blue background) -[4;1;36;44mthe quick brown fox[0m Underline Bright Cyan (on Blue background) -[4;7;36;44mthe quick brown fox[0m Underline Inverse Cyan (on Blue background) -[7;1;36;44mthe quick brown fox[0m Inverse Bright Cyan (on Blue background) -[7;4;36;44mthe quick brown fox[0m Inverse Underline Cyan (on Blue background) -[1;4;37;44mthe quick brown fox[0m Bright Underline White (on Blue background) -[1;7;37;44mthe quick brown fox[0m Bright Inverse White (on Blue background) -[4;1;37;44mthe quick brown fox[0m Underline Bright White (on Blue background) -[4;7;37;44mthe quick brown fox[0m Underline Inverse White (on Blue background) -[7;1;37;44mthe quick brown fox[0m Inverse Bright White (on Blue background) -[7;4;37;44mthe quick brown fox[0m Inverse Underline White (on Blue background) -[1;4;30;45mthe quick brown fox[0m Bright Underline Black (on Magenta background) -[1;7;30;45mthe quick brown fox[0m Bright Inverse Black (on Magenta background) -[4;1;30;45mthe quick brown fox[0m Underline Bright Black (on Magenta background) -[4;7;30;45mthe quick brown fox[0m Underline Inverse Black (on Magenta background) -[7;1;30;45mthe quick brown fox[0m Inverse Bright Black (on Magenta background) -[7;4;30;45mthe quick brown fox[0m Inverse Underline Black (on Magenta background) -[1;4;31;45mthe quick brown fox[0m Bright Underline Red (on Magenta background) -[1;7;31;45mthe quick brown fox[0m Bright Inverse Red (on Magenta background) -[4;1;31;45mthe quick brown fox[0m Underline Bright Red (on Magenta background) -[4;7;31;45mthe quick brown fox[0m Underline Inverse Red (on Magenta background) -[7;1;31;45mthe quick brown fox[0m Inverse Bright Red (on Magenta background) -[7;4;31;45mthe quick brown fox[0m Inverse Underline Red (on Magenta background) -[1;4;32;45mthe quick brown fox[0m Bright Underline Green (on Magenta background) -[1;7;32;45mthe quick brown fox[0m Bright Inverse Green (on Magenta background) -[4;1;32;45mthe quick brown fox[0m Underline Bright Green (on Magenta background) -[4;7;32;45mthe quick brown fox[0m Underline Inverse Green (on Magenta background) -[7;1;32;45mthe quick brown fox[0m Inverse Bright Green (on Magenta background) -[7;4;32;45mthe quick brown fox[0m Inverse Underline Green (on Magenta background) -[1;4;33;45mthe quick brown fox[0m Bright Underline Yellow (on Magenta background) -[1;7;33;45mthe quick brown fox[0m Bright Inverse Yellow (on Magenta background) -[4;1;33;45mthe quick brown fox[0m Underline Bright Yellow (on Magenta background) -[4;7;33;45mthe quick brown fox[0m Underline Inverse Yellow (on Magenta background) -[7;1;33;45mthe quick brown fox[0m Inverse Bright Yellow (on Magenta background) -[7;4;33;45mthe quick brown fox[0m Inverse Underline Yellow (on Magenta background) -[1;4;34;45mthe quick brown fox[0m Bright Underline Blue (on Magenta background) -[1;7;34;45mthe quick brown fox[0m Bright Inverse Blue (on Magenta background) -[4;1;34;45mthe quick brown fox[0m Underline Bright Blue (on Magenta background) -[4;7;34;45mthe quick brown fox[0m Underline Inverse Blue (on Magenta background) -[7;1;34;45mthe quick brown fox[0m Inverse Bright Blue (on Magenta background) -[7;4;34;45mthe quick brown fox[0m Inverse Underline Blue (on Magenta background) -[1;4;35;45mthe quick brown fox[0m Bright Underline Magenta (on Magenta background) -[1;7;35;45mthe quick brown fox[0m Bright Inverse Magenta (on Magenta background) -[4;1;35;45mthe quick brown fox[0m Underline Bright Magenta (on Magenta background) -[4;7;35;45mthe quick brown fox[0m Underline Inverse Magenta (on Magenta background) -[7;1;35;45mthe quick brown fox[0m Inverse Bright Magenta (on Magenta background) -[7;4;35;45mthe quick brown fox[0m Inverse Underline Magenta (on Magenta background) -[1;4;36;45mthe quick brown fox[0m Bright Underline Cyan (on Magenta background) -[1;7;36;45mthe quick brown fox[0m Bright Inverse Cyan (on Magenta background) -[4;1;36;45mthe quick brown fox[0m Underline Bright Cyan (on Magenta background) -[4;7;36;45mthe quick brown fox[0m Underline Inverse Cyan (on Magenta background) -[7;1;36;45mthe quick brown fox[0m Inverse Bright Cyan (on Magenta background) -[7;4;36;45mthe quick brown fox[0m Inverse Underline Cyan (on Magenta background) -[1;4;37;45mthe quick brown fox[0m Bright Underline White (on Magenta background) -[1;7;37;45mthe quick brown fox[0m Bright Inverse White (on Magenta background) -[4;1;37;45mthe quick brown fox[0m Underline Bright White (on Magenta background) -[4;7;37;45mthe quick brown fox[0m Underline Inverse White (on Magenta background) -[7;1;37;45mthe quick brown fox[0m Inverse Bright White (on Magenta background) -[7;4;37;45mthe quick brown fox[0m Inverse Underline White (on Magenta background) -[1;4;30;46mthe quick brown fox[0m Bright Underline Black (on Cyan background) -[1;7;30;46mthe quick brown fox[0m Bright Inverse Black (on Cyan background) -[4;1;30;46mthe quick brown fox[0m Underline Bright Black (on Cyan background) -[4;7;30;46mthe quick brown fox[0m Underline Inverse Black (on Cyan background) -[7;1;30;46mthe quick brown fox[0m Inverse Bright Black (on Cyan background) -[7;4;30;46mthe quick brown fox[0m Inverse Underline Black (on Cyan background) -[1;4;31;46mthe quick brown fox[0m Bright Underline Red (on Cyan background) -[1;7;31;46mthe quick brown fox[0m Bright Inverse Red (on Cyan background) -[4;1;31;46mthe quick brown fox[0m Underline Bright Red (on Cyan background) -[4;7;31;46mthe quick brown fox[0m Underline Inverse Red (on Cyan background) -[7;1;31;46mthe quick brown fox[0m Inverse Bright Red (on Cyan background) -[7;4;31;46mthe quick brown fox[0m Inverse Underline Red (on Cyan background) -[1;4;32;46mthe quick brown fox[0m Bright Underline Green (on Cyan background) -[1;7;32;46mthe quick brown fox[0m Bright Inverse Green (on Cyan background) -[4;1;32;46mthe quick brown fox[0m Underline Bright Green (on Cyan background) -[4;7;32;46mthe quick brown fox[0m Underline Inverse Green (on Cyan background) -[7;1;32;46mthe quick brown fox[0m Inverse Bright Green (on Cyan background) -[7;4;32;46mthe quick brown fox[0m Inverse Underline Green (on Cyan background) -[1;4;33;46mthe quick brown fox[0m Bright Underline Yellow (on Cyan background) -[1;7;33;46mthe quick brown fox[0m Bright Inverse Yellow (on Cyan background) -[4;1;33;46mthe quick brown fox[0m Underline Bright Yellow (on Cyan background) -[4;7;33;46mthe quick brown fox[0m Underline Inverse Yellow (on Cyan background) -[7;1;33;46mthe quick brown fox[0m Inverse Bright Yellow (on Cyan background) -[7;4;33;46mthe quick brown fox[0m Inverse Underline Yellow (on Cyan background) -[1;4;34;46mthe quick brown fox[0m Bright Underline Blue (on Cyan background) -[1;7;34;46mthe quick brown fox[0m Bright Inverse Blue (on Cyan background) -[4;1;34;46mthe quick brown fox[0m Underline Bright Blue (on Cyan background) -[4;7;34;46mthe quick brown fox[0m Underline Inverse Blue (on Cyan background) -[7;1;34;46mthe quick brown fox[0m Inverse Bright Blue (on Cyan background) -[7;4;34;46mthe quick brown fox[0m Inverse Underline Blue (on Cyan background) -[1;4;35;46mthe quick brown fox[0m Bright Underline Magenta (on Cyan background) -[1;7;35;46mthe quick brown fox[0m Bright Inverse Magenta (on Cyan background) -[4;1;35;46mthe quick brown fox[0m Underline Bright Magenta (on Cyan background) -[4;7;35;46mthe quick brown fox[0m Underline Inverse Magenta (on Cyan background) -[7;1;35;46mthe quick brown fox[0m Inverse Bright Magenta (on Cyan background) -[7;4;35;46mthe quick brown fox[0m Inverse Underline Magenta (on Cyan background) -[1;4;36;46mthe quick brown fox[0m Bright Underline Cyan (on Cyan background) -[1;7;36;46mthe quick brown fox[0m Bright Inverse Cyan (on Cyan background) -[4;1;36;46mthe quick brown fox[0m Underline Bright Cyan (on Cyan background) -[4;7;36;46mthe quick brown fox[0m Underline Inverse Cyan (on Cyan background) -[7;1;36;46mthe quick brown fox[0m Inverse Bright Cyan (on Cyan background) -[7;4;36;46mthe quick brown fox[0m Inverse Underline Cyan (on Cyan background) -[1;4;37;46mthe quick brown fox[0m Bright Underline White (on Cyan background) -[1;7;37;46mthe quick brown fox[0m Bright Inverse White (on Cyan background) -[4;1;37;46mthe quick brown fox[0m Underline Bright White (on Cyan background) -[4;7;37;46mthe quick brown fox[0m Underline Inverse White (on Cyan background) -[7;1;37;46mthe quick brown fox[0m Inverse Bright White (on Cyan background) -[7;4;37;46mthe quick brown fox[0m Inverse Underline White (on Cyan background) -[1;4;30;47mthe quick brown fox[0m Bright Underline Black (on White background) -[1;7;30;47mthe quick brown fox[0m Bright Inverse Black (on White background) -[4;1;30;47mthe quick brown fox[0m Underline Bright Black (on White background) -[4;7;30;47mthe quick brown fox[0m Underline Inverse Black (on White background) -[7;1;30;47mthe quick brown fox[0m Inverse Bright Black (on White background) -[7;4;30;47mthe quick brown fox[0m Inverse Underline Black (on White background) -[1;4;31;47mthe quick brown fox[0m Bright Underline Red (on White background) -[1;7;31;47mthe quick brown fox[0m Bright Inverse Red (on White background) -[4;1;31;47mthe quick brown fox[0m Underline Bright Red (on White background) -[4;7;31;47mthe quick brown fox[0m Underline Inverse Red (on White background) -[7;1;31;47mthe quick brown fox[0m Inverse Bright Red (on White background) -[7;4;31;47mthe quick brown fox[0m Inverse Underline Red (on White background) -[1;4;32;47mthe quick brown fox[0m Bright Underline Green (on White background) -[1;7;32;47mthe quick brown fox[0m Bright Inverse Green (on White background) -[4;1;32;47mthe quick brown fox[0m Underline Bright Green (on White background) -[4;7;32;47mthe quick brown fox[0m Underline Inverse Green (on White background) -[7;1;32;47mthe quick brown fox[0m Inverse Bright Green (on White background) -[7;4;32;47mthe quick brown fox[0m Inverse Underline Green (on White background) -[1;4;33;47mthe quick brown fox[0m Bright Underline Yellow (on White background) -[1;7;33;47mthe quick brown fox[0m Bright Inverse Yellow (on White background) -[4;1;33;47mthe quick brown fox[0m Underline Bright Yellow (on White background) -[4;7;33;47mthe quick brown fox[0m Underline Inverse Yellow (on White background) -[7;1;33;47mthe quick brown fox[0m Inverse Bright Yellow (on White background) -[7;4;33;47mthe quick brown fox[0m Inverse Underline Yellow (on White background) -[1;4;34;47mthe quick brown fox[0m Bright Underline Blue (on White background) -[1;7;34;47mthe quick brown fox[0m Bright Inverse Blue (on White background) -[4;1;34;47mthe quick brown fox[0m Underline Bright Blue (on White background) -[4;7;34;47mthe quick brown fox[0m Underline Inverse Blue (on White background) -[7;1;34;47mthe quick brown fox[0m Inverse Bright Blue (on White background) -[7;4;34;47mthe quick brown fox[0m Inverse Underline Blue (on White background) -[1;4;35;47mthe quick brown fox[0m Bright Underline Magenta (on White background) -[1;7;35;47mthe quick brown fox[0m Bright Inverse Magenta (on White background) -[4;1;35;47mthe quick brown fox[0m Underline Bright Magenta (on White background) -[4;7;35;47mthe quick brown fox[0m Underline Inverse Magenta (on White background) -[7;1;35;47mthe quick brown fox[0m Inverse Bright Magenta (on White background) -[7;4;35;47mthe quick brown fox[0m Inverse Underline Magenta (on White background) -[1;4;36;47mthe quick brown fox[0m Bright Underline Cyan (on White background) -[1;7;36;47mthe quick brown fox[0m Bright Inverse Cyan (on White background) -[4;1;36;47mthe quick brown fox[0m Underline Bright Cyan (on White background) -[4;7;36;47mthe quick brown fox[0m Underline Inverse Cyan (on White background) -[7;1;36;47mthe quick brown fox[0m Inverse Bright Cyan (on White background) -[7;4;36;47mthe quick brown fox[0m Inverse Underline Cyan (on White background) -[1;4;37;47mthe quick brown fox[0m Bright Underline White (on White background) -[1;7;37;47mthe quick brown fox[0m Bright Inverse White (on White background) -[4;1;37;47mthe quick brown fox[0m Underline Bright White (on White background) -[4;7;37;47mthe quick brown fox[0m Underline Inverse White (on White background) -[7;1;37;47mthe quick brown fox[0m Inverse Bright White (on White background) -[7;4;37;47mthe quick brown fox[0m Inverse Underline White (on White background) diff --git a/test/files/run/color.scala b/test/files/run/color.scala deleted file mode 100644 index a0af8477e7..0000000000 --- a/test/files/run/color.scala +++ /dev/null @@ -1,33 +0,0 @@ -import scala.tools.util.color._ - -object Test { - // The ones which are somewhat widely supported. - def effects = List(Bright, Underline, Inverse) - - def demo(text: String) = { - def to_s(esc: Ansi): String = esc.atoms map { - case x: AnsiBackground => "" + x - case x => "%-10s" format x - } mkString " " - - def show(esc: Ansi) = println("%s %s".format(text in esc, to_s(esc))) - - println("\n1 color") - for (c <- Ansi.colors) show(c) - println("\n1 effect") - for (e <- Ansi.effects) show(e) - println("\n1 color 1 effect") - for (c <- Ansi.colors; e <- effects) show(c / e) - println("\n2 colors 0 effects") - for (c1 <- Ansi.colors ; c2 <- Ansi.colors) show(c2 on c1) - println("\n2 colors 1 effect") - for (c1 <- Ansi.colors ; c2 <- Ansi.colors ; e1 <- effects) show((c2 on c1) / e1) - println("\n2 colors 2 effects") - for (c1 <- Ansi.colors ; c2 <- Ansi.colors ; e1 <- effects ; e2 <- effects ; if e1 != e2) show((c2 on c1) / e1 / e2) - } - - def main(args: Array[String]): Unit = { - val str = if (args.size > 1) args mkString " " else "the quick brown fox" - demo(str) - } -} diff --git a/test/files/run/groundtypetags_core.check b/test/files/run/concretetypetags_core.check index 62fcb481ae..f124aa6a35 100644 --- a/test/files/run/groundtypetags_core.check +++ b/test/files/run/concretetypetags_core.check @@ -1,30 +1,32 @@ -true
-ConcreteTypeTag[Byte]
-true
-ConcreteTypeTag[Short]
-true
-ConcreteTypeTag[Char]
-true
-ConcreteTypeTag[Int]
-true
-ConcreteTypeTag[Long]
-true
-ConcreteTypeTag[Float]
-true
-ConcreteTypeTag[Double]
-true
-ConcreteTypeTag[Boolean]
-true
-ConcreteTypeTag[Unit]
-true
-ConcreteTypeTag[Any]
-true
-ConcreteTypeTag[Object]
-true
-ConcreteTypeTag[AnyVal]
-true
-ConcreteTypeTag[AnyRef]
-true
-ConcreteTypeTag[Null]
-true
-ConcreteTypeTag[Nothing]
+true +ConcreteTypeTag[Byte] +true +ConcreteTypeTag[Short] +true +ConcreteTypeTag[Char] +true +ConcreteTypeTag[Int] +true +ConcreteTypeTag[Long] +true +ConcreteTypeTag[Float] +true +ConcreteTypeTag[Double] +true +ConcreteTypeTag[Boolean] +true +ConcreteTypeTag[Unit] +true +ConcreteTypeTag[Any] +true +ConcreteTypeTag[Object] +true +ConcreteTypeTag[AnyVal] +true +ConcreteTypeTag[AnyRef] +true +ConcreteTypeTag[Null] +true +ConcreteTypeTag[Nothing] +true +ConcreteTypeTag[String] diff --git a/test/files/run/groundtypetags_core.scala b/test/files/run/concretetypetags_core.scala index 8b81a0c795..b6cfea3895 100644 --- a/test/files/run/groundtypetags_core.scala +++ b/test/files/run/concretetypetags_core.scala @@ -29,4 +29,6 @@ object Test extends App { println(implicitly[ConcreteTypeTag[Null]]) println(implicitly[ConcreteTypeTag[Nothing]] eq ConcreteTypeTag.Nothing) println(implicitly[ConcreteTypeTag[Nothing]]) + println(implicitly[ConcreteTypeTag[String]] eq ConcreteTypeTag.String) + println(implicitly[ConcreteTypeTag[String]]) }
\ No newline at end of file diff --git a/test/files/run/concretetypetags_multi.check b/test/files/run/concretetypetags_multi.check new file mode 100644 index 0000000000..613106985c --- /dev/null +++ b/test/files/run/concretetypetags_multi.check @@ -0,0 +1,5 @@ +ConcreteTypeTag[Int]
+ConcreteTypeTag[Array[Int]]
+ConcreteTypeTag[Array[Array[Int]]]
+ConcreteTypeTag[Array[Array[Array[Int]]]]
+ConcreteTypeTag[Array[Array[Array[Array[Int]]]]]
diff --git a/test/files/run/concretetypetags_multi.scala b/test/files/run/concretetypetags_multi.scala new file mode 100644 index 0000000000..7e19d7db34 --- /dev/null +++ b/test/files/run/concretetypetags_multi.scala @@ -0,0 +1,7 @@ +object Test extends App { + println(concreteTypeTag[Int]) + println(concreteTypeTag[Array[Int]]) + println(concreteTypeTag[Array[Array[Int]]]) + println(concreteTypeTag[Array[Array[Array[Int]]]]) + println(concreteTypeTag[Array[Array[Array[Array[Int]]]]]) +}
\ No newline at end of file diff --git a/test/files/run/constrained-types.check b/test/files/run/constrained-types.check index ac8817cb08..37784a20ca 100644 --- a/test/files/run/constrained-types.check +++ b/test/files/run/constrained-types.check @@ -75,9 +75,13 @@ scala> var four = "four" four: String = four scala> val four2 = m(four) // should have an existential bound +warning: there were 1 feature warnings; re-run with -feature for details +warning: there were 1 feature warnings; re-run with -feature for details four2: String @Annot(x) forSome { val x: String } = four scala> val four3 = four2 // should have the same type as four2 +warning: there were 1 feature warnings; re-run with -feature for details +warning: there were 1 feature warnings; re-run with -feature for details four3: String @Annot(x) forSome { val x: String } = four scala> val stuff = m("stuff") // should not crash @@ -100,6 +104,8 @@ scala> def m = { val y : String @Annot(x) = x y } // x should not escape the local scope with a narrow type +warning: there were 1 feature warnings; re-run with -feature for details +warning: there were 1 feature warnings; re-run with -feature for details m: String @Annot(x) forSome { val x: String } scala> @@ -113,6 +119,7 @@ scala> def n(y: String) = { } m("stuff".stripMargin) } // x should be existentially bound +warning: there were 1 feature warnings; re-run with -feature for details n: (y: String)String @Annot(x) forSome { val x: String } scala> diff --git a/test/files/run/ctries/DumbHash.scala b/test/files/run/ctries-new/DumbHash.scala index 8ef325b67c..8ef325b67c 100644 --- a/test/files/run/ctries/DumbHash.scala +++ b/test/files/run/ctries-new/DumbHash.scala diff --git a/test/files/run/ctries/Wrap.scala b/test/files/run/ctries-new/Wrap.scala index 7b645c1612..7b645c1612 100644 --- a/test/files/run/ctries/Wrap.scala +++ b/test/files/run/ctries-new/Wrap.scala diff --git a/test/files/run/ctries/concmap.scala b/test/files/run/ctries-new/concmap.scala index 3ec0256afb..3ec0256afb 100644 --- a/test/files/run/ctries/concmap.scala +++ b/test/files/run/ctries-new/concmap.scala diff --git a/test/files/run/ctries/iterator.scala b/test/files/run/ctries-new/iterator.scala index b953a40e00..b953a40e00 100644 --- a/test/files/run/ctries/iterator.scala +++ b/test/files/run/ctries-new/iterator.scala diff --git a/test/files/run/ctries/lnode.scala b/test/files/run/ctries-new/lnode.scala index 92a31088e5..92a31088e5 100644 --- a/test/files/run/ctries/lnode.scala +++ b/test/files/run/ctries-new/lnode.scala diff --git a/test/files/run/ctries-new/main.scala b/test/files/run/ctries-new/main.scala new file mode 100644 index 0000000000..1d40dab6c5 --- /dev/null +++ b/test/files/run/ctries-new/main.scala @@ -0,0 +1,45 @@ + + + + + + + +object Test { + + def main(args: Array[String]) { + ConcurrentMapSpec.test() + IteratorSpec.test() + LNodeSpec.test() + SnapshotSpec.test() + } + +} + + +trait Spec { + + implicit def str2ops(s: String) = new { + def in[U](body: =>U) { + // just execute body + body + } + } + + implicit def any2ops(a: Any) = new { + def shouldEqual(other: Any) = assert(a == other) + } + + def evaluating[U](body: =>U) = new { + def shouldProduce[T <: Throwable: ClassTag]() = { + var produced = false + try body + catch { + case e => if (e.getClass == implicitly[ClassTag[T]].erasure) produced = true + } finally { + assert(produced, "Did not produce exception of type: " + implicitly[ClassTag[T]]) + } + } + } + +} diff --git a/test/files/run/ctries/snapshot.scala b/test/files/run/ctries-new/snapshot.scala index 5fe77d445b..5fe77d445b 100644 --- a/test/files/run/ctries/snapshot.scala +++ b/test/files/run/ctries-new/snapshot.scala diff --git a/test/files/run/ctries-old/DumbHash.scala b/test/files/run/ctries-old/DumbHash.scala new file mode 100644 index 0000000000..8ef325b67c --- /dev/null +++ b/test/files/run/ctries-old/DumbHash.scala @@ -0,0 +1,14 @@ + + + + + + +class DumbHash(val i: Int) { + override def equals(other: Any) = other match { + case that: DumbHash => that.i == this.i + case _ => false + } + override def hashCode = i % 5 + override def toString = "DH(%s)".format(i) +} diff --git a/test/files/run/ctries-old/Wrap.scala b/test/files/run/ctries-old/Wrap.scala new file mode 100644 index 0000000000..7b645c1612 --- /dev/null +++ b/test/files/run/ctries-old/Wrap.scala @@ -0,0 +1,9 @@ + + + + + + +case class Wrap(i: Int) { + override def hashCode = i * 0x9e3775cd +} diff --git a/test/files/run/ctries-old/concmap.scala b/test/files/run/ctries-old/concmap.scala new file mode 100644 index 0000000000..3ec0256afb --- /dev/null +++ b/test/files/run/ctries-old/concmap.scala @@ -0,0 +1,188 @@ + + + +import collection.concurrent.TrieMap + + +object ConcurrentMapSpec extends Spec { + + val initsz = 500 + val secondsz = 750 + + def test() { + "support put" in { + val ct = new TrieMap[Wrap, Int] + for (i <- 0 until initsz) assert(ct.put(new Wrap(i), i) == None) + for (i <- 0 until initsz) assert(ct.put(new Wrap(i), -i) == Some(i)) + } + + "support put if absent" in { + val ct = new TrieMap[Wrap, Int] + for (i <- 0 until initsz) ct.update(new Wrap(i), i) + for (i <- 0 until initsz) assert(ct.putIfAbsent(new Wrap(i), -i) == Some(i)) + for (i <- 0 until initsz) assert(ct.putIfAbsent(new Wrap(i), -i) == Some(i)) + for (i <- initsz until secondsz) assert(ct.putIfAbsent(new Wrap(i), -i) == None) + for (i <- initsz until secondsz) assert(ct.putIfAbsent(new Wrap(i), i) == Some(-i)) + } + + "support remove if mapped to a specific value" in { + val ct = new TrieMap[Wrap, Int] + for (i <- 0 until initsz) ct.update(new Wrap(i), i) + for (i <- 0 until initsz) assert(ct.remove(new Wrap(i), -i - 1) == false) + for (i <- 0 until initsz) assert(ct.remove(new Wrap(i), i) == true) + for (i <- 0 until initsz) assert(ct.remove(new Wrap(i), i) == false) + } + + "support replace if mapped to a specific value" in { + val ct = new TrieMap[Wrap, Int] + for (i <- 0 until initsz) ct.update(new Wrap(i), i) + for (i <- 0 until initsz) assert(ct.replace(new Wrap(i), -i - 1, -i - 2) == false) + for (i <- 0 until initsz) assert(ct.replace(new Wrap(i), i, -i - 2) == true) + for (i <- 0 until initsz) assert(ct.replace(new Wrap(i), i, -i - 2) == false) + for (i <- initsz until secondsz) assert(ct.replace(new Wrap(i), i, 0) == false) + } + + "support replace if present" in { + val ct = new TrieMap[Wrap, Int] + for (i <- 0 until initsz) ct.update(new Wrap(i), i) + for (i <- 0 until initsz) assert(ct.replace(new Wrap(i), -i) == Some(i)) + for (i <- 0 until initsz) assert(ct.replace(new Wrap(i), i) == Some(-i)) + for (i <- initsz until secondsz) assert(ct.replace(new Wrap(i), i) == None) + } + + def assertEqual(a: Any, b: Any) = { + if (a != b) println(a, b) + assert(a == b) + } + + "support replace if mapped to a specific value, using several threads" in { + val ct = new TrieMap[Wrap, Int] + val sz = 55000 + for (i <- 0 until sz) ct.update(new Wrap(i), i) + + class Updater(index: Int, offs: Int) extends Thread { + override def run() { + var repeats = 0 + for (i <- 0 until sz) { + val j = (offs + i) % sz + var k = Int.MaxValue + do { + if (k != Int.MaxValue) repeats += 1 + k = ct.lookup(new Wrap(j)) + } while (!ct.replace(new Wrap(j), k, -k)) + } + //println("Thread %d repeats: %d".format(index, repeats)) + } + } + + val threads = for (i <- 0 until 16) yield new Updater(i, sz / 32 * i) + threads.foreach(_.start()) + threads.foreach(_.join()) + + for (i <- 0 until sz) assertEqual(ct(new Wrap(i)), i) + + val threads2 = for (i <- 0 until 15) yield new Updater(i, sz / 32 * i) + threads2.foreach(_.start()) + threads2.foreach(_.join()) + + for (i <- 0 until sz) assertEqual(ct(new Wrap(i)), -i) + } + + "support put if absent, several threads" in { + val ct = new TrieMap[Wrap, Int] + val sz = 110000 + + class Updater(offs: Int) extends Thread { + override def run() { + for (i <- 0 until sz) { + val j = (offs + i) % sz + ct.putIfAbsent(new Wrap(j), j) + assert(ct.lookup(new Wrap(j)) == j) + } + } + } + + val threads = for (i <- 0 until 16) yield new Updater(sz / 32 * i) + threads.foreach(_.start()) + threads.foreach(_.join()) + + for (i <- 0 until sz) assert(ct(new Wrap(i)) == i) + } + + "support remove if mapped to a specific value, several threads" in { + val ct = new TrieMap[Wrap, Int] + val sz = 55000 + for (i <- 0 until sz) ct.update(new Wrap(i), i) + + class Remover(offs: Int) extends Thread { + override def run() { + for (i <- 0 until sz) { + val j = (offs + i) % sz + ct.remove(new Wrap(j), j) + assert(ct.get(new Wrap(j)) == None) + } + } + } + + val threads = for (i <- 0 until 16) yield new Remover(sz / 32 * i) + threads.foreach(_.start()) + threads.foreach(_.join()) + + for (i <- 0 until sz) assert(ct.get(new Wrap(i)) == None) + } + + "have all or none of the elements depending on the oddity" in { + val ct = new TrieMap[Wrap, Int] + val sz = 65000 + for (i <- 0 until sz) ct(new Wrap(i)) = i + + class Modifier(index: Int, offs: Int) extends Thread { + override def run() { + for (j <- 0 until sz) { + val i = (offs + j) % sz + var success = false + do { + if (ct.contains(new Wrap(i))) { + success = ct.remove(new Wrap(i)) != None + } else { + success = ct.putIfAbsent(new Wrap(i), i) == None + } + } while (!success) + } + } + } + + def modify(n: Int) = { + val threads = for (i <- 0 until n) yield new Modifier(i, sz / n * i) + threads.foreach(_.start()) + threads.foreach(_.join()) + } + + modify(16) + for (i <- 0 until sz) assertEqual(ct.get(new Wrap(i)), Some(i)) + modify(15) + for (i <- 0 until sz) assertEqual(ct.get(new Wrap(i)), None) + } + + "compute size correctly" in { + val ct = new TrieMap[Wrap, Int] + val sz = 36450 + for (i <- 0 until sz) ct(new Wrap(i)) = i + + assertEqual(ct.size, sz) + assertEqual(ct.size, sz) + } + + "compute size correctly in parallel" in { + val ct = new TrieMap[Wrap, Int] + val sz = 36450 + for (i <- 0 until sz) ct(new Wrap(i)) = i + val pct = ct.par + + assertEqual(pct.size, sz) + assertEqual(pct.size, sz) + } + + } + +} diff --git a/test/files/run/ctries-old/iterator.scala b/test/files/run/ctries-old/iterator.scala new file mode 100644 index 0000000000..b953a40e00 --- /dev/null +++ b/test/files/run/ctries-old/iterator.scala @@ -0,0 +1,289 @@ + + + + +import collection._ +import collection.concurrent.TrieMap + + + +object IteratorSpec extends Spec { + + def test() { + "work for an empty trie" in { + val ct = new TrieMap + val it = ct.iterator + + it.hasNext shouldEqual (false) + evaluating { it.next() }.shouldProduce [NoSuchElementException] + } + + def nonEmptyIteratorCheck(sz: Int) { + val ct = new TrieMap[Wrap, Int] + for (i <- 0 until sz) ct.put(new Wrap(i), i) + + val it = ct.iterator + val tracker = mutable.Map[Wrap, Int]() + for (i <- 0 until sz) { + assert(it.hasNext == true) + tracker += it.next + } + + it.hasNext shouldEqual (false) + evaluating { it.next() }.shouldProduce [NoSuchElementException] + tracker.size shouldEqual (sz) + tracker shouldEqual (ct) + } + + "work for a 1 element trie" in { + nonEmptyIteratorCheck(1) + } + + "work for a 2 element trie" in { + nonEmptyIteratorCheck(2) + } + + "work for a 3 element trie" in { + nonEmptyIteratorCheck(3) + } + + "work for a 5 element trie" in { + nonEmptyIteratorCheck(5) + } + + "work for a 10 element trie" in { + nonEmptyIteratorCheck(10) + } + + "work for a 20 element trie" in { + nonEmptyIteratorCheck(20) + } + + "work for a 50 element trie" in { + nonEmptyIteratorCheck(50) + } + + "work for a 100 element trie" in { + nonEmptyIteratorCheck(100) + } + + "work for a 1k element trie" in { + nonEmptyIteratorCheck(1000) + } + + "work for a 5k element trie" in { + nonEmptyIteratorCheck(5000) + } + + "work for a 75k element trie" in { + nonEmptyIteratorCheck(75000) + } + + "work for a 250k element trie" in { + nonEmptyIteratorCheck(500000) + } + + def nonEmptyCollideCheck(sz: Int) { + val ct = new TrieMap[DumbHash, Int] + for (i <- 0 until sz) ct.put(new DumbHash(i), i) + + val it = ct.iterator + val tracker = mutable.Map[DumbHash, Int]() + for (i <- 0 until sz) { + assert(it.hasNext == true) + tracker += it.next + } + + it.hasNext shouldEqual (false) + evaluating { it.next() }.shouldProduce [NoSuchElementException] + tracker.size shouldEqual (sz) + tracker shouldEqual (ct) + } + + "work for colliding hashcodes, 2 element trie" in { + nonEmptyCollideCheck(2) + } + + "work for colliding hashcodes, 3 element trie" in { + nonEmptyCollideCheck(3) + } + + "work for colliding hashcodes, 5 element trie" in { + nonEmptyCollideCheck(5) + } + + "work for colliding hashcodes, 10 element trie" in { + nonEmptyCollideCheck(10) + } + + "work for colliding hashcodes, 100 element trie" in { + nonEmptyCollideCheck(100) + } + + "work for colliding hashcodes, 500 element trie" in { + nonEmptyCollideCheck(500) + } + + "work for colliding hashcodes, 5k element trie" in { + nonEmptyCollideCheck(5000) + } + + def assertEqual(a: Map[Wrap, Int], b: Map[Wrap, Int]) { + if (a != b) { + println(a.size + " vs " + b.size) + // println(a) + // println(b) + // println(a.toSeq.sortBy((x: (Wrap, Int)) => x._1.i)) + // println(b.toSeq.sortBy((x: (Wrap, Int)) => x._1.i)) + } + assert(a == b) + } + + "be consistent when taken with concurrent modifications" in { + val sz = 25000 + val W = 15 + val S = 5 + val checks = 5 + val ct = new TrieMap[Wrap, Int] + for (i <- 0 until sz) ct.put(new Wrap(i), i) + + class Modifier extends Thread { + override def run() { + for (i <- 0 until sz) ct.putIfAbsent(new Wrap(i), i) match { + case Some(_) => ct.remove(new Wrap(i)) + case None => + } + } + } + + def consistentIteration(ct: TrieMap[Wrap, Int], checks: Int) { + class Iter extends Thread { + override def run() { + val snap = ct.readOnlySnapshot() + val initial = mutable.Map[Wrap, Int]() + for (kv <- snap) initial += kv + + for (i <- 0 until checks) { + assertEqual(snap.iterator.toMap, initial) + } + } + } + + val iter = new Iter + iter.start() + iter.join() + } + + val threads = for (_ <- 0 until W) yield new Modifier + threads.foreach(_.start()) + for (_ <- 0 until S) consistentIteration(ct, checks) + threads.foreach(_.join()) + } + + "be consistent with a concurrent removal with a well defined order" in { + val sz = 150000 + val sgroupsize = 10 + val sgroupnum = 5 + val removerslowdown = 50 + val ct = new TrieMap[Wrap, Int] + for (i <- 0 until sz) ct.put(new Wrap(i), i) + + class Remover extends Thread { + override def run() { + for (i <- 0 until sz) { + assert(ct.remove(new Wrap(i)) == Some(i)) + for (i <- 0 until removerslowdown) ct.get(new Wrap(i)) // slow down, mate + } + //println("done removing") + } + } + + def consistentIteration(it: Iterator[(Wrap, Int)]) = { + class Iter extends Thread { + override def run() { + val elems = it.toBuffer + if (elems.nonEmpty) { + val minelem = elems.minBy((x: (Wrap, Int)) => x._1.i)._1.i + assert(elems.forall(_._1.i >= minelem)) + } + } + } + new Iter + } + + val remover = new Remover + remover.start() + for (_ <- 0 until sgroupnum) { + val iters = for (_ <- 0 until sgroupsize) yield consistentIteration(ct.iterator) + iters.foreach(_.start()) + iters.foreach(_.join()) + } + //println("done with iterators") + remover.join() + } + + "be consistent with a concurrent insertion with a well defined order" in { + val sz = 150000 + val sgroupsize = 10 + val sgroupnum = 10 + val inserterslowdown = 50 + val ct = new TrieMap[Wrap, Int] + + class Inserter extends Thread { + override def run() { + for (i <- 0 until sz) { + assert(ct.put(new Wrap(i), i) == None) + for (i <- 0 until inserterslowdown) ct.get(new Wrap(i)) // slow down, mate + } + //println("done inserting") + } + } + + def consistentIteration(it: Iterator[(Wrap, Int)]) = { + class Iter extends Thread { + override def run() { + val elems = it.toSeq + if (elems.nonEmpty) { + val maxelem = elems.maxBy((x: (Wrap, Int)) => x._1.i)._1.i + assert(elems.forall(_._1.i <= maxelem)) + } + } + } + new Iter + } + + val inserter = new Inserter + inserter.start() + for (_ <- 0 until sgroupnum) { + val iters = for (_ <- 0 until sgroupsize) yield consistentIteration(ct.iterator) + iters.foreach(_.start()) + iters.foreach(_.join()) + } + //println("done with iterators") + inserter.join() + } + + "work on a yet unevaluated snapshot" in { + val sz = 50000 + val ct = new TrieMap[Wrap, Int] + for (i <- 0 until sz) ct.update(new Wrap(i), i) + + val snap = ct.snapshot() + val it = snap.iterator + + while (it.hasNext) it.next() + } + + "be duplicated" in { + val sz = 50 + val ct = collection.parallel.mutable.ParTrieMap((0 until sz) zip (0 until sz): _*) + val it = ct.splitter + for (_ <- 0 until (sz / 2)) it.next() + val dupit = it.dup + + it.toList shouldEqual dupit.toList + } + + } + +} diff --git a/test/files/run/ctries-old/lnode.scala b/test/files/run/ctries-old/lnode.scala new file mode 100644 index 0000000000..92a31088e5 --- /dev/null +++ b/test/files/run/ctries-old/lnode.scala @@ -0,0 +1,61 @@ + + + +import collection.concurrent.TrieMap + + +object LNodeSpec extends Spec { + + val initsz = 1500 + val secondsz = 1750 + + def test() { + "accept elements with the same hash codes" in { + val ct = new TrieMap[DumbHash, Int] + for (i <- 0 until initsz) ct.update(new DumbHash(i), i) + } + + "lookup elements with the same hash codes" in { + val ct = new TrieMap[DumbHash, Int] + for (i <- 0 until initsz) ct.update(new DumbHash(i), i) + for (i <- 0 until initsz) assert(ct.get(new DumbHash(i)) == Some(i)) + for (i <- initsz until secondsz) assert(ct.get(new DumbHash(i)) == None) + } + + "remove elements with the same hash codes" in { + val ct = new TrieMap[DumbHash, Int] + for (i <- 0 until initsz) ct.update(new DumbHash(i), i) + for (i <- 0 until initsz) { + val remelem = ct.remove(new DumbHash(i)) + assert(remelem == Some(i), "removing " + i + " yields " + remelem) + } + for (i <- 0 until initsz) assert(ct.get(new DumbHash(i)) == None) + } + + "put elements with the same hash codes if absent" in { + val ct = new TrieMap[DumbHash, Int] + for (i <- 0 until initsz) ct.put(new DumbHash(i), i) + for (i <- 0 until initsz) assert(ct.lookup(new DumbHash(i)) == i) + for (i <- 0 until initsz) assert(ct.putIfAbsent(new DumbHash(i), i) == Some(i)) + for (i <- initsz until secondsz) assert(ct.putIfAbsent(new DumbHash(i), i) == None) + for (i <- initsz until secondsz) assert(ct.lookup(new DumbHash(i)) == i) + } + + "replace elements with the same hash codes" in { + val ct = new TrieMap[DumbHash, Int] + for (i <- 0 until initsz) assert(ct.put(new DumbHash(i), i) == None) + for (i <- 0 until initsz) assert(ct.lookup(new DumbHash(i)) == i) + for (i <- 0 until initsz) assert(ct.replace(new DumbHash(i), -i) == Some(i)) + for (i <- 0 until initsz) assert(ct.lookup(new DumbHash(i)) == -i) + for (i <- 0 until initsz) assert(ct.replace(new DumbHash(i), -i, i) == true) + } + + "remove elements with the same hash codes if mapped to a specific value" in { + val ct = new TrieMap[DumbHash, Int] + for (i <- 0 until initsz) assert(ct.put(new DumbHash(i), i) == None) + for (i <- 0 until initsz) assert(ct.remove(new DumbHash(i), i) == true) + } + + } + +} diff --git a/test/files/run/ctries/main.scala b/test/files/run/ctries-old/main.scala index 8db7fcef54..8db7fcef54 100644 --- a/test/files/run/ctries/main.scala +++ b/test/files/run/ctries-old/main.scala diff --git a/test/files/run/ctries-old/snapshot.scala b/test/files/run/ctries-old/snapshot.scala new file mode 100644 index 0000000000..5fe77d445b --- /dev/null +++ b/test/files/run/ctries-old/snapshot.scala @@ -0,0 +1,267 @@ + + + + +import collection._ +import collection.concurrent.TrieMap + + + +object SnapshotSpec extends Spec { + + def test() { + "support snapshots" in { + val ctn = new TrieMap + ctn.snapshot() + ctn.readOnlySnapshot() + + val ct = new TrieMap[Int, Int] + for (i <- 0 until 100) ct.put(i, i) + ct.snapshot() + ct.readOnlySnapshot() + } + + "empty 2 quiescent snapshots in isolation" in { + val sz = 4000 + + class Worker(trie: TrieMap[Wrap, Int]) extends Thread { + override def run() { + for (i <- 0 until sz) { + assert(trie.remove(new Wrap(i)) == Some(i)) + for (j <- 0 until sz) + if (j <= i) assert(trie.get(new Wrap(j)) == None) + else assert(trie.get(new Wrap(j)) == Some(j)) + } + } + } + + val ct = new TrieMap[Wrap, Int] + for (i <- 0 until sz) ct.put(new Wrap(i), i) + val snapt = ct.snapshot() + + val original = new Worker(ct) + val snapshot = new Worker(snapt) + original.start() + snapshot.start() + original.join() + snapshot.join() + + for (i <- 0 until sz) { + assert(ct.get(new Wrap(i)) == None) + assert(snapt.get(new Wrap(i)) == None) + } + } + + def consistentReadOnly(name: String, readonly: Map[Wrap, Int], sz: Int, N: Int) { + @volatile var e: Exception = null + + // reads possible entries once and stores them + // then reads all these N more times to check if the + // state stayed the same + class Reader(trie: Map[Wrap, Int]) extends Thread { + setName("Reader " + name) + + override def run() = + try check() + catch { + case ex: Exception => e = ex + } + + def check() { + val initial = mutable.Map[Wrap, Int]() + for (i <- 0 until sz) trie.get(new Wrap(i)) match { + case Some(i) => initial.put(new Wrap(i), i) + case None => // do nothing + } + + for (k <- 0 until N) { + for (i <- 0 until sz) { + val tres = trie.get(new Wrap(i)) + val ires = initial.get(new Wrap(i)) + if (tres != ires) println(i, "initially: " + ires, "traversal %d: %s".format(k, tres)) + assert(tres == ires) + } + } + } + } + + val reader = new Reader(readonly) + reader.start() + reader.join() + + if (e ne null) { + e.printStackTrace() + throw e + } + } + + // traverses the trie `rep` times and modifies each entry + class Modifier(trie: TrieMap[Wrap, Int], index: Int, rep: Int, sz: Int) extends Thread { + setName("Modifier %d".format(index)) + + override def run() { + for (k <- 0 until rep) { + for (i <- 0 until sz) trie.putIfAbsent(new Wrap(i), i) match { + case Some(_) => trie.remove(new Wrap(i)) + case None => // do nothing + } + } + } + } + + // removes all the elements from the trie + class Remover(trie: TrieMap[Wrap, Int], index: Int, totremovers: Int, sz: Int) extends Thread { + setName("Remover %d".format(index)) + + override def run() { + for (i <- 0 until sz) trie.remove(new Wrap((i + sz / totremovers * index) % sz)) + } + } + + "have a consistent quiescent read-only snapshot" in { + val sz = 10000 + val N = 100 + val W = 10 + + val ct = new TrieMap[Wrap, Int] + for (i <- 0 until sz) ct(new Wrap(i)) = i + val readonly = ct.readOnlySnapshot() + val threads = for (i <- 0 until W) yield new Modifier(ct, i, N, sz) + + threads.foreach(_.start()) + consistentReadOnly("qm", readonly, sz, N) + threads.foreach(_.join()) + } + + // now, we check non-quiescent snapshots, as these permit situations + // where a thread is caught in the middle of the update when a snapshot is taken + + "have a consistent non-quiescent read-only snapshot, concurrent with removes only" in { + val sz = 1250 + val W = 100 + val S = 5000 + + val ct = new TrieMap[Wrap, Int] + for (i <- 0 until sz) ct(new Wrap(i)) = i + val threads = for (i <- 0 until W) yield new Remover(ct, i, W, sz) + + threads.foreach(_.start()) + for (i <- 0 until S) consistentReadOnly("non-qr", ct.readOnlySnapshot(), sz, 5) + threads.foreach(_.join()) + } + + "have a consistent non-quiescent read-only snapshot, concurrent with modifications" in { + val sz = 1000 + val N = 7000 + val W = 10 + val S = 7000 + + val ct = new TrieMap[Wrap, Int] + for (i <- 0 until sz) ct(new Wrap(i)) = i + val threads = for (i <- 0 until W) yield new Modifier(ct, i, N, sz) + + threads.foreach(_.start()) + for (i <- 0 until S) consistentReadOnly("non-qm", ct.readOnlySnapshot(), sz, 5) + threads.foreach(_.join()) + } + + def consistentNonReadOnly(name: String, trie: TrieMap[Wrap, Int], sz: Int, N: Int) { + @volatile var e: Exception = null + + // reads possible entries once and stores them + // then reads all these N more times to check if the + // state stayed the same + class Worker extends Thread { + setName("Worker " + name) + + override def run() = + try check() + catch { + case ex: Exception => e = ex + } + + def check() { + val initial = mutable.Map[Wrap, Int]() + for (i <- 0 until sz) trie.get(new Wrap(i)) match { + case Some(i) => initial.put(new Wrap(i), i) + case None => // do nothing + } + + for (k <- 0 until N) { + // modify + for ((key, value) <- initial) { + val oldv = if (k % 2 == 0) value else -value + val newv = -oldv + trie.replace(key, oldv, newv) + } + + // check + for (i <- 0 until sz) if (initial.contains(new Wrap(i))) { + val expected = if (k % 2 == 0) -i else i + //println(trie.get(new Wrap(i))) + assert(trie.get(new Wrap(i)) == Some(expected)) + } else { + assert(trie.get(new Wrap(i)) == None) + } + } + } + } + + val worker = new Worker + worker.start() + worker.join() + + if (e ne null) { + e.printStackTrace() + throw e + } + } + + "have a consistent non-quiescent snapshot, concurrent with modifications" in { + val sz = 9000 + val N = 1000 + val W = 10 + val S = 400 + + val ct = new TrieMap[Wrap, Int] + for (i <- 0 until sz) ct(new Wrap(i)) = i + val threads = for (i <- 0 until W) yield new Modifier(ct, i, N, sz) + + threads.foreach(_.start()) + for (i <- 0 until S) { + consistentReadOnly("non-qm", ct.snapshot(), sz, 5) + consistentNonReadOnly("non-qsnap", ct.snapshot(), sz, 5) + } + threads.foreach(_.join()) + } + + "work when many concurrent snapshots are taken, concurrent with modifications" in { + val sz = 12000 + val W = 10 + val S = 10 + val modifytimes = 1200 + val snaptimes = 600 + val ct = new TrieMap[Wrap, Int] + for (i <- 0 until sz) ct(new Wrap(i)) = i + + class Snapshooter extends Thread { + setName("Snapshooter") + override def run() { + for (k <- 0 until snaptimes) { + val snap = ct.snapshot() + for (i <- 0 until sz) snap.remove(new Wrap(i)) + for (i <- 0 until sz) assert(!snap.contains(new Wrap(i))) + } + } + } + + val mods = for (i <- 0 until W) yield new Modifier(ct, i, modifytimes, sz) + val shooters = for (i <- 0 until S) yield new Snapshooter + val threads = mods ++ shooters + threads.foreach(_.start()) + threads.foreach(_.join()) + } + + } + +} diff --git a/test/files/run/dynamic-proxy.check b/test/files/run/dynamic-proxy.check new file mode 100644 index 0000000000..d1b85daff4 --- /dev/null +++ b/test/files/run/dynamic-proxy.check @@ -0,0 +1,20 @@ +noargs +noargs +nullary +value +symbolic +symbolic with args +non-existent method +before mutation +mutation 1 +after mutation 1 +mutation 2 +after mutation 2 +overloaded with object +overloaded with primitive +overloaded with object in var +overloaded with object in var 2 +typeArgs: I am a car +default: 4 +default: 3 +named: 6 diff --git a/test/files/run/dynamic-proxy.flags b/test/files/run/dynamic-proxy.flags new file mode 100644 index 0000000000..48fd867160 --- /dev/null +++ b/test/files/run/dynamic-proxy.flags @@ -0,0 +1 @@ +-Xexperimental diff --git a/test/files/run/dynamic-proxy.scala b/test/files/run/dynamic-proxy.scala new file mode 100644 index 0000000000..ab5a8b1d66 --- /dev/null +++ b/test/files/run/dynamic-proxy.scala @@ -0,0 +1,72 @@ +import scala.reflect._ + +class Car{ override def toString = "I am a car" } +object x{ + def nullary = "nullary" + def noargs() = "noargs" + def - = "symbolic" + def $(s:String) = "symbolic with args" + val value = "value" + def overloaded(i:Int) = "overloaded with primitive" + def overloaded(s:String) = s + def default( a:Int, b:Int = 2 ) = "default: "+(a+b) + def named( a:Int, b:Int, c:Int ) = "named: "+(a+b+c) + def typeArgs[T]( v:T ) = "typeArgs: "+v + var mutable = "before mutation" + def multiArgLists( a:String )( b:String ) = "multiArgList " + a + b + def bar( s:String )(implicit car:Car) = s + car.toString +} + +object Test extends App{ + val d = new DynamicProxy{ val dynamicProxyTarget = x } + + println( d.noargs ) + println( d.noargs() ) + println( d.nullary ) + println( d.value ) + println( d.- ) + println( d.$("x") ) + + try{ + println( d.test ) + } catch { + case _ => println("non-existent method") + } + + println( d.mutable ) + + println("mutation 1") + d.mutable_=("after mutation 1") + println( d.mutable ) + + println("mutation 2") + d.mutable = "after mutation 2" + println( d.mutable ) + + println( d.overloaded("overloaded with object") ) + println( d.overloaded(1) ) + + // test some non-constant arguments + def s = "overloaded with object in var" + println( d.overloaded(s) ) + println( d.overloaded(s + " 2") ) + + val car = new Car + println( d.typeArgs(car) ) // inferred + // println( d.typeArgs[Car](car) ) // explicit not working (yet) + + println( d.default( 1,3 ) ) + println( d.default( 1 ) ) + + println( d.named(1,c=3,b=2) ) // applyDynamicNamed seems to be broken + + // println( d.multiArgLists("a")("b") ) // not working yet + + /* + // may never work + // testing implicit parameters (first test works when moving x into TestDynamicReflect) + implicit val car2 = new Car + println( d.bar( "Yeah, ") ); // FAILS: could not find implicit value for parameter car + {println( d.bar( "Yeah, ") )} // FAILS: could not find implicit value for parameter car + */ +} diff --git a/test/files/run/enrich-gentraversable.check b/test/files/run/enrich-gentraversable.check new file mode 100644 index 0000000000..348b38d6a4 --- /dev/null +++ b/test/files/run/enrich-gentraversable.check @@ -0,0 +1,4 @@ +List(2, 4) +Array(2, 4) +HW +Vector(72, 108, 108, 32, 114, 108, 100) diff --git a/test/files/run/enrich-gentraversable.scala b/test/files/run/enrich-gentraversable.scala new file mode 100644 index 0000000000..c9320ff985 --- /dev/null +++ b/test/files/run/enrich-gentraversable.scala @@ -0,0 +1,30 @@ +object Test extends App { + import scala.collection.generic.{ CanBuildFrom, FromRepr, HasElem } + + def typed[T](t : => T) {} + + class FilterMapImpl[A, Repr](val r : Repr)(implicit hasElem : HasElem[Repr, A]) { + def filterMap[B, That](f : A => Option[B])(implicit cbf : CanBuildFrom[Repr, B, That]) : That = r.flatMap(f(_).toSeq) + } + + implicit def filterMap[Repr : FromRepr](r : Repr) = new FilterMapImpl(r) + + val l = List(1, 2, 3, 4, 5) + val fml = l.filterMap(i => if(i % 2 == 0) Some(i) else None) + typed[List[Int]](fml) + println(fml) + + val a = Array(1, 2, 3, 4, 5) + val fma = a.filterMap(i => if(i % 2 == 0) Some(i) else None) + typed[Array[Int]](fma) + println(fma.deep) + + val s = "Hello World" + val fms1 = s.filterMap(c => if(c >= 'A' && c <= 'Z') Some(c) else None) + typed[String](fms1) + println(fms1) + + val fms2 = s.filterMap(c =>if(c % 2 == 0) Some(c.toInt) else None) + typed[IndexedSeq[Int]](fms2) + println(fms2) +} diff --git a/test/files/run/erasuretags_abstract.check b/test/files/run/erasuretags_abstract.check new file mode 100644 index 0000000000..17e7204664 --- /dev/null +++ b/test/files/run/erasuretags_abstract.check @@ -0,0 +1,4 @@ +class java.lang.Object
+class java.lang.Object
+class java.lang.Object
+int
diff --git a/test/files/run/erasuretags_abstract.scala b/test/files/run/erasuretags_abstract.scala new file mode 100644 index 0000000000..8e4ad0d090 --- /dev/null +++ b/test/files/run/erasuretags_abstract.scala @@ -0,0 +1,9 @@ +object Test extends App { + def foo1[T] = erasureTag[T] + println(foo1[Int].erasure) + println(foo1[String].erasure) + println(foo1[Array[Int]].erasure) + + def foo2[T <: Int] = erasureTag[T] + println(foo2[Int].erasure) +}
\ No newline at end of file diff --git a/test/files/run/erasuretags_basic.check b/test/files/run/erasuretags_basic.check new file mode 100644 index 0000000000..c02a4d32af --- /dev/null +++ b/test/files/run/erasuretags_basic.check @@ -0,0 +1,24 @@ +int
+class [I
+class scala.collection.immutable.List
+class [Lscala.collection.immutable.List;
+class scala.collection.immutable.List
+class [Lscala.collection.immutable.List;
+interface scala.collection.immutable.Map
+class [Lscala.collection.immutable.Map;
+class [I
+class [[I
+class [Lscala.collection.immutable.List;
+class [[Lscala.collection.immutable.List;
+class [Lscala.collection.immutable.List;
+class [[Lscala.collection.immutable.List;
+class [Lscala.collection.immutable.Map;
+class [[Lscala.collection.immutable.Map;
+class [[I
+class [[[I
+class [[Lscala.collection.immutable.List;
+class [[[Lscala.collection.immutable.List;
+class [[Lscala.collection.immutable.List;
+class [[[Lscala.collection.immutable.List;
+class [[Lscala.collection.immutable.Map;
+class [[[Lscala.collection.immutable.Map;
diff --git a/test/files/run/erasuretags_basic.scala b/test/files/run/erasuretags_basic.scala new file mode 100644 index 0000000000..d894fdf2e9 --- /dev/null +++ b/test/files/run/erasuretags_basic.scala @@ -0,0 +1,21 @@ +object Test extends App { + def test[T: ErasureTag] = { + println(implicitly[ErasureTag[T]].erasure) + println(implicitly[ErasureTag[Array[T]]].erasure) + } + + test[Int] + test[List[Int]] + test[List[String]] + test[Map[Int, String]] + + test[Array[Int]] + test[Array[List[Int]]] + test[Array[List[String]]] + test[Array[Map[Int, String]]] + + test[Array[Array[Int]]] + test[Array[Array[List[Int]]]] + test[Array[Array[List[String]]]] + test[Array[Array[Map[Int, String]]]] +}
\ No newline at end of file diff --git a/test/files/run/erasuretags_core.check b/test/files/run/erasuretags_core.check new file mode 100644 index 0000000000..2c544678d1 --- /dev/null +++ b/test/files/run/erasuretags_core.check @@ -0,0 +1,32 @@ +byte
+class [B
+short
+class [S
+char
+class [C
+int
+class [I
+long
+class [J
+float
+class [F
+double
+class [D
+boolean
+class [Z
+void
+class [Lscala.runtime.BoxedUnit;
+class java.lang.Object
+class [Ljava.lang.Object;
+class java.lang.Object
+class [Ljava.lang.Object;
+class java.lang.Object
+class [Ljava.lang.Object;
+class java.lang.Object
+class [Ljava.lang.Object;
+class scala.runtime.Null$
+class [Lscala.runtime.Null$;
+class scala.runtime.Nothing$
+class [Lscala.runtime.Nothing$;
+class java.lang.String
+class [Ljava.lang.String;
diff --git a/test/files/run/erasuretags_core.scala b/test/files/run/erasuretags_core.scala new file mode 100644 index 0000000000..5ed06dcd31 --- /dev/null +++ b/test/files/run/erasuretags_core.scala @@ -0,0 +1,34 @@ +object Test extends App { + println(implicitly[ErasureTag[Byte]].erasure) + println(implicitly[ErasureTag[Array[Byte]]].erasure) + println(implicitly[ErasureTag[Short]].erasure) + println(implicitly[ErasureTag[Array[Short]]].erasure) + println(implicitly[ErasureTag[Char]].erasure) + println(implicitly[ErasureTag[Array[Char]]].erasure) + println(implicitly[ErasureTag[Int]].erasure) + println(implicitly[ErasureTag[Array[Int]]].erasure) + println(implicitly[ErasureTag[Long]].erasure) + println(implicitly[ErasureTag[Array[Long]]].erasure) + println(implicitly[ErasureTag[Float]].erasure) + println(implicitly[ErasureTag[Array[Float]]].erasure) + println(implicitly[ErasureTag[Double]].erasure) + println(implicitly[ErasureTag[Array[Double]]].erasure) + println(implicitly[ErasureTag[Boolean]].erasure) + println(implicitly[ErasureTag[Array[Boolean]]].erasure) + println(implicitly[ErasureTag[Unit]].erasure) + println(implicitly[ErasureTag[Array[Unit]]].erasure) + println(implicitly[ErasureTag[Any]].erasure) + println(implicitly[ErasureTag[Array[Any]]].erasure) + println(implicitly[ErasureTag[Object]].erasure) + println(implicitly[ErasureTag[Array[Object]]].erasure) + println(implicitly[ErasureTag[AnyVal]].erasure) + println(implicitly[ErasureTag[Array[AnyVal]]].erasure) + println(implicitly[ErasureTag[AnyRef]].erasure) + println(implicitly[ErasureTag[Array[AnyRef]]].erasure) + println(implicitly[ErasureTag[Null]].erasure) + println(implicitly[ErasureTag[Array[Null]]].erasure) + println(implicitly[ErasureTag[Nothing]].erasure) + println(implicitly[ErasureTag[Array[Nothing]]].erasure) + println(implicitly[ErasureTag[String]].erasure) + println(implicitly[ErasureTag[Array[String]]].erasure) +}
\ No newline at end of file diff --git a/test/files/run/erasuretags_usage.scala b/test/files/run/erasuretags_usage.scala new file mode 100644 index 0000000000..16e53af071 --- /dev/null +++ b/test/files/run/erasuretags_usage.scala @@ -0,0 +1,12 @@ +object Test extends App { + def foo[T] = { + class MyErasureTag(_erasure: Class[_]) extends ErasureTag[T] { + def erasure: Class[T] = _erasure.asInstanceOf[Class[T]] + } + + implicit val tag = new MyErasureTag(classOf[Int]) + println(typeTag[T]) + println(typeTag[T].tpe) + println(typeTag[T].erasure) + } +}
\ No newline at end of file diff --git a/test/files/run/existentials-in-compiler.check b/test/files/run/existentials-in-compiler.check index 83e3cdf435..4df4b0ca96 100644 --- a/test/files/run/existentials-in-compiler.check +++ b/test/files/run/existentials-in-compiler.check @@ -100,8 +100,8 @@ abstract trait Cov31[+A, +B, C <: (A, B)] extends Object abstract trait Cov32[+A, B, C <: (A, B)] extends Object extest.Cov32[A,B,C] forSome { +A; B; C <: (A, B) } -abstract trait Cov33[+A, -B, C <: (A, _$10) forSome { type _$10 }] extends Object - extest.Cov33[A,B,C] forSome { +A; -B; C <: (A, _$10) forSome { type _$10 } } +abstract trait Cov33[+A, -B, C <: Tuple2[A, _]] extends Object + extest.Cov33[A,B,C] forSome { +A; -B; C <: Tuple2[A, _] } abstract trait Cov34[A, +B, C <: (A, B)] extends Object extest.Cov34[A,B,C] forSome { A; +B; C <: (A, B) } @@ -109,14 +109,14 @@ abstract trait Cov34[A, +B, C <: (A, B)] extends Object abstract trait Cov35[A, B, C <: (A, B)] extends Object extest.Cov35[A,B,C] forSome { A; B; C <: (A, B) } -abstract trait Cov36[A, -B, C <: (A, _$11) forSome { type _$11 }] extends Object - extest.Cov36[A,B,C] forSome { A; -B; C <: (A, _$11) forSome { type _$11 } } +abstract trait Cov36[A, -B, C <: Tuple2[A, _]] extends Object + extest.Cov36[A,B,C] forSome { A; -B; C <: Tuple2[A, _] } -abstract trait Cov37[-A, +B, C <: (_$12, B) forSome { type _$12 }] extends Object - extest.Cov37[A,B,C] forSome { -A; +B; C <: (_$12, B) forSome { type _$12 } } +abstract trait Cov37[-A, +B, C <: Tuple2[_, B]] extends Object + extest.Cov37[A,B,C] forSome { -A; +B; C <: Tuple2[_, B] } -abstract trait Cov38[-A, B, C <: (_$13, B) forSome { type _$13 }] extends Object - extest.Cov38[A,B,C] forSome { -A; B; C <: (_$13, B) forSome { type _$13 } } +abstract trait Cov38[-A, B, C <: Tuple2[_, B]] extends Object + extest.Cov38[A,B,C] forSome { -A; B; C <: Tuple2[_, B] } abstract trait Cov39[-A, -B, C <: Tuple2[_, _]] extends Object extest.Cov39[_, _, _ <: Tuple2[_, _]] diff --git a/test/files/run/existentials3-new.check b/test/files/run/existentials3-new.check new file mode 100644 index 0000000000..66674fbbd6 --- /dev/null +++ b/test/files/run/existentials3-new.check @@ -0,0 +1,24 @@ +ConcreteTypeTag[Bar.type], t=AbstractTypeRef, s= <: scala.runtime.AbstractFunction0[Bar] with Serializable{case def unapply(x$0: Bar): Boolean} with Singleton +ConcreteTypeTag[Bar], t=AbstractTypeRef, s= <: Test.ToS with Product with Serializable{def copy(): Bar} +ConcreteTypeTag[Test.ToS], t=RefinedType, s=f3 +ConcreteTypeTag[Test.ToS], t=RefinedType, s=f4 +ConcreteTypeTag[Test.ToS], t=RefinedType, s=f5 +ConcreteTypeTag[() => Test.ToS], t=TypeRef, s=class Function0 +ConcreteTypeTag[() => Test.ToS], t=TypeRef, s=class Function0 +ConcreteTypeTag[$anon], t=AbstractTypeRef, s= <: B with Test.ToS +ConcreteTypeTag[$anon], t=AbstractTypeRef, s= <: B with A with Test.ToS +TypeTag[List[Object{type T1}#T1]], t=TypeRef, s=class List +ConcreteTypeTag[List[Seq[Int]]], t=TypeRef, s=class List +ConcreteTypeTag[List[Seq[U forSome { type U <: Int }]]], t=TypeRef, s=class List +ConcreteTypeTag[Bar.type], t=AbstractTypeRef, s= <: scala.runtime.AbstractFunction0[Bar] with Serializable{case def unapply(x$0: Bar): Boolean} with Singleton +ConcreteTypeTag[Bar], t=AbstractTypeRef, s= <: Test.ToS with Product with Serializable{def copy(): Bar} +ConcreteTypeTag[Test.ToS], t=RefinedType, s=g3 +ConcreteTypeTag[Test.ToS], t=RefinedType, s=g4 +ConcreteTypeTag[Test.ToS], t=RefinedType, s=g5 +ConcreteTypeTag[() => Test.ToS], t=TypeRef, s=class Function0 +ConcreteTypeTag[() => Test.ToS], t=TypeRef, s=class Function0 +ConcreteTypeTag[$anon], t=AbstractTypeRef, s= <: B with Test.ToS +ConcreteTypeTag[$anon], t=AbstractTypeRef, s= <: B with A with Test.ToS +TypeTag[List[Object{type T1}#T1]], t=TypeRef, s=class List +ConcreteTypeTag[List[Seq[Int]]], t=TypeRef, s=class List +ConcreteTypeTag[List[Seq[U forSome { type U <: Int }]]], t=TypeRef, s=class List diff --git a/test/files/run/existentials3-new.scala b/test/files/run/existentials3-new.scala new file mode 100644 index 0000000000..32129a04c6 --- /dev/null +++ b/test/files/run/existentials3-new.scala @@ -0,0 +1,78 @@ +object Test { + trait ToS { final override def toString = getClass.getName } + + def f1 = { case class Bar() extends ToS; Bar } + def f2 = { case class Bar() extends ToS; Bar() } + def f3 = { class Bar() extends ToS; object Bar extends ToS; Bar } + def f4 = { class Bar() extends ToS; new Bar() } + def f5 = { object Bar extends ToS; Bar } + def f6 = { () => { object Bar extends ToS ; Bar } } + def f7 = { val f = { () => { object Bar extends ToS ; Bar } } ; f } + + def f8 = { trait A ; trait B extends A ; class C extends B with ToS; new C { } } + def f9 = { trait A ; trait B ; class C extends B with A with ToS; new C { } } + + def f10 = { class A { type T1 } ; List[A#T1]() } + def f11 = { abstract class A extends Seq[Int] ; List[A]() } + def f12 = { abstract class A extends Seq[U forSome { type U <: Int }] ; List[A]() } + + val g1 = { case class Bar() extends ToS; Bar } + val g2 = { case class Bar() extends ToS; Bar() } + val g3 = { class Bar() extends ToS; object Bar extends ToS; Bar } + val g4 = { class Bar() extends ToS; new Bar() } + val g5 = { object Bar extends ToS; Bar } + val g6 = { () => { object Bar extends ToS ; Bar } } + val g7 = { val f = { () => { object Bar extends ToS ; Bar } } ; f } + + val g8 = { trait A ; trait B extends A ; class C extends B with ToS; new C { } } + val g9 = { trait A ; trait B ; class C extends B with A with ToS; new C { } } + + val g10 = { class A { type T1 } ; List[A#T1]() } + val g11 = { abstract class A extends Seq[Int] ; List[A]() } + val g12 = { abstract class A extends Seq[U forSome { type U <: Int }] ; List[A]() } + + def printTag(t: TypeTag[_]) = { + val s = if (t.sym.isFreeType) t.sym.typeSignature.toString else t.sym.toString + println("%s, t=%s, s=%s".format(t, t.tpe.kind, s)) + } + def m[T: ConcreteTypeTag](x: T) = printTag(concreteTypeTag[T]) + def m2[T: TypeTag](x: T) = printTag(typeTag[T]) + + // tags do work for f10/g10 + def main(args: Array[String]): Unit = { + m(f1) + m(f2) + m(f3) + m(f4) + m(f5) + m(f6) + m(f7) + m(f8) + m(f9) + m2(f10) + m(f11) + m(f12) + m(g1) + m(g2) + m(g3) + m(g4) + m(g5) + m(g6) + m(g7) + m(g8) + m(g9) + m2(g10) + m(g11) + m(g12) + } +} + +object Misc { + trait Bippy { def bippy = "I'm Bippy!" } + object o1 { + def f1 = { trait A extends Seq[U forSome { type U <: Bippy }] ; abstract class B extends A ; trait C extends B ; (null: C) } + def f2 = f1.head.bippy + } + def g1 = o1.f1 _ + def g2 = o1.f2 _ +} diff --git a/test/files/run/existentials3.check.temporarily.disabled b/test/files/run/existentials3-old.check index 36a458dacc..72abfac637 100644 --- a/test/files/run/existentials3.check.temporarily.disabled +++ b/test/files/run/existentials3-old.check @@ -5,7 +5,7 @@ Object with Test$ToS Object with Test$ToS scala.Function0[Object with Test$ToS] scala.Function0[Object with Test$ToS] -_ <: Object with _ <: Object with Object with Test$ToS +_ <: Object with _ <: Object with Test$ToS _ <: Object with _ <: Object with _ <: Object with Test$ToS scala.collection.immutable.List[Object with scala.collection.Seq[Int]] scala.collection.immutable.List[Object with scala.collection.Seq[_ <: Int]] @@ -16,7 +16,7 @@ Object with Test$ToS Object with Test$ToS scala.Function0[Object with Test$ToS] scala.Function0[Object with Test$ToS] -_ <: Object with _ <: Object with Object with Test$ToS +_ <: Object with _ <: Object with Test$ToS _ <: Object with _ <: Object with _ <: Object with Test$ToS scala.collection.immutable.List[Object with scala.collection.Seq[Int]] scala.collection.immutable.List[Object with scala.collection.Seq[_ <: Int]] diff --git a/test/files/run/existentials3.scala.temporarily.disabled b/test/files/run/existentials3-old.scala index bb80d366cc..944160ff12 100644 --- a/test/files/run/existentials3.scala.temporarily.disabled +++ b/test/files/run/existentials3-old.scala @@ -11,11 +11,11 @@ object Test { def f8 = { trait A ; trait B extends A ; class C extends B with ToS; new C { } } def f9 = { trait A ; trait B ; class C extends B with A with ToS; new C { } } - + def f10 = { class A { type T1 } ; List[A#T1]() } def f11 = { abstract class A extends Seq[Int] ; List[A]() } def f12 = { abstract class A extends Seq[U forSome { type U <: Int }] ; List[A]() } - + val g1 = { case class Bar() extends ToS; Bar } val g2 = { case class Bar() extends ToS; Bar() } val g3 = { class Bar() extends ToS; object Bar extends ToS; Bar } @@ -30,9 +30,9 @@ object Test { val g10 = { class A { type T1 } ; List[A#T1]() } val g11 = { abstract class A extends Seq[Int] ; List[A]() } val g12 = { abstract class A extends Seq[U forSome { type U <: Int }] ; List[A]() } - + def m[T: Manifest](x: T) = println(manifest[T]) - + // manifests don't work for f10/g10 def main(args: Array[String]): Unit = { m(f1) diff --git a/test/files/run/getClassTest.check b/test/files/run/getClassTest-new.check index 94e86c3889..94e86c3889 100644 --- a/test/files/run/getClassTest.check +++ b/test/files/run/getClassTest-new.check diff --git a/test/files/run/getClassTest-new.scala b/test/files/run/getClassTest-new.scala new file mode 100644 index 0000000000..89778ca2d3 --- /dev/null +++ b/test/files/run/getClassTest-new.scala @@ -0,0 +1,66 @@ +class AnyVals { + def f1 = (5: Any).getClass + def f2 = (5: AnyVal).getClass + def f3 = 5.getClass + def f4 = (5: java.lang.Integer).getClass + def f5 = (5.asInstanceOf[AnyRef]).getClass + + // scalap says: + // + // def f1 : java.lang.Class[?0] forSome {type ?0} = { /* compiled code */ } + // def f2 : java.lang.Class[?0] forSome {type ?0} = { /* compiled code */ } + // def f3 : java.lang.Class[scala.Int] = { /* compiled code */ } + // def f4 : java.lang.Class[?0] forSome {type ?0 <: java.lang.Integer} = { /* compiled code */ } + // def f5 : java.lang.Class[?0] forSome {type ?0 <: scala.AnyRef} = { /* compiled code */ } + // + // java generic signature says: + // + // f1: java.lang.Class<?> + // f2: java.lang.Class<?> + // f3: java.lang.Class<java.lang.Object> + // f4: java.lang.Class<? extends java.lang.Integer> + // f5: java.lang.Class<?> +} + +class AnyRefs { + class A + class B extends A + + def f1 = (new B: Any).getClass().newInstance() + def f2 = (new B: AnyRef).getClass().newInstance() + def f3 = (new B: A).getClass().newInstance() + def f4 = (new B: B).getClass().newInstance() + + def f0[T >: B] = (new B: T).getClass().newInstance() + + def f5 = f0[Any] + def f6 = f0[AnyRef] + def f7 = f0[A] + def f8 = f0[B] +} + +class MoreAnyRefs { + trait A + trait B + + // don't leak anon/refinements + def f1 = (new A with B { }).getClass() + def f2 = (new B with A { }).getClass() + def f3 = (new { def bippy() = 5 }).getClass() + def f4 = (new A { def bippy() = 5 }).getClass() +} + +object Test { + def returnTypes[T: ClassTag] = ( + classTag[T].erasure.getMethods.toList + filter (_.getName startsWith "f") + sortBy (_.getName) + map (m => m.getName + ": " + m.getGenericReturnType.toString) + ) + + def main(args: Array[String]): Unit = { + returnTypes[AnyVals] foreach println + returnTypes[AnyRefs] foreach println + returnTypes[MoreAnyRefs] foreach println + } +} diff --git a/test/files/run/getClassTest-old.check b/test/files/run/getClassTest-old.check new file mode 100644 index 0000000000..94e86c3889 --- /dev/null +++ b/test/files/run/getClassTest-old.check @@ -0,0 +1,18 @@ +f1: java.lang.Class<?> +f2: java.lang.Class<?> +f3: java.lang.Class<java.lang.Object> +f4: java.lang.Class<? extends java.lang.Integer> +f5: java.lang.Class<?> +f0: T +f1: class java.lang.Object +f2: class java.lang.Object +f3: class AnyRefs$A +f4: class AnyRefs$B +f5: class java.lang.Object +f6: class java.lang.Object +f7: class AnyRefs$A +f8: class AnyRefs$B +f1: java.lang.Class<? extends MoreAnyRefs$A> +f2: java.lang.Class<? extends MoreAnyRefs$B> +f3: java.lang.Class<?> +f4: java.lang.Class<? extends MoreAnyRefs$A> diff --git a/test/files/run/getClassTest.scala b/test/files/run/getClassTest-old.scala index 2485cd2c71..951cc8d931 100644 --- a/test/files/run/getClassTest.scala +++ b/test/files/run/getClassTest-old.scala @@ -4,7 +4,7 @@ class AnyVals { def f3 = 5.getClass def f4 = (5: java.lang.Integer).getClass def f5 = (5.asInstanceOf[AnyRef]).getClass - + // scalap says: // // def f1 : java.lang.Class[?0] forSome {type ?0} = { /* compiled code */ } @@ -19,18 +19,18 @@ class AnyVals { // f2: java.lang.Class<?> // f3: java.lang.Class<java.lang.Object> // f4: java.lang.Class<? extends java.lang.Integer> - // f5: java.lang.Class<?> + // f5: java.lang.Class<?> } class AnyRefs { class A class B extends A - + def f1 = (new B: Any).getClass().newInstance() def f2 = (new B: AnyRef).getClass().newInstance() def f3 = (new B: A).getClass().newInstance() def f4 = (new B: B).getClass().newInstance() - + def f0[T >: B] = (new B: T).getClass().newInstance() def f5 = f0[Any] @@ -52,7 +52,7 @@ class MoreAnyRefs { object Test { def returnTypes[T: Manifest] = ( - manifest[T].erasure.getMethods.toList + manifest[T].erasure.getMethods.toList filter (_.getName startsWith "f") sortBy (_.getName) map (m => m.getName + ": " + m.getGenericReturnType.toString) diff --git a/test/files/run/hashhash.scala b/test/files/run/hashhash.scala index b9cec99a12..f9fc067398 100644 --- a/test/files/run/hashhash.scala +++ b/test/files/run/hashhash.scala @@ -6,5 +6,18 @@ object Test { /** Just a little sanity check, not to be confused with a unit test. */ List(5, 5.5f, "abc", new AnyRef, ()) foreach confirmSame List(5.0f, 1.0d, -(5.0f), (-1.0d)) foreach confirmDifferent + + val x = (BigInt(1) << 64).toDouble + val y: Any = x + val f: Float = x.toFloat + val jn: java.lang.Number = x + val jf: java.lang.Float = x.toFloat + val jd: java.lang.Double = x + + assert(x.## == y.##, ((x, y))) + assert(x.## == f.##, ((x, f))) + assert(x.## == jn.##, ((x, jn))) + assert(x.## == jf.##, ((x, jf))) + assert(x.## == jd.##, ((x, jd))) } } diff --git a/test/files/run/impconvtimes-msil.check b/test/files/run/impconvtimes-msil.check deleted file mode 100644 index 082377e474..0000000000 --- a/test/files/run/impconvtimes-msil.check +++ /dev/null @@ -1 +0,0 @@ -3.0 * Hour = Measure(3,Hour) diff --git a/test/files/run/infix-msil.check b/test/files/run/infix-msil.check deleted file mode 100644 index b37cdcd80b..0000000000 --- a/test/files/run/infix-msil.check +++ /dev/null @@ -1,2 +0,0 @@ -op(op(op(,0,0),1,1),2,2) -OK diff --git a/test/files/run/inline-ex-handlers.check b/test/files/run/inline-ex-handlers.check index 7a8a744bfa..708fcc6985 100644 --- a/test/files/run/inline-ex-handlers.check +++ b/test/files/run/inline-ex-handlers.check @@ -1,40 +1,44 @@ 172c172 -< locals: value x$1, value temp1 +< locals: value x$1, value x1 --- -> locals: value x$1, value temp1, variable boxed1 +> locals: value x$1, value x1, variable boxed1 174c174 < blocks: [1,2,3,4] --- -> blocks: [1,2,3] -187,189d186 -< 92 JUMP 4 -< -< 4: -195a193,194 +> blocks: [1,3,4] +186a187,188 > 92 STORE_LOCAL(variable boxed1) > 92 LOAD_LOCAL(variable boxed1) -386c385 -< blocks: [1,2,3,4,5,7,8,10] +195,197d196 +< 92 JUMP 2 +< +< 2: +385c384 +< blocks: [1,2,3,4,5,8,11,13,14,16] --- -> blocks: [1,2,3,4,5,7,8,10,11] -410c409,418 +> blocks: [1,2,3,5,8,11,13,14,16,17] +409c408,417 < 103 THROW(MyException) --- -> ? STORE_LOCAL(value ex$1) -> ? JUMP 11 +> ? STORE_LOCAL(value ex5) +> ? JUMP 17 > -> 11: -> 101 LOAD_LOCAL(value ex$1) -> 101 STORE_LOCAL(value temp2) -> 101 SCOPE_ENTER value temp2 -> 101 LOAD_LOCAL(value temp2) -> 101 IS_INSTANCE REF(class MyException) -> 101 CZJUMP (BOOL)NE ? 4 : 5 -501c509 +> 17: +> 101 LOAD_LOCAL(value ex5) +> 101 STORE_LOCAL(value x3) +> 101 SCOPE_ENTER value x3 +> 106 LOAD_LOCAL(value x3) +> 106 IS_INSTANCE REF(class MyException) +> 106 CZJUMP (BOOL)NE ? 5 : 11 +422,424d429 +< 101 JUMP 4 +< +< 4: +512c517 < blocks: [1,2,3,4,6,7,8,9,10] --- > blocks: [1,2,3,4,6,7,8,9,10,11,12,13] -530c538,543 +541c546,551 < 306 THROW(MyException) --- > ? JUMP 11 @@ -43,7 +47,7 @@ > ? LOAD_LOCAL(variable monitor4) > 305 MONITOR_EXIT > ? JUMP 12 -536c549,555 +547c557,563 < ? THROW(Throwable) --- > ? JUMP 12 @@ -53,7 +57,7 @@ > 304 MONITOR_EXIT > ? STORE_LOCAL(value t) > ? JUMP 13 -542c561,574 +553c569,582 < ? THROW(Throwable) --- > ? STORE_LOCAL(value t) @@ -70,19 +74,19 @@ > 310 CALL_PRIMITIVE(EndConcat) > 310 CALL_METHOD scala.Predef.println (dynamic) > 310 JUMP 2 -566c598 +577c606 < catch (Throwable) in ArrayBuffer(7, 8, 9, 10) starting at: 6 --- > catch (Throwable) in ArrayBuffer(7, 8, 9, 10, 11) starting at: 6 -569c601 +580c609 < catch (Throwable) in ArrayBuffer(4, 6, 7, 8, 9, 10) starting at: 3 --- > catch (Throwable) in ArrayBuffer(4, 6, 7, 8, 9, 10, 11, 12) starting at: 3 -601c633 +612c641 < blocks: [1,2,3,4,5,6,7,9,10] --- > blocks: [1,2,3,4,5,6,7,9,10,11,12] -625c657,663 +636c665,671 < 78 THROW(IllegalArgumentException) --- > ? STORE_LOCAL(value e) @@ -92,7 +96,7 @@ > 81 LOAD_LOCAL(value e) > ? STORE_LOCAL(variable exc1) > ? JUMP 12 -654c692,706 +665c700,714 < 81 THROW(Exception) --- > ? STORE_LOCAL(variable exc1) @@ -110,57 +114,53 @@ > 84 STORE_LOCAL(variable result) > 84 LOAD_LOCAL(variable exc1) > 84 THROW(Throwable) -676c728 +687c736 < catch (<none>) in ArrayBuffer(4, 6, 7, 9) starting at: 3 --- > catch (<none>) in ArrayBuffer(4, 6, 7, 9, 11) starting at: 3 -702c754 -< blocks: [1,2,3,4,5,6,7,8,11,12,13,14,15,16,18,19] +713c762 +< blocks: [1,2,3,4,5,6,9,12,14,17,18,19,22,25,27,28,30,31] --- -> blocks: [1,2,3,4,5,6,7,8,11,12,13,14,15,16,18,19,20,21,22] -726c778,787 +> blocks: [1,2,3,4,5,6,9,12,14,17,18,19,22,25,27,28,30,31,32,33,34] +737c786,793 < 172 THROW(MyException) --- -> ? STORE_LOCAL(value ex$4) -> ? JUMP 20 +> ? STORE_LOCAL(value ex5) +> ? JUMP 32 > -> 20: -> 170 LOAD_LOCAL(value ex$4) -> 170 STORE_LOCAL(value temp11) -> 170 SCOPE_ENTER value temp11 -> 170 LOAD_LOCAL(value temp11) -> 170 IS_INSTANCE REF(class MyException) -> 170 CZJUMP (BOOL)NE ? 12 : 13 -780c841,842 +> 32: +> 170 LOAD_LOCAL(value ex5) +> 170 STORE_LOCAL(value x3) +> 170 SCOPE_ENTER value x3 +> 170 JUMP 18 +793c849,850 < 177 THROW(MyException) --- -> ? STORE_LOCAL(value ex$5) -> ? JUMP 21 -784c846,855 +> ? STORE_LOCAL(value ex5) +> ? JUMP 33 +797c854,861 < 170 THROW(Throwable) --- -> ? STORE_LOCAL(value ex$5) -> ? JUMP 21 +> ? STORE_LOCAL(value ex5) +> ? JUMP 33 > -> 21: -> 169 LOAD_LOCAL(value ex$5) -> 169 STORE_LOCAL(value temp14) -> 169 SCOPE_ENTER value temp14 -> 169 LOAD_LOCAL(value temp14) -> 169 IS_INSTANCE REF(class MyException) -> 169 CZJUMP (BOOL)NE ? 5 : 6 -815c886,887 +> 33: +> 169 LOAD_LOCAL(value ex5) +> 169 STORE_LOCAL(value x3) +> 169 SCOPE_ENTER value x3 +> 169 JUMP 5 +830c894,895 < 182 THROW(MyException) --- > ? STORE_LOCAL(variable exc2) -> ? JUMP 22 -819c891,905 +> ? JUMP 34 +834c899,900 < 169 THROW(Throwable) --- > ? STORE_LOCAL(variable exc2) -> ? JUMP 22 -> -> 22: +> ? JUMP 34 +835a902,914 +> 34: > 184 LOAD_MODULE object Predef > 184 CONSTANT("finally") > 184 CALL_METHOD scala.Predef.println (dynamic) @@ -172,57 +172,60 @@ > 185 STORE_LOCAL(variable result) > 185 LOAD_LOCAL(variable exc2) > 185 THROW(Throwable) -841c927 -< catch (Throwable) in ArrayBuffer(11, 12, 13, 14, 15, 16, 18) starting at: 4 +> +856c935 +< catch (Throwable) in ArrayBuffer(17, 18, 19, 22, 25, 27, 28, 30) starting at: 4 --- -> catch (Throwable) in ArrayBuffer(11, 12, 13, 14, 15, 16, 18, 20) starting at: 4 -844c930 -< catch (<none>) in ArrayBuffer(4, 5, 6, 7, 11, 12, 13, 14, 15, 16, 18) starting at: 3 +> catch (Throwable) in ArrayBuffer(17, 18, 19, 22, 25, 27, 28, 30, 32) starting at: 4 +859c938 +< catch (<none>) in ArrayBuffer(4, 5, 6, 9, 12, 17, 18, 19, 22, 25, 27, 28, 30) starting at: 3 --- -> catch (<none>) in ArrayBuffer(4, 5, 6, 7, 11, 12, 13, 14, 15, 16, 18, 20, 21) starting at: 3 -870c956 -< blocks: [1,2,3,6,7,8,10,11,13] +> catch (<none>) in ArrayBuffer(4, 5, 6, 9, 12, 17, 18, 19, 22, 25, 27, 28, 30, 32, 33) starting at: 3 +885c964 +< blocks: [1,2,3,6,7,8,11,14,16,17,19] --- -> blocks: [1,2,3,6,7,8,10,11,13,14] -894c980,989 +> blocks: [1,2,3,6,7,8,11,14,16,17,19,20] +909c988,995 < 124 THROW(MyException) --- -> ? STORE_LOCAL(value ex$2) -> ? JUMP 14 +> ? STORE_LOCAL(value ex5) +> ? JUMP 20 > -> 14: -> 122 LOAD_LOCAL(value ex$2) -> 122 STORE_LOCAL(value temp5) -> 122 SCOPE_ENTER value temp5 -> 122 LOAD_LOCAL(value temp5) -> 122 IS_INSTANCE REF(class MyException) -> 122 CZJUMP (BOOL)NE ? 7 : 8 -942c1037 -< catch (IllegalArgumentException) in ArrayBuffer(6, 7, 8, 10, 11, 13) starting at: 3 ---- -> catch (IllegalArgumentException) in ArrayBuffer(6, 7, 8, 10, 11, 13, 14) starting at: 3 -968c1063 -< blocks: [1,2,3,4,5,9,10,11,13] ---- -> blocks: [1,2,3,4,5,9,10,11,13,14] -992c1087,1096 +> 20: +> 122 LOAD_LOCAL(value ex5) +> 122 STORE_LOCAL(value x3) +> 122 SCOPE_ENTER value x3 +> 122 JUMP 7 +969c1055 +< catch (IllegalArgumentException) in ArrayBuffer(6, 7, 8, 11, 14, 16, 17, 19) starting at: 3 +--- +> catch (IllegalArgumentException) in ArrayBuffer(6, 7, 8, 11, 14, 16, 17, 19, 20) starting at: 3 +995c1081 +< blocks: [1,2,3,4,5,8,11,15,16,17,19] +--- +> blocks: [1,2,3,5,8,11,15,16,17,19,20] +1019c1105,1114 < 148 THROW(MyException) --- -> ? STORE_LOCAL(value ex$3) -> ? JUMP 14 +> ? STORE_LOCAL(value ex5) +> ? JUMP 20 > -> 14: -> 145 LOAD_LOCAL(value ex$3) -> 145 STORE_LOCAL(value temp8) -> 145 SCOPE_ENTER value temp8 -> 145 LOAD_LOCAL(value temp8) -> 145 IS_INSTANCE REF(class MyException) -> 145 CZJUMP (BOOL)NE ? 4 : 5 -1236c1340 +> 20: +> 145 LOAD_LOCAL(value ex5) +> 145 STORE_LOCAL(value x3) +> 145 SCOPE_ENTER value x3 +> 154 LOAD_LOCAL(value x3) +> 154 IS_INSTANCE REF(class MyException) +> 154 CZJUMP (BOOL)NE ? 5 : 11 +1040,1042d1134 +< 145 JUMP 4 +< +< 4: +1275c1367 < blocks: [1,2,3,4,5,7] --- > blocks: [1,2,3,4,5,7,8] -1260c1364,1371 +1299c1391,1398 < 38 THROW(IllegalArgumentException) --- > ? STORE_LOCAL(value e) @@ -233,33 +236,37 @@ > 42 CONSTANT("IllegalArgumentException") > 42 CALL_METHOD scala.Predef.println (dynamic) > 42 JUMP 2 -1309c1420 -< blocks: [1,2,3,4,5,7,8,10,11,13] +1348c1447 +< blocks: [1,2,3,4,5,8,11,13,14,16,17,19] --- -> blocks: [1,2,3,4,5,7,8,10,11,13,14] -1333c1444,1445 +> blocks: [1,2,3,5,8,11,13,14,16,17,19,20] +1372c1471,1472 < 203 THROW(MyException) --- -> ? STORE_LOCAL(value ex$6) -> ? JUMP 14 -1353c1465,1474 +> ? STORE_LOCAL(value ex5) +> ? JUMP 20 +1392c1492,1501 < 209 THROW(MyException) --- -> ? STORE_LOCAL(value ex$6) -> ? JUMP 14 +> ? STORE_LOCAL(value ex5) +> ? JUMP 20 > -> 14: -> 200 LOAD_LOCAL(value ex$6) -> 200 STORE_LOCAL(value temp17) -> 200 SCOPE_ENTER value temp17 -> 200 LOAD_LOCAL(value temp17) -> 200 IS_INSTANCE REF(class MyException) -> 200 CZJUMP (BOOL)NE ? 4 : 5 -1416c1537 +> 20: +> 200 LOAD_LOCAL(value ex5) +> 200 STORE_LOCAL(value x3) +> 200 SCOPE_ENTER value x3 +> 212 LOAD_LOCAL(value x3) +> 212 IS_INSTANCE REF(class MyException) +> 212 CZJUMP (BOOL)NE ? 5 : 11 +1405,1407d1513 +< 200 JUMP 4 +< +< 4: +1467c1573 < blocks: [1,2,3,4,5,7] --- > blocks: [1,2,3,4,5,7,8] -1440c1561,1568 +1491c1597,1604 < 58 THROW(IllegalArgumentException) --- > ? STORE_LOCAL(value e) @@ -270,11 +277,11 @@ > 62 CONSTANT("RuntimeException") > 62 CALL_METHOD scala.Predef.println (dynamic) > 62 JUMP 2 -1489c1617 +1540c1653 < blocks: [1,2,3,4] --- > blocks: [1,2,3,4,5] -1509c1637,1642 +1560c1673,1678 < 229 THROW(MyException) --- > ? JUMP 5 @@ -283,19 +290,19 @@ > ? LOAD_LOCAL(variable monitor1) > 228 MONITOR_EXIT > 228 THROW(Throwable) -1515c1648 +1566c1684 < ? THROW(Throwable) --- > 228 THROW(Throwable) -1543c1676 +1594c1712 < locals: value args, variable result, variable monitor2, variable monitorResult1 --- > locals: value exception$1, value args, variable result, variable monitor2, variable monitorResult1 -1545c1678 +1596c1714 < blocks: [1,2,3,4] --- > blocks: [1,2,3,4,5] -1568c1701,1709 +1619c1737,1745 < 245 THROW(MyException) --- > ? STORE_LOCAL(value exception$1) @@ -307,7 +314,7 @@ > ? LOAD_LOCAL(variable monitor2) > 244 MONITOR_EXIT > 244 THROW(Throwable) -1574c1715 +1625c1751 < ? THROW(Throwable) --- > 244 THROW(Throwable) diff --git a/test/files/run/interop_classmanifests_arepartially_typetags.check b/test/files/run/interop_classmanifests_arepartially_typetags.check new file mode 100644 index 0000000000..3dfcdccbec --- /dev/null +++ b/test/files/run/interop_classmanifests_arepartially_typetags.check @@ -0,0 +1,6 @@ +T
+int
+T
+class java.lang.String
+T
+class [I
diff --git a/test/files/run/interop_classmanifests_arepartially_typetags.scala b/test/files/run/interop_classmanifests_arepartially_typetags.scala new file mode 100644 index 0000000000..9bc1f32e86 --- /dev/null +++ b/test/files/run/interop_classmanifests_arepartially_typetags.scala @@ -0,0 +1,10 @@ +object Test extends App { + def classManifestIspartiallyTypeTag[T: ClassManifest] = { + println(typeTag[T].tpe) + println(typeTag[T].erasure) + } + + classManifestIspartiallyTypeTag[Int] + classManifestIspartiallyTypeTag[String] + classManifestIspartiallyTypeTag[Array[Int]] +}
\ No newline at end of file diff --git a/test/files/run/interop_classtags_are_classmanifests.check b/test/files/run/interop_classtags_are_classmanifests.check new file mode 100644 index 0000000000..02393dff23 --- /dev/null +++ b/test/files/run/interop_classtags_are_classmanifests.check @@ -0,0 +1,6 @@ +Int
+java.lang.String
+Array[Int]
+Int
+java.lang.String
+Array[Int]
diff --git a/test/files/run/interop_classtags_are_classmanifests.scala b/test/files/run/interop_classtags_are_classmanifests.scala new file mode 100644 index 0000000000..309c99a3f5 --- /dev/null +++ b/test/files/run/interop_classtags_are_classmanifests.scala @@ -0,0 +1,17 @@ +object Test extends App { + def arrayTagIsClassManifest[T: ArrayTag] = { + println(classManifest[T]) + } + + arrayTagIsClassManifest[Int] + arrayTagIsClassManifest[String] + arrayTagIsClassManifest[Array[Int]] + + def classTagIsClassManifest[T: ClassTag] = { + println(classManifest[T]) + } + + classTagIsClassManifest[Int] + classTagIsClassManifest[String] + classTagIsClassManifest[Array[Int]] +}
\ No newline at end of file diff --git a/test/files/run/interop_concretetypetags_are_classmanifests.check b/test/files/run/interop_concretetypetags_are_classmanifests.check new file mode 100644 index 0000000000..c59e92d4eb --- /dev/null +++ b/test/files/run/interop_concretetypetags_are_classmanifests.check @@ -0,0 +1,3 @@ +Int
+java.lang.String
+Array[Int]
diff --git a/test/files/run/interop_concretetypetags_are_classmanifests.scala b/test/files/run/interop_concretetypetags_are_classmanifests.scala new file mode 100644 index 0000000000..b578d7e626 --- /dev/null +++ b/test/files/run/interop_concretetypetags_are_classmanifests.scala @@ -0,0 +1,9 @@ +object Test extends App { + def concreteTypeTagIsClassManifest[T: ConcreteTypeTag] = { + println(classManifest[T]) + } + + concreteTypeTagIsClassManifest[Int] + concreteTypeTagIsClassManifest[String] + concreteTypeTagIsClassManifest[Array[Int]] +}
\ No newline at end of file diff --git a/test/files/run/interop_concretetypetags_are_manifests.check b/test/files/run/interop_concretetypetags_are_manifests.check new file mode 100644 index 0000000000..c59e92d4eb --- /dev/null +++ b/test/files/run/interop_concretetypetags_are_manifests.check @@ -0,0 +1,3 @@ +Int
+java.lang.String
+Array[Int]
diff --git a/test/files/run/interop_concretetypetags_are_manifests.scala b/test/files/run/interop_concretetypetags_are_manifests.scala new file mode 100644 index 0000000000..731410bc10 --- /dev/null +++ b/test/files/run/interop_concretetypetags_are_manifests.scala @@ -0,0 +1,9 @@ +object Test extends App { + def concreteTypeTagIsManifest[T: ConcreteTypeTag] = { + println(manifest[T]) + } + + concreteTypeTagIsManifest[Int] + concreteTypeTagIsManifest[String] + concreteTypeTagIsManifest[Array[Int]] +}
\ No newline at end of file diff --git a/test/files/run/interop_manifests_are_classtags.check b/test/files/run/interop_manifests_are_classtags.check new file mode 100644 index 0000000000..07ff6b984a --- /dev/null +++ b/test/files/run/interop_manifests_are_classtags.check @@ -0,0 +1,24 @@ +Int
+Int
+List()
+List(0, 0, 0, 0, 0)
+java.lang.String
+java.lang.String
+List()
+List(null, null, null, null, null)
+Array[Int]
+Array[Int]
+List()
+List(null, null, null, null, null)
+Int
+Int
+List()
+List(0, 0, 0, 0, 0)
+java.lang.String
+java.lang.String
+List()
+List(null, null, null, null, null)
+Array[Int]
+Array[Int]
+List()
+List(null, null, null, null, null)
diff --git a/test/files/run/interop_manifests_are_classtags.scala b/test/files/run/interop_manifests_are_classtags.scala new file mode 100644 index 0000000000..582cea3467 --- /dev/null +++ b/test/files/run/interop_manifests_are_classtags.scala @@ -0,0 +1,23 @@ +object Test extends App { + def classManifestIsClassTag[T: ClassManifest] = { + println(arrayTag[T]) + println(erasureTag[T]) + println(Array[T]().toList) + println(new Array[T](5).toList) + } + + classManifestIsClassTag[Int] + classManifestIsClassTag[String] + classManifestIsClassTag[Array[Int]] + + def manifestIsClassTag[T: Manifest] = { + println(arrayTag[T]) + println(erasureTag[T]) + println(Array[T]().toList) + println(new Array[T](5).toList) + } + + manifestIsClassTag[Int] + manifestIsClassTag[String] + manifestIsClassTag[Array[Int]] +}
\ No newline at end of file diff --git a/test/files/run/interop_manifests_are_concretetypetags.check b/test/files/run/interop_manifests_are_concretetypetags.check new file mode 100644 index 0000000000..edab85ecf1 --- /dev/null +++ b/test/files/run/interop_manifests_are_concretetypetags.check @@ -0,0 +1,6 @@ +Int +int +String +class java.lang.String +Array[Int] +class [I diff --git a/test/files/run/interop_manifests_are_concretetypetags.scala b/test/files/run/interop_manifests_are_concretetypetags.scala new file mode 100644 index 0000000000..0b82a56d0a --- /dev/null +++ b/test/files/run/interop_manifests_are_concretetypetags.scala @@ -0,0 +1,10 @@ +object Test extends App { + def manifestIsConcreteTypeTag[T: Manifest] = { + println(concreteTypeTag[T].tpe) + println(concreteTypeTag[T].erasure) + } + + manifestIsConcreteTypeTag[Int] + manifestIsConcreteTypeTag[String] + manifestIsConcreteTypeTag[Array[Int]] +}
\ No newline at end of file diff --git a/test/files/run/interop_manifests_are_typetags.check b/test/files/run/interop_manifests_are_typetags.check new file mode 100644 index 0000000000..edab85ecf1 --- /dev/null +++ b/test/files/run/interop_manifests_are_typetags.check @@ -0,0 +1,6 @@ +Int +int +String +class java.lang.String +Array[Int] +class [I diff --git a/test/files/run/interop_manifests_are_typetags.scala b/test/files/run/interop_manifests_are_typetags.scala new file mode 100644 index 0000000000..03a7b7b6d5 --- /dev/null +++ b/test/files/run/interop_manifests_are_typetags.scala @@ -0,0 +1,10 @@ +object Test extends App { + def manifestIsTypeTag[T: Manifest] = { + println(typeTag[T].tpe) + println(typeTag[T].erasure) + } + + manifestIsTypeTag[Int] + manifestIsTypeTag[String] + manifestIsTypeTag[Array[Int]] +}
\ No newline at end of file diff --git a/test/files/run/iq-msil.check b/test/files/run/iq-msil.check deleted file mode 100644 index 08f9fc755e..0000000000 --- a/test/files/run/iq-msil.check +++ /dev/null @@ -1,12 +0,0 @@ -Empty -Head: 42 -q5: Queue(0,1,2,3,4,5,6,7,8,9) -q5[5]: 5 -q5 == q5c: True -q5c == q5: True -q8: Queue(2,3,4,5,6,7,8,9,10,11) -q8 == q9: True -Elements: 1 2 3 4 5 6 7 8 9 -String: <1-2-3-4-5-6-7-8-9> -Length: 9 -Front: 1 diff --git a/test/files/run/lazy-locals.check b/test/files/run/lazy-locals.check index 7d14da243b..d1cc754f2c 100644 --- a/test/files/run/lazy-locals.check +++ b/test/files/run/lazy-locals.check @@ -36,30 +36,19 @@ forced lazy val t02 forced lazy val t01 forced lazy val t00 Sum is: 496 -forced lazy val t32 -forced lazy val t31 -forced lazy val t30 -forced lazy val t29 -forced lazy val t28 -forced lazy val t27 -forced lazy val t26 -forced lazy val t25 -forced lazy val t24 -forced lazy val t23 -forced lazy val t22 -forced lazy val t21 -forced lazy val t20 -forced lazy val t19 -forced lazy val t18 -forced lazy val t17 -forced lazy val t16 -forced lazy val t15 -forced lazy val t14 -forced lazy val t13 -forced lazy val t12 -forced lazy val t11 -forced lazy val t10 -forced lazy val t09 +Sum again is: 496 +Sum again again is: 496 +forced lazy val t07 +forced lazy val t06 +forced lazy val t05 +forced lazy val t04 +forced lazy val t03 +forced lazy val t02 +forced lazy val t01 +forced lazy val t00 +Sum is: 28 +Sum again is: 28 +Sum again again is: 28 forced lazy val t08 forced lazy val t07 forced lazy val t06 @@ -69,7 +58,9 @@ forced lazy val t03 forced lazy val t02 forced lazy val t01 forced lazy val t00 -Sum is: 528 +Sum is: 36 +Sum again is: 36 +Sum again again is: 36 forced lazy val t at n = 0 42 forced lazy val t at n = 0 diff --git a/test/files/run/lazy-locals.scala b/test/files/run/lazy-locals.scala index 696aeeba96..aca15d0357 100644 --- a/test/files/run/lazy-locals.scala +++ b/test/files/run/lazy-locals.scala @@ -13,7 +13,7 @@ object Test extends App { 1 + t + t } - /** test 32 lazy vals, which fills one bitmap int. */ + /** test 32 lazy vals, which should spill over multiple byte bitmaps. */ def testLazy32 = { lazy val t00 = { Console.println("forced lazy val t00"); 0 } lazy val t01 = { Console.println("forced lazy val t01"); 1 } @@ -51,12 +51,25 @@ object Test extends App { val sum = t31 + t30 + t29 + t28 + t27 + t26 + t25 + t24 + t23 + t22 + t21 + t20 + t19 + t18 + t17 + t16 + t15 + t14 + t13 + t12 + t11 + t10 + t09 + t08 + t07 + t06 + t05 + - t04 + t03 + t02 + t01 + t00; - println("Sum is: " + sum); + t04 + t03 + t02 + t01 + t00 + val sum2 = t31 + t30 + t29 + t28 + t27 + t26 + t25 + t24 + t23 + + t22 + t21 + t20 + t19 + t18 + t17 + t16 + t15 + t14 + + t13 + t12 + t11 + t10 + t09 + t08 + t07 + t06 + t05 + + t04 + t03 + t02 + t01 + t00 + val sum3 = t00 + t01 + t02 + t03 + t04 + t05 + t06 + t07 + t08 + + t09 + t10 + t11 + t12 + t13 + t14 + t15 + t16 + t17 + + t18 + t19 + t20 + t21 + t22 + t23 + t24 + t25 + t26 + + t27 + t28 + t29 + t30 + t31 + + + + println("Sum is: " + sum) + println("Sum again is: " + sum2) + println("Sum again again is: " + sum3) } - /** test 32 lazy vals, which needs two bitmap ints. */ - def testLazy33 = { + /** test 8 lazy vals, which should fit one byte bitmap. */ + def testLazy8 = { lazy val t00 = { Console.println("forced lazy val t00"); 0 } lazy val t01 = { Console.println("forced lazy val t01"); 1 } lazy val t02 = { Console.println("forced lazy val t02"); 2 } @@ -65,39 +78,38 @@ object Test extends App { lazy val t05 = { Console.println("forced lazy val t05"); 5 } lazy val t06 = { Console.println("forced lazy val t06"); 6 } lazy val t07 = { Console.println("forced lazy val t07"); 7 } - lazy val t08 = { Console.println("forced lazy val t08"); 8 } - lazy val t09 = { Console.println("forced lazy val t09"); 9 } - lazy val t10 = { Console.println("forced lazy val t10"); 10 } - lazy val t11 = { Console.println("forced lazy val t11"); 11 } - lazy val t12 = { Console.println("forced lazy val t12"); 12 } - lazy val t13 = { Console.println("forced lazy val t13"); 13 } - lazy val t14 = { Console.println("forced lazy val t14"); 14 } - lazy val t15 = { Console.println("forced lazy val t15"); 15 } - lazy val t16 = { Console.println("forced lazy val t16"); 16 } - lazy val t17 = { Console.println("forced lazy val t17"); 17 } - lazy val t18 = { Console.println("forced lazy val t18"); 18 } - lazy val t19 = { Console.println("forced lazy val t19"); 19 } - lazy val t20 = { Console.println("forced lazy val t20"); 20 } - lazy val t21 = { Console.println("forced lazy val t21"); 21 } - lazy val t22 = { Console.println("forced lazy val t22"); 22 } - lazy val t23 = { Console.println("forced lazy val t23"); 23 } - lazy val t24 = { Console.println("forced lazy val t24"); 24 } - lazy val t25 = { Console.println("forced lazy val t25"); 25 } - lazy val t26 = { Console.println("forced lazy val t26"); 26 } - lazy val t27 = { Console.println("forced lazy val t27"); 27 } - lazy val t28 = { Console.println("forced lazy val t28"); 28 } - lazy val t29 = { Console.println("forced lazy val t29"); 29 } - lazy val t30 = { Console.println("forced lazy val t30"); 30 } - lazy val t31 = { Console.println("forced lazy val t31"); 31 } - lazy val t32 = { Console.println("forced lazy val t32"); 32 } - val sum = t32 + t31 + t30 + t29 + t28 + t27 + t26 + t25 + t24 + t23 + - t22 + t21 + t20 + t19 + t18 + t17 + t16 + t15 + t14 + - t13 + t12 + t11 + t10 + t09 + t08 + t07 + t06 + t05 + - t04 + t03 + t02 + t01 + t00; - println("Sum is: " + sum); + val sum = t07 + t06 + t05 + t04 + t03 + t02 + t01 + t00 + val sum2 = t07 + t06 + t05 + t04 + t03 + t02 + t01 + t00 + val sum3 = t00 + t01 + t02 + t03 + t04 + t05 + t06 + t07 + + + + println("Sum is: " + sum) + println("Sum again is: " + sum2) + println("Sum again again is: " + sum3) } + /** test 9 lazy vals, which should spill over two bitmaps. */ + def testLazy9 = { + lazy val t00 = { Console.println("forced lazy val t00"); 0 } + lazy val t01 = { Console.println("forced lazy val t01"); 1 } + lazy val t02 = { Console.println("forced lazy val t02"); 2 } + lazy val t03 = { Console.println("forced lazy val t03"); 3 } + lazy val t04 = { Console.println("forced lazy val t04"); 4 } + lazy val t05 = { Console.println("forced lazy val t05"); 5 } + lazy val t06 = { Console.println("forced lazy val t06"); 6 } + lazy val t07 = { Console.println("forced lazy val t07"); 7 } + lazy val t08 = { Console.println("forced lazy val t08"); 8 } + + val sum = t08 + t07 + t06 + t05 + t04 + t03 + t02 + t01 + t00 + val sum2 = t08 + t07 + t06 + t05 + t04 + t03 + t02 + t01 + t00 + val sum3 = t00 + t01 + t02 + t03 + t04 + t05 + t06 + t07 + t08 + + println("Sum is: " + sum) + println("Sum again is: " + sum2) + println("Sum again again is: " + sum3) + } /** test recursive method with lazy vals and a single forced */ def testLazyRec(n: Int): Int = { @@ -185,7 +197,8 @@ object Test extends App { println(testLazy) testLazy32 - testLazy33 + testLazy8 + testLazy9 println(testLazyRec(5)) println(testLazyRecMany(5)) testRecVal diff --git a/test/files/run/macro-abort-fresh.flags b/test/files/run/macro-abort-fresh.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-abort-fresh.flags +++ b/test/files/run/macro-abort-fresh.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-abort-fresh/Test_2.scala b/test/files/run/macro-abort-fresh/Test_2.scala index f389231ca6..ecf48b9752 100644 --- a/test/files/run/macro-abort-fresh/Test_2.scala +++ b/test/files/run/macro-abort-fresh/Test_2.scala @@ -1,6 +1,6 @@ object Test extends App { import scala.reflect.mirror._ val tree = Select(Ident("Macros"), newTermName("foo")) - try tree.eval + try Expr(tree).eval catch { case ex: Throwable => println(ex.getMessage) } }
\ No newline at end of file diff --git a/test/files/run/macro-basic-ma-md-mi.flags b/test/files/run/macro-basic-ma-md-mi.flags index 06a7b31f11..5e5dd6ce79 100644 --- a/test/files/run/macro-basic-ma-md-mi.flags +++ b/test/files/run/macro-basic-ma-md-mi.flags @@ -1 +1 @@ --Xmacros +-language:experimental.macros diff --git a/test/files/run/macro-basic-ma-mdmi.flags b/test/files/run/macro-basic-ma-mdmi.flags index 06a7b31f11..5e5dd6ce79 100644 --- a/test/files/run/macro-basic-ma-mdmi.flags +++ b/test/files/run/macro-basic-ma-mdmi.flags @@ -1 +1 @@ --Xmacros +-language:experimental.macros diff --git a/test/files/run/macro-basic-mamd-mi.flags b/test/files/run/macro-basic-mamd-mi.flags index 06a7b31f11..5e5dd6ce79 100644 --- a/test/files/run/macro-basic-mamd-mi.flags +++ b/test/files/run/macro-basic-mamd-mi.flags @@ -1 +1 @@ --Xmacros +-language:experimental.macros diff --git a/test/files/run/macro-basic-mamd-mi/Impls_1.scala b/test/files/run/macro-basic-mamd-mi/Impls_1.scala index eadb63fa8e..82d2cce2f5 100644 --- a/test/files/run/macro-basic-mamd-mi/Impls_1.scala +++ b/test/files/run/macro-basic-mamd-mi/Impls_1.scala @@ -3,12 +3,12 @@ import scala.reflect.makro.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.mirror._ - Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))) + Expr(Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1))))) } def bar(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.mirror._ - Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2)))) + Expr(Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2))))) } def quux(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { diff --git a/test/files/run/macro-bodyexpandstoimpl.flags b/test/files/run/macro-bodyexpandstoimpl.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-bodyexpandstoimpl.flags +++ b/test/files/run/macro-bodyexpandstoimpl.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-annotation.flags b/test/files/run/macro-declared-in-annotation.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-annotation.flags +++ b/test/files/run/macro-declared-in-annotation.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-annotation/Macros_2.scala b/test/files/run/macro-declared-in-annotation/Macros_2.scala index a565849aa9..40d71c62fb 100644 --- a/test/files/run/macro-declared-in-annotation/Macros_2.scala +++ b/test/files/run/macro-declared-in-annotation/Macros_2.scala @@ -1,4 +1,4 @@ -class foo(val bar: String) extends StaticAnnotation +class foo(val bar: String) extends annotation.StaticAnnotation object Api { // foo in ann must have a different name diff --git a/test/files/run/macro-declared-in-anonymous.flags b/test/files/run/macro-declared-in-anonymous.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-anonymous.flags +++ b/test/files/run/macro-declared-in-anonymous.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-block.flags b/test/files/run/macro-declared-in-block.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-block.flags +++ b/test/files/run/macro-declared-in-block.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-class-class.flags b/test/files/run/macro-declared-in-class-class.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-class-class.flags +++ b/test/files/run/macro-declared-in-class-class.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-class-object.flags b/test/files/run/macro-declared-in-class-object.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-class-object.flags +++ b/test/files/run/macro-declared-in-class-object.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-class.flags b/test/files/run/macro-declared-in-class.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-class.flags +++ b/test/files/run/macro-declared-in-class.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-default-param.flags b/test/files/run/macro-declared-in-default-param.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-default-param.flags +++ b/test/files/run/macro-declared-in-default-param.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-implicit-class.flags b/test/files/run/macro-declared-in-implicit-class.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-implicit-class.flags +++ b/test/files/run/macro-declared-in-implicit-class.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-method.flags b/test/files/run/macro-declared-in-method.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-method.flags +++ b/test/files/run/macro-declared-in-method.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-object-class.flags b/test/files/run/macro-declared-in-object-class.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-object-class.flags +++ b/test/files/run/macro-declared-in-object-class.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-object-object.flags b/test/files/run/macro-declared-in-object-object.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-object-object.flags +++ b/test/files/run/macro-declared-in-object-object.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-object.flags b/test/files/run/macro-declared-in-object.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-object.flags +++ b/test/files/run/macro-declared-in-object.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-package-object.flags b/test/files/run/macro-declared-in-package-object.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-package-object.flags +++ b/test/files/run/macro-declared-in-package-object.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-refinement.flags b/test/files/run/macro-declared-in-refinement.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-refinement.flags +++ b/test/files/run/macro-declared-in-refinement.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-trait.flags b/test/files/run/macro-declared-in-trait.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-trait.flags +++ b/test/files/run/macro-declared-in-trait.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-def-infer-return-type-a.flags b/test/files/run/macro-def-infer-return-type-a.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-def-infer-return-type-a.flags +++ b/test/files/run/macro-def-infer-return-type-a.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-def-infer-return-type-b.flags b/test/files/run/macro-def-infer-return-type-b.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-def-infer-return-type-b.flags +++ b/test/files/run/macro-def-infer-return-type-b.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-def-infer-return-type-b/Test_2.scala b/test/files/run/macro-def-infer-return-type-b/Test_2.scala index 8ff4494750..f8f15b4224 100644 --- a/test/files/run/macro-def-infer-return-type-b/Test_2.scala +++ b/test/files/run/macro-def-infer-return-type-b/Test_2.scala @@ -1,6 +1,6 @@ object Test extends App { import scala.reflect.mirror._ val tree = Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant(42)))) - try tree.eval + try Expr(tree).eval catch { case ex: Throwable => println(ex.getMessage) } }
\ No newline at end of file diff --git a/test/files/run/macro-def-infer-return-type-c.flags b/test/files/run/macro-def-infer-return-type-c.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-def-infer-return-type-c.flags +++ b/test/files/run/macro-def-infer-return-type-c.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-def-path-dependent-a.flags b/test/files/run/macro-def-path-dependent-a.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-def-path-dependent-a.flags +++ b/test/files/run/macro-def-path-dependent-a.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-def-path-dependent-b.flags b/test/files/run/macro-def-path-dependent-b.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-def-path-dependent-b.flags +++ b/test/files/run/macro-def-path-dependent-b.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-def-path-dependent-c.flags b/test/files/run/macro-def-path-dependent-c.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-def-path-dependent-c.flags +++ b/test/files/run/macro-def-path-dependent-c.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-def-path-dependent-d.flags b/test/files/run/macro-def-path-dependent-d.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-def-path-dependent-d.flags +++ b/test/files/run/macro-def-path-dependent-d.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-implicit-macro-has-implicit.flags b/test/files/run/macro-expand-implicit-macro-has-implicit.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-implicit-macro-has-implicit.flags +++ b/test/files/run/macro-expand-implicit-macro-has-implicit.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-implicit-macro-is-implicit.flags b/test/files/run/macro-expand-implicit-macro-is-implicit.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-implicit-macro-is-implicit.flags +++ b/test/files/run/macro-expand-implicit-macro-is-implicit.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-implicit-macro-is-val.flags b/test/files/run/macro-expand-implicit-macro-is-val.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-implicit-macro-is-val.flags +++ b/test/files/run/macro-expand-implicit-macro-is-val.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-implicit-macro-is-view.flags b/test/files/run/macro-expand-implicit-macro-is-view.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-implicit-macro-is-view.flags +++ b/test/files/run/macro-expand-implicit-macro-is-view.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-multiple-arglists.flags b/test/files/run/macro-expand-multiple-arglists.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-multiple-arglists.flags +++ b/test/files/run/macro-expand-multiple-arglists.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-nullary-generic.flags b/test/files/run/macro-expand-nullary-generic.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-nullary-generic.flags +++ b/test/files/run/macro-expand-nullary-generic.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-nullary-nongeneric.flags b/test/files/run/macro-expand-nullary-nongeneric.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-nullary-nongeneric.flags +++ b/test/files/run/macro-expand-nullary-nongeneric.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-overload.flags b/test/files/run/macro-expand-overload.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-overload.flags +++ b/test/files/run/macro-expand-overload.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-override.flags b/test/files/run/macro-expand-override.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-override.flags +++ b/test/files/run/macro-expand-override.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-recursive.flags b/test/files/run/macro-expand-recursive.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-recursive.flags +++ b/test/files/run/macro-expand-recursive.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-bounds-a.flags b/test/files/run/macro-expand-tparams-bounds-a.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-tparams-bounds-a.flags +++ b/test/files/run/macro-expand-tparams-bounds-a.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-bounds-a/Impls_1.scala b/test/files/run/macro-expand-tparams-bounds-a/Impls_1.scala index 4cd98c5838..5019d5d4a7 100644 --- a/test/files/run/macro-expand-tparams-bounds-a/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-bounds-a/Impls_1.scala @@ -1,8 +1,5 @@ import scala.reflect.makro.{Context => Ctx} object Impls { - def foo[U <: String](c: Ctx): c.Expr[Unit] = { - import c.mirror._ - Literal(Constant(())) - } + def foo[U <: String](c: Ctx): c.Expr[Unit] = c.literalUnit } diff --git a/test/files/run/macro-expand-tparams-bounds-b.flags b/test/files/run/macro-expand-tparams-bounds-b.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-tparams-bounds-b.flags +++ b/test/files/run/macro-expand-tparams-bounds-b.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-bounds-b/Impls_1.scala b/test/files/run/macro-expand-tparams-bounds-b/Impls_1.scala index 9103ddb08a..abd68696b6 100644 --- a/test/files/run/macro-expand-tparams-bounds-b/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-bounds-b/Impls_1.scala @@ -3,8 +3,5 @@ import scala.reflect.makro.{Context => Ctx} class C object Impls { - def foo[U <: C](c: Ctx): c.Expr[Unit] = { - import c.mirror._ - Literal(Constant(())) - } + def foo[U <: C](c: Ctx): c.Expr[Unit] = c.literalUnit } diff --git a/test/files/run/macro-expand-tparams-explicit.flags b/test/files/run/macro-expand-tparams-explicit.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-tparams-explicit.flags +++ b/test/files/run/macro-expand-tparams-explicit.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-implicit.flags b/test/files/run/macro-expand-tparams-implicit.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-tparams-implicit.flags +++ b/test/files/run/macro-expand-tparams-implicit.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-only-in-impl.flags b/test/files/run/macro-expand-tparams-only-in-impl.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-tparams-only-in-impl.flags +++ b/test/files/run/macro-expand-tparams-only-in-impl.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-only-in-impl/Impls_1.scala b/test/files/run/macro-expand-tparams-only-in-impl/Impls_1.scala index 4cd98c5838..5019d5d4a7 100644 --- a/test/files/run/macro-expand-tparams-only-in-impl/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-only-in-impl/Impls_1.scala @@ -1,8 +1,5 @@ import scala.reflect.makro.{Context => Ctx} object Impls { - def foo[U <: String](c: Ctx): c.Expr[Unit] = { - import c.mirror._ - Literal(Constant(())) - } + def foo[U <: String](c: Ctx): c.Expr[Unit] = c.literalUnit } diff --git a/test/files/run/macro-expand-tparams-optional.flags b/test/files/run/macro-expand-tparams-optional.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-tparams-optional.flags +++ b/test/files/run/macro-expand-tparams-optional.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-a.flags b/test/files/run/macro-expand-tparams-prefix-a.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-tparams-prefix-a.flags +++ b/test/files/run/macro-expand-tparams-prefix-a.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-b.flags b/test/files/run/macro-expand-tparams-prefix-b.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-tparams-prefix-b.flags +++ b/test/files/run/macro-expand-tparams-prefix-b.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-c1.flags b/test/files/run/macro-expand-tparams-prefix-c1.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-tparams-prefix-c1.flags +++ b/test/files/run/macro-expand-tparams-prefix-c1.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-c1/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix-c1/Impls_1.scala index bc880fdf77..4da5a9b823 100644 --- a/test/files/run/macro-expand-tparams-prefix-c1/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-prefix-c1/Impls_1.scala @@ -3,10 +3,10 @@ import scala.reflect.makro.{Context => Ctx} object Impls { def foo[T, U: c.TypeTag, V](c: Ctx)(implicit T: c.TypeTag[T], V: c.TypeTag[V]): c.Expr[Unit] = { import c.mirror._ - Block(List( + Expr(Block(List( Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.TypeTag[U]].toString)))), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))), - Literal(Constant(()))) + Literal(Constant(())))) } } diff --git a/test/files/run/macro-expand-tparams-prefix-c2.flags b/test/files/run/macro-expand-tparams-prefix-c2.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-tparams-prefix-c2.flags +++ b/test/files/run/macro-expand-tparams-prefix-c2.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-c2/Impls_Macros_1.scala b/test/files/run/macro-expand-tparams-prefix-c2/Impls_Macros_1.scala index c83e401afb..4d137a4aef 100644 --- a/test/files/run/macro-expand-tparams-prefix-c2/Impls_Macros_1.scala +++ b/test/files/run/macro-expand-tparams-prefix-c2/Impls_Macros_1.scala @@ -3,11 +3,11 @@ import scala.reflect.makro.{Context => Ctx} object Impls { def foo[T, U: c.TypeTag, V](c: Ctx)(implicit T: c.TypeTag[T], V: c.TypeTag[V]): c.Expr[Unit] = { import c.mirror._ - Block(List( + Expr(Block(List( Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.TypeTag[U]].toString)))), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))), - Literal(Constant(()))) + Literal(Constant(())))) } } diff --git a/test/files/run/macro-expand-tparams-prefix-d1.flags b/test/files/run/macro-expand-tparams-prefix-d1.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-tparams-prefix-d1.flags +++ b/test/files/run/macro-expand-tparams-prefix-d1.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-d1/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix-d1/Impls_1.scala index bc880fdf77..4da5a9b823 100644 --- a/test/files/run/macro-expand-tparams-prefix-d1/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-prefix-d1/Impls_1.scala @@ -3,10 +3,10 @@ import scala.reflect.makro.{Context => Ctx} object Impls { def foo[T, U: c.TypeTag, V](c: Ctx)(implicit T: c.TypeTag[T], V: c.TypeTag[V]): c.Expr[Unit] = { import c.mirror._ - Block(List( + Expr(Block(List( Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.TypeTag[U]].toString)))), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))), - Literal(Constant(()))) + Literal(Constant(())))) } } diff --git a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad.flags b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad.flags +++ b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala index 523c6b0645..01fc9d4462 100644 --- a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala +++ b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala @@ -5,6 +5,6 @@ object Macros { object Test extends App { import scala.reflect.mirror._ val tree = Apply(Select(Ident("Macros"), newTermName("foo")), List(Typed(Apply(Ident(definitions.ListModule), List(Literal(Constant(1)), Literal(Constant(2)))), Ident(tpnme.WILDCARD_STAR)))) - try tree.eval + try Expr(tree).eval catch { case ex: Throwable => println(ex.getMessage) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good.flags b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good.flags +++ b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-varargs-explicit-over-varargs.flags b/test/files/run/macro-expand-varargs-explicit-over-varargs.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-varargs-explicit-over-varargs.flags +++ b/test/files/run/macro-expand-varargs-explicit-over-varargs.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-varargs-implicit-over-nonvarargs.flags b/test/files/run/macro-expand-varargs-implicit-over-nonvarargs.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-varargs-implicit-over-nonvarargs.flags +++ b/test/files/run/macro-expand-varargs-implicit-over-nonvarargs.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-varargs-implicit-over-varargs.flags b/test/files/run/macro-expand-varargs-implicit-over-varargs.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-varargs-implicit-over-varargs.flags +++ b/test/files/run/macro-expand-varargs-implicit-over-varargs.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-impl-default-params.flags b/test/files/run/macro-impl-default-params.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-impl-default-params.flags +++ b/test/files/run/macro-impl-default-params.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-impl-rename-context.flags b/test/files/run/macro-impl-rename-context.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-impl-rename-context.flags +++ b/test/files/run/macro-impl-rename-context.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype.flags b/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype.flags +++ b/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Impls_Macros_1.scala b/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Impls_Macros_1.scala index 882867fcab..828ccf34e2 100644 --- a/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Impls_Macros_1.scala +++ b/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Impls_Macros_1.scala @@ -3,7 +3,7 @@ import scala.reflect.makro.{Context => Ctx} object Impls { def foo(c: Ctx): c.Expr[Int] = { import c.mirror._ - Literal(Constant("42")) + Expr(Literal(Constant("42"))) } } diff --git a/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Test_2.scala b/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Test_2.scala index f389231ca6..ecf48b9752 100644 --- a/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Test_2.scala +++ b/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Test_2.scala @@ -1,6 +1,6 @@ object Test extends App { import scala.reflect.mirror._ val tree = Select(Ident("Macros"), newTermName("foo")) - try tree.eval + try Expr(tree).eval catch { case ex: Throwable => println(ex.getMessage) } }
\ No newline at end of file diff --git a/test/files/run/macro-invalidret-doesnt-conform-to-impl-rettype.flags b/test/files/run/macro-invalidret-doesnt-conform-to-impl-rettype.flags deleted file mode 100644 index 7fea2ff901..0000000000 --- a/test/files/run/macro-invalidret-doesnt-conform-to-impl-rettype.flags +++ /dev/null @@ -1 +0,0 @@ --Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-invalidret-nontypeable.flags b/test/files/run/macro-invalidret-nontypeable.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-invalidret-nontypeable.flags +++ b/test/files/run/macro-invalidret-nontypeable.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-invalidret-nontypeable/Test_2.scala b/test/files/run/macro-invalidret-nontypeable/Test_2.scala index f389231ca6..ecf48b9752 100644 --- a/test/files/run/macro-invalidret-nontypeable/Test_2.scala +++ b/test/files/run/macro-invalidret-nontypeable/Test_2.scala @@ -1,6 +1,6 @@ object Test extends App { import scala.reflect.mirror._ val tree = Select(Ident("Macros"), newTermName("foo")) - try tree.eval + try Expr(tree).eval catch { case ex: Throwable => println(ex.getMessage) } }
\ No newline at end of file diff --git a/test/files/run/macro-invalidusage-badret.flags b/test/files/run/macro-invalidusage-badret.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-invalidusage-badret.flags +++ b/test/files/run/macro-invalidusage-badret.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-invalidusage-badret/Test_2.scala b/test/files/run/macro-invalidusage-badret/Test_2.scala index e171c9d05a..aeb3c26eaa 100644 --- a/test/files/run/macro-invalidusage-badret/Test_2.scala +++ b/test/files/run/macro-invalidusage-badret/Test_2.scala @@ -1,6 +1,6 @@ object Test extends App { import scala.reflect.mirror._ val tree = Typed(Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant(42)))), Ident(newTypeName("String"))) - try tree.eval + try Expr(tree).eval catch { case ex: Throwable => println(ex.getMessage) } }
\ No newline at end of file diff --git a/test/files/run/macro-invalidusage-partialapplication.flags b/test/files/run/macro-invalidusage-partialapplication.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-invalidusage-partialapplication.flags +++ b/test/files/run/macro-invalidusage-partialapplication.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-invalidusage-partialapplication/Test_2.scala b/test/files/run/macro-invalidusage-partialapplication/Test_2.scala index 63371a4a82..293d906048 100644 --- a/test/files/run/macro-invalidusage-partialapplication/Test_2.scala +++ b/test/files/run/macro-invalidusage-partialapplication/Test_2.scala @@ -1,6 +1,6 @@ object Test extends App { import scala.reflect.mirror._ val tree = Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant(40)))) - try tree.eval + try Expr(tree).eval catch { case ex: Throwable => println(ex.getMessage) } } diff --git a/test/files/run/macro-openmacros.flags b/test/files/run/macro-openmacros.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-openmacros.flags +++ b/test/files/run/macro-openmacros.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-quasiinvalidbody-c.flags b/test/files/run/macro-quasiinvalidbody-c.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-quasiinvalidbody-c.flags +++ b/test/files/run/macro-quasiinvalidbody-c.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-range.flags b/test/files/run/macro-range.flags index 06a7b31f11..5e5dd6ce79 100644 --- a/test/files/run/macro-range.flags +++ b/test/files/run/macro-range.flags @@ -1 +1 @@ --Xmacros +-language:experimental.macros diff --git a/test/files/run/macro-range/Expansion_Impossible_2.scala b/test/files/run/macro-range/Expansion_Impossible_2.scala index 7a093b74ee..051afff99c 100644 --- a/test/files/run/macro-range/Expansion_Impossible_2.scala +++ b/test/files/run/macro-range/Expansion_Impossible_2.scala @@ -14,7 +14,7 @@ object Impls { // scala"{ var i = $low; val h = $hi; while (i < h) { $f(i); i = i + 1 } } // or: // scala"($_this: RangeDefault).foreach($f)" - c.prefix.tree match { + Expr(c.prefix.tree match { case Apply(Select(New(tpt), initName), List(lo, hi)) if tpt.symbol.fullName == "Range" => val iname = newTermName("$i") val hname = newTermName("$h") @@ -23,7 +23,7 @@ object Impls { val labelname = newTermName("$while") val cond = makeBinop(iref, "$less", href) val body = Block( - List(makeApply(f, List(iref))), + List(makeApply(f.tree, List(iref))), Assign(iref, makeBinop(iref, "$plus", Literal(Constant(1))))) val generated = Block( @@ -37,10 +37,10 @@ object Impls { case _ => Apply( Select( - Typed(c.prefix, Ident(newTypeName("RangeDefault"))), + Typed(c.prefix.tree, Ident(newTypeName("RangeDefault"))), newTermName("foreach")), - List(f)) - } + List(f.tree)) + }) } } diff --git a/test/files/run/macro-reflective-ma-normal-mdmi.flags b/test/files/run/macro-reflective-ma-normal-mdmi.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-reflective-ma-normal-mdmi.flags +++ b/test/files/run/macro-reflective-ma-normal-mdmi.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-reflective-ma-normal-mdmi/Test_2.scala b/test/files/run/macro-reflective-ma-normal-mdmi/Test_2.scala index 3c594aed75..632708a125 100644 --- a/test/files/run/macro-reflective-ma-normal-mdmi/Test_2.scala +++ b/test/files/run/macro-reflective-ma-normal-mdmi/Test_2.scala @@ -1,5 +1,5 @@ object Test extends App { import scala.reflect.mirror._ val tree = Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant(42)))) - println(tree.eval) + println(Expr(tree).eval) } diff --git a/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala b/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala index 7cbe425fc8..cf34f1685d 100644 --- a/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala +++ b/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala @@ -12,5 +12,6 @@ object Test extends App { val module = ModuleDef(NoMods, newTermName("Macros"), Template(Nil, emptyValDef, List(modulector, macrodef))) val macroapp = Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant(42)))) val tree = Block(macrodef, module, macroapp) - println(tree.eval) + val toolbox = mkToolBox(options = "-language:experimental.macros") + println(toolbox.runExpr(tree)) } diff --git a/test/files/run/macro-reify-basic.flags b/test/files/run/macro-reify-basic.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-reify-basic.flags +++ b/test/files/run/macro-reify-basic.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-reify-eval-eval.flags b/test/files/run/macro-reify-eval-eval.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-reify-eval-eval.flags +++ b/test/files/run/macro-reify-eval-eval.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-reify-eval-outside-reify.flags b/test/files/run/macro-reify-eval-outside-reify.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-reify-eval-outside-reify.flags +++ b/test/files/run/macro-reify-eval-outside-reify.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-reify-eval-outside-reify/Impls_Macros_1.scala b/test/files/run/macro-reify-eval-outside-reify/Impls_Macros_1.scala index 13b603d610..086f9aeef2 100644 --- a/test/files/run/macro-reify-eval-outside-reify/Impls_Macros_1.scala +++ b/test/files/run/macro-reify-eval-outside-reify/Impls_Macros_1.scala @@ -1,7 +1,10 @@ import scala.reflect.makro.{Context => Ctx} object Impls { - def foo(c: Ctx)(x: c.Expr[Int]) = c.literal(x.eval) + def foo(c: Ctx)(x: c.Expr[Int]) = { + val x1 = c.Expr[Int](c.resetAllAttrs(x.tree)) + c.literal(x1.eval) + } } object Macros { diff --git a/test/files/run/macro-reify-eval-outside-reify/Test_2.scala b/test/files/run/macro-reify-eval-outside-reify/Test_2.scala index 3c594aed75..632708a125 100644 --- a/test/files/run/macro-reify-eval-outside-reify/Test_2.scala +++ b/test/files/run/macro-reify-eval-outside-reify/Test_2.scala @@ -1,5 +1,5 @@ object Test extends App { import scala.reflect.mirror._ val tree = Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant(42)))) - println(tree.eval) + println(Expr(tree).eval) } diff --git a/test/files/run/macro-reify-freevars.check b/test/files/run/macro-reify-freevars.check index 02a6a7436b..068742f0b6 100644 --- a/test/files/run/macro-reify-freevars.check +++ b/test/files/run/macro-reify-freevars.check @@ -1,3 +1,3 @@ -reflective compilation has failed:
-
-macro expansion contains free term variable code defined by map in Macros_1.scala:8:9. have you forgot to use eval when splicing this variable into a reifee? if you have troubles tracking free term variables, consider using -Xlog-free-terms
+reflective compilation has failed: + +Macro expansion contains free term variable code defined by map in Macros_1.scala:8:9. Have you forgotten to use eval when splicing this variable into a reifee? If you have troubles tracking free term variables, consider using -Xlog-free-terms diff --git a/test/files/run/macro-reify-freevars.flags b/test/files/run/macro-reify-freevars.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-reify-freevars.flags +++ b/test/files/run/macro-reify-freevars.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-reify-freevars/Test_2.scala b/test/files/run/macro-reify-freevars/Test_2.scala index 55c677155a..e7077f9c7f 100644 --- a/test/files/run/macro-reify-freevars/Test_2.scala +++ b/test/files/run/macro-reify-freevars/Test_2.scala @@ -4,6 +4,6 @@ object Test extends App { val x = ValDef(NoMods, newTermName("x"), Ident("Int"), EmptyTree) val fn = Function(List(x), Apply(Select(Ident(newTermName("x")), newTermName("$plus")), List(Literal(Constant("5"))))) val tree = Apply(Select(q, newTermName("map")), List(fn)) - try tree.eval + try Expr(tree).eval catch { case ex: Throwable => println(ex.getMessage) } }
\ No newline at end of file diff --git a/test/files/run/macro-reify-nested-a.flags b/test/files/run/macro-reify-nested-a.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-reify-nested-a.flags +++ b/test/files/run/macro-reify-nested-a.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-reify-nested-b.flags b/test/files/run/macro-reify-nested-b.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-reify-nested-b.flags +++ b/test/files/run/macro-reify-nested-b.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-reify-ref-to-packageless.flags b/test/files/run/macro-reify-ref-to-packageless.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-reify-ref-to-packageless.flags +++ b/test/files/run/macro-reify-ref-to-packageless.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-reify-tagful-a.flags b/test/files/run/macro-reify-tagful-a.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-reify-tagful-a.flags +++ b/test/files/run/macro-reify-tagful-a.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-reify-tagless-a.check b/test/files/run/macro-reify-tagless-a.check index b58cff19bc..4ee11190d6 100644 --- a/test/files/run/macro-reify-tagless-a.check +++ b/test/files/run/macro-reify-tagless-a.check @@ -1,3 +1,3 @@ -reflective compilation has failed:
-
-macro expansion contains free type variable T defined by foo in Impls_Macros_1.scala:7:13. have you forgot to use c.TypeTag annotation for this type parameter? if you have troubles tracking free type variables, consider using -Xlog-free-types
+reflective compilation has failed: + +Macro expansion contains free type variable T defined by foo in Impls_Macros_1.scala:7:13. Have you forgotten to use c.TypeTag annotation for this type parameter? If you have troubles tracking free type variables, consider using -Xlog-free-types diff --git a/test/files/run/macro-reify-tagless-a.flags b/test/files/run/macro-reify-tagless-a.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-reify-tagless-a.flags +++ b/test/files/run/macro-reify-tagless-a.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-reify-tagless-a/Test_2.scala b/test/files/run/macro-reify-tagless-a/Test_2.scala index d996da1570..94efbd0c37 100644 --- a/test/files/run/macro-reify-tagless-a/Test_2.scala +++ b/test/files/run/macro-reify-tagless-a/Test_2.scala @@ -7,6 +7,6 @@ object Test extends App { val rhs = Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant("hello world")))) val list = ValDef(NoMods, newTermName("list"), tpt, rhs) val tree = Block(list, Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Ident(list.name)))) - try tree.eval + try Expr(tree).eval catch { case ex: Throwable => println(ex.getMessage) } } diff --git a/test/files/run/macro-reify-typetag-typeparams-notags.check b/test/files/run/macro-reify-typetag-typeparams-notags.check index af4877e205..11d78ece41 100644 --- a/test/files/run/macro-reify-typetag-typeparams-notags.check +++ b/test/files/run/macro-reify-typetag-typeparams-notags.check @@ -1,2 +1,2 @@ -ConcreteTypeTag[T]
-ConcreteTypeTag[List[T]]
+TypeTag[T]
+TypeTag[List[T]]
diff --git a/test/files/run/macro-reify-typetag-typeparams-tags.check b/test/files/run/macro-reify-typetag-typeparams-tags.check index d75b3c72b2..458593c449 100644 --- a/test/files/run/macro-reify-typetag-typeparams-tags.check +++ b/test/files/run/macro-reify-typetag-typeparams-tags.check @@ -1,2 +1,2 @@ ConcreteTypeTag[Int]
-ConcreteTypeTag[List[Int]]
+*ConcreteTypeTag[List[Int]]
diff --git a/test/files/run/macro-reify-typetag-usegroundtypetag.check b/test/files/run/macro-reify-typetag-usegroundtypetag.check index d75b3c72b2..458593c449 100644 --- a/test/files/run/macro-reify-typetag-usegroundtypetag.check +++ b/test/files/run/macro-reify-typetag-usegroundtypetag.check @@ -1,2 +1,2 @@ ConcreteTypeTag[Int]
-ConcreteTypeTag[List[Int]]
+*ConcreteTypeTag[List[Int]]
diff --git a/test/files/run/macro-reify-unreify.flags b/test/files/run/macro-reify-unreify.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-reify-unreify.flags +++ b/test/files/run/macro-reify-unreify.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-reify-value-outside-reify.flags b/test/files/run/macro-reify-value-outside-reify.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-reify-value-outside-reify.flags +++ b/test/files/run/macro-reify-value-outside-reify.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-reify-value-outside-reify/Impls_Macros_1.scala b/test/files/run/macro-reify-value-outside-reify/Impls_Macros_1.scala index 28ec1ace67..109e19e44a 100644 --- a/test/files/run/macro-reify-value-outside-reify/Impls_Macros_1.scala +++ b/test/files/run/macro-reify-value-outside-reify/Impls_Macros_1.scala @@ -1,7 +1,10 @@ import scala.reflect.makro.{Context => Ctx} object Impls { - def foo(c: Ctx)(x: c.Expr[Int]) = c.literal(x.value) + def foo(c: Ctx)(x: c.Expr[Int]) = { + val x1 = c.Expr[Int](c.resetAllAttrs(x.tree)) + c.literal(x1.value) + } } object Macros { diff --git a/test/files/run/macro-reify-value-outside-reify/Test_2.scala b/test/files/run/macro-reify-value-outside-reify/Test_2.scala index 8225eb0b39..128cad4510 100644 --- a/test/files/run/macro-reify-value-outside-reify/Test_2.scala +++ b/test/files/run/macro-reify-value-outside-reify/Test_2.scala @@ -1,6 +1,6 @@ object Test extends App { import scala.reflect.mirror._ val tree = Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant(42)))) - try println(tree.eval) + try println(Expr(tree).eval) catch { case ex: Throwable => println(ex.getMessage) } } diff --git a/test/files/run/macro-repl-basic.check b/test/files/run/macro-repl-basic.check index 3bc899f49b..9e0f9aa1a2 100644 --- a/test/files/run/macro-repl-basic.check +++ b/test/files/run/macro-repl-basic.check @@ -1,51 +1,54 @@ -Type in expressions to have them evaluated.
-Type :help for more information.
-
-scala>
-
-scala> import scala.reflect.makro.{Context => Ctx}
-import scala.reflect.makro.{Context=>Ctx}
-
-scala>
-
-scala> object Impls {
- def foo(c: Ctx)(x: c.Expr[Int]) = {
- import c.mirror._
- val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1))))
- Expr[Int](body)
- }
-
- def bar(c: Ctx)(x: c.Expr[Int]) = {
- import c.mirror._
- val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2))))
- Expr[Int](body)
- }
-
- def quux(c: Ctx)(x: c.Expr[Int]) = {
- import c.mirror._
- val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3))))
- Expr[Int](body)
- }
-}
-defined module Impls
-
-scala> object Macros {
- object Shmacros {
- def foo(x: Int): Int = macro Impls.foo
- }
- def bar(x: Int): Int = macro Impls.bar
-}; class Macros {
- def quux(x: Int): Int = macro Impls.quux
-}
-defined module Macros
-defined class Macros
-
-scala>
-
-scala> import Macros.Shmacros._
-import Macros.Shmacros._
-
-scala> println(foo(2) + Macros.bar(2) * new Macros().quux(4))
-31
-
-scala>
+Type in expressions to have them evaluated. +Type :help for more information. + +scala> + +scala> import language.experimental.macros +import language.experimental.macros + +scala> import scala.reflect.makro.{Context => Ctx} +import scala.reflect.makro.{Context=>Ctx} + +scala> + +scala> object Impls { + def foo(c: Ctx)(x: c.Expr[Int]) = { + import c.mirror._ + val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))) + Expr[Int](body) + } + + def bar(c: Ctx)(x: c.Expr[Int]) = { + import c.mirror._ + val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2)))) + Expr[Int](body) + } + + def quux(c: Ctx)(x: c.Expr[Int]) = { + import c.mirror._ + val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3)))) + Expr[Int](body) + } +} +defined module Impls + +scala> object Macros { + object Shmacros { + def foo(x: Int): Int = macro Impls.foo + } + def bar(x: Int): Int = macro Impls.bar +}; class Macros { + def quux(x: Int): Int = macro Impls.quux +} +defined module Macros +defined class Macros + +scala> + +scala> import Macros.Shmacros._ +import Macros.Shmacros._ + +scala> println(foo(2) + Macros.bar(2) * new Macros().quux(4)) +31 + +scala> diff --git a/test/files/run/macro-repl-basic.scala b/test/files/run/macro-repl-basic.scala index a21eb7815f..e8849b4b56 100644 --- a/test/files/run/macro-repl-basic.scala +++ b/test/files/run/macro-repl-basic.scala @@ -1,8 +1,8 @@ import scala.tools.partest.ReplTest object Test extends ReplTest { - override def extraSettings = "-Xmacros" def code = """ + |import language.experimental.macros |import scala.reflect.makro.{Context => Ctx} | |object Impls { @@ -36,4 +36,4 @@ object Test extends ReplTest { |import Macros.Shmacros._ |println(foo(2) + Macros.bar(2) * new Macros().quux(4)) |""".stripMargin -}
\ No newline at end of file +} diff --git a/test/files/run/macro-repl-dontexpand.scala b/test/files/run/macro-repl-dontexpand.scala index 9889a8ffdf..cd1b2e1969 100644 --- a/test/files/run/macro-repl-dontexpand.scala +++ b/test/files/run/macro-repl-dontexpand.scala @@ -1,9 +1,9 @@ import scala.tools.partest.ReplTest object Test extends ReplTest { - override def extraSettings = "-Xmacros" + override def extraSettings = "-language:experimental.macros" def code = """ |def bar(c: scala.reflect.makro.Context) = ??? |def foo = macro bar |""".stripMargin -}
\ No newline at end of file +} diff --git a/test/files/run/macro-rettype-mismatch.check b/test/files/run/macro-rettype-mismatch.check deleted file mode 100644 index f6e4bc09fd..0000000000 --- a/test/files/run/macro-rettype-mismatch.check +++ /dev/null @@ -1,5 +0,0 @@ -error: type mismatch; - found : Int(2) - required: String -
-java.lang.Error: reflective compilation has failed
diff --git a/test/files/run/macro-rettype-mismatch.flags b/test/files/run/macro-rettype-mismatch.flags deleted file mode 100644 index 7fea2ff901..0000000000 --- a/test/files/run/macro-rettype-mismatch.flags +++ /dev/null @@ -1 +0,0 @@ --Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-settings.flags b/test/files/run/macro-settings.flags index cdc7512197..15479e30b8 100644 --- a/test/files/run/macro-settings.flags +++ b/test/files/run/macro-settings.flags @@ -1 +1 @@ --Xmacros -Xmacro-settings:hello=1
\ No newline at end of file +-language:experimental.macros -Xmacro-settings:hello=1
\ No newline at end of file diff --git a/test/files/run/macro-sip19-revised.flags b/test/files/run/macro-sip19-revised.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-sip19-revised.flags +++ b/test/files/run/macro-sip19-revised.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-sip19.flags b/test/files/run/macro-sip19.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-sip19.flags +++ b/test/files/run/macro-sip19.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-typecheck-implicitsdisabled.flags b/test/files/run/macro-typecheck-implicitsdisabled.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-typecheck-implicitsdisabled.flags +++ b/test/files/run/macro-typecheck-implicitsdisabled.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-typecheck-macrosdisabled.check b/test/files/run/macro-typecheck-macrosdisabled.check index b432a539fc..3e1057520b 100644 --- a/test/files/run/macro-typecheck-macrosdisabled.check +++ b/test/files/run/macro-typecheck-macrosdisabled.check @@ -1,5 +1,5 @@ {
val $mr: reflect.mirror.type = scala.reflect.`package`.mirror;
- $mr.Expr.apply[Int(2)]($mr.Literal.apply($mr.Constant.apply(2)))($mr.ConcreteTypeTag.apply[Int(2)]($mr.ConstantType.apply($mr.Constant.apply(2))))
+ $mr.Expr.apply[Int(2)]($mr.Literal.apply($mr.Constant.apply(2)))($mr.ConcreteTypeTag.apply[Int(2)]($mr.ConstantType.apply($mr.Constant.apply(2)), classOf[scala.Int]))
}
mr.reify[Int](2)
diff --git a/test/files/run/macro-typecheck-macrosdisabled.flags b/test/files/run/macro-typecheck-macrosdisabled.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-typecheck-macrosdisabled.flags +++ b/test/files/run/macro-typecheck-macrosdisabled.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala b/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala index c253f0b1fb..3de9367994 100644 --- a/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala +++ b/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala @@ -4,13 +4,6 @@ object Macros { def impl_with_macros_enabled(c: Context) = { import c.mirror._ - // todo. doesn't work. why? - //val mrPkg = staticModule("scala.reflect.package") - //val mrSym = selectTerm(mrPkg, "mirror") - //val NullaryMethodType(mrTpe) = mrSym.typeSignature - //val mr = newFreeTerm("mr", mrTpe, scala.reflect.mirror, null) - //val tree1 = Apply(Select(Ident(mr), newTermName("reify")), List(Literal(Constant(2)))) - val mr = Select(Select(Select(Ident(newTermName("scala")), newTermName("reflect")), newTermName("package")), newTermName("mirror")) val tree1 = Apply(Select(mr, newTermName("reify")), List(Literal(Constant(2)))) val ttree1 = c.typeCheck(tree1, withMacrosDisabled = false) @@ -25,7 +18,7 @@ object Macros { val mrPkg = staticModule("scala.reflect.package") val mrSym = selectTerm(mrPkg, "mirror") val NullaryMethodType(mrTpe) = mrSym.typeSignature - val mr = newFreeTerm("mr", mrTpe, scala.reflect.mirror, null) + val mr = newFreeTerm("mr", mrTpe, scala.reflect.mirror) val tree2 = Apply(Select(Ident(mr), newTermName("reify")), List(Literal(Constant(2)))) val ttree2 = c.typeCheck(tree2, withMacrosDisabled = true) diff --git a/test/files/run/macro-typecheck-macrosdisabled2.check b/test/files/run/macro-typecheck-macrosdisabled2.check new file mode 100644 index 0000000000..02da6ad0c7 --- /dev/null +++ b/test/files/run/macro-typecheck-macrosdisabled2.check @@ -0,0 +1,5 @@ +{
+ val $mr: reflect.mirror.type = scala.reflect.`package`.mirror;
+ $mr.Expr.apply[Array[Int]]($mr.Apply.apply($mr.Select.apply($mr.Select.apply($mr.Ident($mr.staticModule("scala")), $mr.newTermName("Array")), $mr.newTermName("apply")), scala.collection.immutable.List.apply[$mr.Literal]($mr.Literal.apply($mr.Constant.apply(2)))))($mr.ConcreteTypeTag.apply[Array[Int]]($mr.TypeRef.apply($mr.thisModuleType("scala"), $mr.staticClass("scala.Array"), scala.collection.immutable.List.apply[$mr.Type]($mr.staticClass("scala.Int").asTypeConstructor)), ScalaRunTime.this.arrayClass(classOf[scala.Int])))
+}
+mr.reify[Array[Int]](scala.Array.apply(2))
diff --git a/test/files/run/macro-typecheck-macrosdisabled2.flags b/test/files/run/macro-typecheck-macrosdisabled2.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/files/run/macro-typecheck-macrosdisabled2.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala b/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala new file mode 100644 index 0000000000..1b840a6204 --- /dev/null +++ b/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala @@ -0,0 +1,29 @@ +import scala.reflect.makro.Context + +object Macros { + def impl_with_macros_enabled(c: Context) = { + import c.mirror._ + + val mr = Select(Select(Select(Ident(newTermName("scala")), newTermName("reflect")), newTermName("package")), newTermName("mirror")) + val tree1 = Apply(Select(mr, newTermName("reify")), List(Apply(Select(Ident(newTermName("scala")), newTermName("Array")), List(Literal(Constant(2)))))) + val ttree1 = c.typeCheck(tree1, withMacrosDisabled = false) + c.literal(ttree1.toString) + } + + def foo_with_macros_enabled = macro impl_with_macros_enabled + + def impl_with_macros_disabled(c: Context) = { + import c.mirror._ + + val mrPkg = staticModule("scala.reflect.package") + val mrSym = selectTerm(mrPkg, "mirror") + val NullaryMethodType(mrTpe) = mrSym.typeSignature + val mr = newFreeTerm("mr", mrTpe, scala.reflect.mirror) + + val tree2 = Apply(Select(Ident(mr), newTermName("reify")), List(Apply(Select(Ident(newTermName("scala")), newTermName("Array")), List(Literal(Constant(2)))))) + val ttree2 = c.typeCheck(tree2, withMacrosDisabled = true) + c.literal(ttree2.toString) + } + + def foo_with_macros_disabled = macro impl_with_macros_disabled +}
\ No newline at end of file diff --git a/test/files/run/macro-typecheck-macrosdisabled2/Test_2.scala b/test/files/run/macro-typecheck-macrosdisabled2/Test_2.scala new file mode 100644 index 0000000000..bdba39195b --- /dev/null +++ b/test/files/run/macro-typecheck-macrosdisabled2/Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + println(Macros.foo_with_macros_enabled) + println(Macros.foo_with_macros_disabled) +}
\ No newline at end of file diff --git a/test/files/run/macro-undetparams-consfromsls.flags b/test/files/run/macro-undetparams-consfromsls.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-undetparams-consfromsls.flags +++ b/test/files/run/macro-undetparams-consfromsls.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-undetparams-implicitval.flags b/test/files/run/macro-undetparams-implicitval.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-undetparams-implicitval.flags +++ b/test/files/run/macro-undetparams-implicitval.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-undetparams-macroitself.flags b/test/files/run/macro-undetparams-macroitself.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-undetparams-macroitself.flags +++ b/test/files/run/macro-undetparams-macroitself.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/manifests-new.scala b/test/files/run/manifests-new.scala new file mode 100644 index 0000000000..4485ce9124 --- /dev/null +++ b/test/files/run/manifests-new.scala @@ -0,0 +1,147 @@ +object Test +{ + object Variances extends Enumeration { + val CO, IN, CONTRA = Value + } + import Variances.{ CO, IN, CONTRA } + + object SubtypeRelationship extends Enumeration { + val NONE, SAME, SUB, SUPER = Value + } + import SubtypeRelationship.{ NONE, SAME, SUB, SUPER } + + class VarianceTester[T, U, CC[_]](expected: Variances.Value)( + implicit ev1: TypeTag[T], ev2: TypeTag[U], ev3: TypeTag[CC[T]], ev4: TypeTag[CC[U]]) { + + def elements = List(ev1.tpe <:< ev2.tpe, ev2.tpe <:< ev1.tpe) + def containers = List(ev3.tpe <:< ev4.tpe, ev4.tpe <:< ev3.tpe) + + def isUnrelated = typeCompare[T, U] == NONE + def isSame = typeCompare[T, U] == SAME + def isSub = typeCompare[T, U] == SUB + def isSuper = typeCompare[T, U] == SUPER + + def showsCovariance = (elements == containers) + def showsContravariance = (elements == containers.reverse) + def showsInvariance = containers forall (_ == isSame) + + def allContainerVariances = List(showsCovariance, showsInvariance, showsContravariance) + + def showsExpectedVariance = + if (isUnrelated) allContainerVariances forall (_ == false) + else if (isSame) allContainerVariances forall (_ == true) + else expected match { + case CO => showsCovariance && !showsContravariance && !showsInvariance + case IN => showsInvariance && !showsCovariance && !showsContravariance + case CONTRA => showsContravariance && !showsCovariance && !showsInvariance + } + } + + def showsCovariance[T, U, CC[_]](implicit ev1: TypeTag[T], ev2: TypeTag[U], ev3: TypeTag[CC[T]], ev4: TypeTag[CC[U]]) = + new VarianceTester[T, U, CC](CO) showsExpectedVariance + + def showsInvariance[T, U, CC[_]](implicit ev1: TypeTag[T], ev2: TypeTag[U], ev3: TypeTag[CC[T]], ev4: TypeTag[CC[U]]) = + new VarianceTester[T, U, CC](IN) showsExpectedVariance + + def showsContravariance[T, U, CC[_]](implicit ev1: TypeTag[T], ev2: TypeTag[U], ev3: TypeTag[CC[T]], ev4: TypeTag[CC[U]]) = + new VarianceTester[T, U, CC](CONTRA) showsExpectedVariance + + def typeCompare[T, U](implicit ev1: TypeTag[T], ev2: TypeTag[U]) = (ev1.tpe <:< ev2.tpe, ev2.tpe <:< ev1.tpe) match { + case (true, true) => SAME + case (true, false) => SUB + case (false, true) => SUPER + case (false, false) => NONE + } + + def assertAnyRef[T: TypeTag] = List( + typeTag[T].tpe <:< typeTag[Any].tpe, + typeTag[T].tpe <:< typeTag[AnyRef].tpe, + !(typeTag[T].tpe <:< typeTag[AnyVal].tpe) + ) foreach (assert(_, "assertAnyRef")) + + def assertAnyVal[T: TypeTag] = List( + typeTag[T].tpe <:< typeTag[Any].tpe, + !(typeTag[T].tpe <:< typeTag[AnyRef].tpe), + typeTag[T].tpe <:< typeTag[AnyVal].tpe + ) foreach (assert(_, "assertAnyVal")) + + def assertSameType[T: TypeTag, U: TypeTag] = assert(typeCompare[T, U] == SAME, "assertSameType") + def assertSuperType[T: TypeTag, U: TypeTag] = assert(typeCompare[T, U] == SUPER, "assertSuperType") + def assertSubType[T: TypeTag, U: TypeTag] = assert(typeCompare[T, U] == SUB, "assertSubType") + def assertNoRelationship[T: TypeTag, U: TypeTag] = assert(typeCompare[T, U] == NONE, "assertNoRelationship") + + def testVariancesVia[T: TypeTag, U: TypeTag] = assert( + typeCompare[T, U] == SUB && + showsCovariance[T, U, List] && + showsInvariance[T, U, Set], + "testVariancesVia" + ) + + def runAllTests = { + assertAnyVal[AnyVal] + assertAnyVal[Unit] + assertAnyVal[Int] + assertAnyVal[Double] + assertAnyVal[Boolean] + assertAnyVal[Char] + + assertAnyRef[AnyRef] + assertAnyRef[java.lang.Object] + assertAnyRef[java.lang.Integer] + assertAnyRef[java.lang.Double] + assertAnyRef[java.lang.Boolean] + assertAnyRef[java.lang.Character] + assertAnyRef[String] + assertAnyRef[scala.List[String]] + assertAnyRef[scala.List[_]] + + // variance doesn't work yet + // testVariancesVia[String, Any] + // testVariancesVia[String, AnyRef] + + assertSubType[List[String], List[Any]] + assertSubType[List[String], List[AnyRef]] + assertNoRelationship[List[String], List[AnyVal]] + + assertSubType[List[Int], List[Any]] + assertSubType[List[Int], List[AnyVal]] + assertNoRelationship[List[Int], List[AnyRef]] + + // Nothing + assertSubType[Nothing, Any] + assertSubType[Nothing, AnyVal] + assertSubType[Nothing, AnyRef] + assertSubType[Nothing, String] + assertSubType[Nothing, List[String]] + assertSubType[Nothing, Null] + assertSameType[Nothing, Nothing] + + // Null + assertSubType[Null, Any] + assertNoRelationship[Null, AnyVal] + assertSubType[Null, AnyRef] + assertSubType[Null, String] + assertSubType[Null, List[String]] + assertSameType[Null, Null] + assertSuperType[Null, Nothing] + + // Any + assertSameType[Any, Any] + assertSuperType[Any, AnyVal] + assertSuperType[Any, AnyRef] + assertSuperType[Any, String] + assertSuperType[Any, List[String]] + assertSuperType[Any, Null] + assertSuperType[Any, Nothing] + + // Misc unrelated types + assertNoRelationship[Unit, AnyRef] + assertNoRelationship[Unit, Int] + assertNoRelationship[Int, Long] + assertNoRelationship[Boolean, String] + assertNoRelationship[List[Boolean], List[String]] + assertNoRelationship[Set[Boolean], Set[String]] + } + + def main(args: Array[String]): Unit = runAllTests +} diff --git a/test/files/run/manifests.scala b/test/files/run/manifests-old.scala index 2d64bf18a9..621689a254 100644 --- a/test/files/run/manifests.scala +++ b/test/files/run/manifests-old.scala @@ -13,8 +13,8 @@ object Test class VarianceTester[T, U, CC[_]](expected: Variances.Value)( implicit ev1: Manifest[T], ev2: Manifest[U], ev3: Manifest[CC[T]], ev4: Manifest[CC[U]]) { - def elements = List(ev1.tpe <:< ev2.tpe, ev2.tpe <:< ev1.tpe) - def containers = List(ev3.tpe <:< ev4.tpe, ev4.tpe <:< ev3.tpe) + def elements = List(ev1 <:< ev2, ev2 <:< ev1) + def containers = List(ev3 <:< ev4, ev4 <:< ev3) def isUnrelated = typeCompare[T, U] == NONE def isSame = typeCompare[T, U] == SAME @@ -46,25 +46,23 @@ object Test def showsContravariance[T, U, CC[_]](implicit ev1: Manifest[T], ev2: Manifest[U], ev3: Manifest[CC[T]], ev4: Manifest[CC[U]]) = new VarianceTester[T, U, CC](CONTRA) showsExpectedVariance - def typeCompare[T, U](implicit ev1: Manifest[T], ev2: Manifest[U]) = { - (ev1.tpe <:< ev2.tpe, ev2.tpe <:< ev1.tpe) match { - case (true, true) => SAME - case (true, false) => SUB - case (false, true) => SUPER - case (false, false) => NONE - } + def typeCompare[T, U](implicit ev1: Manifest[T], ev2: Manifest[U]) = (ev1 <:< ev2, ev2 <:< ev1) match { + case (true, true) => SAME + case (true, false) => SUB + case (false, true) => SUPER + case (false, false) => NONE } def assertAnyRef[T: Manifest] = List( - manifest[T].tpe <:< manifest[Any].tpe, - manifest[T].tpe <:< manifest[AnyRef].tpe, - !(manifest[T].tpe <:< manifest[AnyVal].tpe) + manifest[T] <:< manifest[Any], + manifest[T] <:< manifest[AnyRef], + !(manifest[T] <:< manifest[AnyVal]) ) foreach (assert(_, "assertAnyRef")) def assertAnyVal[T: Manifest] = List( - manifest[T].tpe <:< manifest[Any].tpe, - !(manifest[T].tpe <:< manifest[AnyRef].tpe), - manifest[T].tpe <:< manifest[AnyVal].tpe + manifest[T] <:< manifest[Any], + !(manifest[T] <:< manifest[AnyRef]), + manifest[T] <:< manifest[AnyVal] ) foreach (assert(_, "assertAnyVal")) def assertSameType[T: Manifest, U: Manifest] = assert(typeCompare[T, U] == SAME, "assertSameType") @@ -146,4 +144,4 @@ object Test } def main(args: Array[String]): Unit = runAllTests -} +}
\ No newline at end of file diff --git a/test/files/run/misc-msil.check b/test/files/run/misc-msil.check deleted file mode 100644 index 480a840b9a..0000000000 --- a/test/files/run/misc-msil.check +++ /dev/null @@ -1,33 +0,0 @@ -### Hello -### 17 -### Bye - -### fib(0) = 1 -### fib(1) = 1 -### fib(2) = 2 -### fib(3) = 3 -### fib(4) = 5 -=== MyClass::toString === -=== MySubclass::toString === -=== MyClass::test === - -identity - -A.a = 1 -B.a = 5 -B.b = 2 - -X.a = 4 -Y.a = 11 -Y.b = 5 -Y.b = 5 - -X::foo - -Y::foo -X::foo - -3 -3 - -True diff --git a/test/files/run/mock.check b/test/files/run/mock.check deleted file mode 100644 index 967c4e20bb..0000000000 --- a/test/files/run/mock.check +++ /dev/null @@ -1,3 +0,0 @@ -Hi, thanks for calling: that makes 1 times. -Hi, thanks for calling: that makes 2 times. -Hi, thanks for calling: that makes 3 times. diff --git a/test/files/run/mock.scala b/test/files/run/mock.scala deleted file mode 100644 index 8778e20ef5..0000000000 --- a/test/files/run/mock.scala +++ /dev/null @@ -1,29 +0,0 @@ -import scala.tools.reflect._ -import java.util.concurrent.Callable -import java.io.Closeable - -object Test { - // It'd be really nice about now if functions had a common parent. - implicit def interfaceify(x: AnyRef): UniversalFn = UniversalFn(x) - - def runner(x: Runnable) = x.run() - def caller[T](x: Callable[T]): T = x.call() - def closer(x: Closeable) = x.close() - - def main(args: Array[String]): Unit = { - var counter = 0 - val closure = () => { - counter += 1 - println("Hi, thanks for calling: that makes " + counter + " times.") - counter - } - - val int1 = closure.as[Runnable] - val int2 = closure.as[Callable[Int]] - val int3 = closure.as[Closeable] - - runner(int1) - caller(int2) - closer(int3) - } -} diff --git a/test/files/run/names-defaults.check b/test/files/run/names-defaults.check index 5656d1a276..f253de71d6 100644 --- a/test/files/run/names-defaults.check +++ b/test/files/run/names-defaults.check @@ -92,7 +92,7 @@ test5 test5 5 10: 2 -slkdfj1 +slkdfj2 1 lskfdjlk 11 diff --git a/test/files/run/names-defaults.scala b/test/files/run/names-defaults.scala index e1bc7cbf59..220414f02a 100644 --- a/test/files/run/names-defaults.scala +++ b/test/files/run/names-defaults.scala @@ -176,7 +176,7 @@ object Test extends App { println(Fact2()("jyp")) println(Fact2(x = 1)()) - println(Fact2(10)().copy(y = "blabla")()) + println(Fact2(10)().copy(y = "blabla")(3)) // assignment to var <-> named argument @@ -195,7 +195,7 @@ object Test extends App { // dependent types and copy method val a11 = new A2 val b11 = a11.B2(new a11.C2)(1) - println(b11.copy()()) + println(b11.copy()(2)) diff --git a/test/files/run/nonlocalreturn.check b/test/files/run/nonlocalreturn.check new file mode 100644 index 0000000000..aeb2d5e239 --- /dev/null +++ b/test/files/run/nonlocalreturn.check @@ -0,0 +1 @@ +Some(1) diff --git a/test/files/run/nonlocalreturn.scala b/test/files/run/nonlocalreturn.scala new file mode 100644 index 0000000000..3c1e7420ed --- /dev/null +++ b/test/files/run/nonlocalreturn.scala @@ -0,0 +1,15 @@ +object Test { + def wrap[K](body: => K): K = body + + def f(): Option[Int] = { + wrap({ return Some(1) ; None }) + } + + def main(args: Array[String]) { + println(f()) + } +} +// java.lang.ClassCastException: scala.Some cannot be cast to scala.None$ +// at Test$$anonfun$f$1.apply(nonlocalreturn.scala:5) +// at Test$$anonfun$f$1.apply(nonlocalreturn.scala:5) +// at Test$.wrap(nonlocalreturn.scala:2) diff --git a/test/files/run/origins.check b/test/files/run/origins.check index ffbf1c1f44..b12cb6e38f 100644 --- a/test/files/run/origins.check +++ b/test/files/run/origins.check @@ -1,5 +1,5 @@ ->> Origins goxbox.Socks.boop logged 65 calls from 3 distinguished sources. +>> Origins tag 'boop' logged 65 calls from 3 distinguished sources. 50 Test$$anonfun$f3$1.apply(origins.scala:16) 10 Test$$anonfun$f2$1.apply(origins.scala:15) diff --git a/test/files/run/origins.scala b/test/files/run/origins.scala index 9dc6071c7b..0ad92297f5 100644 --- a/test/files/run/origins.scala +++ b/test/files/run/origins.scala @@ -2,7 +2,7 @@ import scala.reflect.internal.util.Origins package goxbox { object Socks { - val origins = Origins[Socks.type]("boop") + val origins = Origins("boop") def boop(x: Int): Int = origins { 5 } } diff --git a/test/files/run/packrat3.check b/test/files/run/packrat3.check index 4d84623ce6..8c10626751 100644 --- a/test/files/run/packrat3.check +++ b/test/files/run/packrat3.check @@ -4,4 +4,4 @@ (((List(a, a, a, a, b, b, b, b)~())~List(a, a, a, a))~List(b, b, b, b, c, c, c, c)) Expected failure ``b'' expected but `c' found -``c'' expected but EOF found +end of input diff --git a/test/files/run/patmat_unapp_abstype-new.check b/test/files/run/patmat_unapp_abstype-new.check new file mode 100644 index 0000000000..42c54631d2 --- /dev/null +++ b/test/files/run/patmat_unapp_abstype-new.check @@ -0,0 +1,4 @@ +TypeRef +MethodType +Bar +Foo diff --git a/test/files/run/patmat_unapp_abstype-new.scala b/test/files/run/patmat_unapp_abstype-new.scala new file mode 100644 index 0000000000..45496f08a2 --- /dev/null +++ b/test/files/run/patmat_unapp_abstype-new.scala @@ -0,0 +1,83 @@ +// abstract types and extractors, oh my! +trait TypesAPI { + trait Type + + // an alternative fix (implemented in the virtual pattern matcher, is to replace the isInstanceOf by a manifest-based run-time test) + // that's what typeRefMani is for + type TypeRef <: Type //; implicit def typeRefMani: Manifest[TypeRef] + val TypeRef: TypeRefExtractor; trait TypeRefExtractor { + def apply(x: Int): TypeRef + def unapply(x: TypeRef): Option[(Int)] + } + + // just for illustration, should follow the same pattern as TypeRef + case class MethodType(n: Int) extends Type +} + +// user should not be exposed to the implementation +trait TypesUser extends TypesAPI { + def shouldNotCrash(tp: Type): Unit = { + tp match { + case TypeRef(x) => println("TypeRef") + // the above checks tp.isInstanceOf[TypeRef], which is erased to tp.isInstanceOf[Type] + // before calling TypeRef.unapply(tp), which will then crash unless tp.isInstanceOf[TypesImpl#TypeRef] (which is not implied by tp.isInstanceOf[Type]) + // tp.isInstanceOf[TypesImpl#TypeRef] is equivalent to classOf[TypesImpl#TypeRef].isAssignableFrom(tp.getClass) + // this is equivalent to manifest + // it is NOT equivalent to manifest[Type] <:< typeRefMani + case MethodType(x) => println("MethodType") + case _ => println("none of the above") + } + } +} + +trait TypesImpl extends TypesAPI { + object TypeRef extends TypeRefExtractor // this will have a bridged unapply(x: Type) = unapply(x.asInstanceOf[TypeRef]) + case class TypeRef(n: Int) extends Type // this has a bridge from TypesAPI#Type to TypesImpl#TypeRef + // --> the cast in the bridge will fail because the pattern matcher can't type test against the abstract types in TypesUser + //lazy val typeRefMani = manifest[TypeRef] +} + +trait Foos { + trait Bar + type Foo <: Bar + trait FooExtractor { + def unapply(foo: Foo): Option[Int] + } + val Foo: FooExtractor +} + +trait RealFoos extends Foos { + class Foo(val x: Int) extends Bar + object Foo extends FooExtractor { + def unapply(foo: Foo): Option[Int] = Some(foo.x) + } +} + +trait Intermed extends Foos { + def crash(bar: Bar): Unit = + bar match { + case Foo(x) => println("Foo") + case _ => println("Bar") + } +} + +object TestUnappStaticallyKnownSynthetic extends TypesImpl with TypesUser { + def test() = { + shouldNotCrash(TypeRef(10)) // should and does print "TypeRef" + // once #1697/#2337 are fixed, this should generate the correct output + shouldNotCrash(MethodType(10)) // should print "MethodType" but prints "none of the above" -- good one, pattern matcher! + } +} + +object TestUnappDynamicSynth extends RealFoos with Intermed { + case class FooToo(n: Int) extends Bar + def test() = { + crash(FooToo(10)) + crash(new Foo(5)) + } +} + +object Test extends App { + TestUnappStaticallyKnownSynthetic.test() + TestUnappDynamicSynth.test() +} diff --git a/test/files/run/patmat_unapp_abstype.check b/test/files/run/patmat_unapp_abstype-old.check index ac28ccdb95..72239d16cd 100644 --- a/test/files/run/patmat_unapp_abstype.check +++ b/test/files/run/patmat_unapp_abstype-old.check @@ -1,2 +1,4 @@ TypeRef none of the above +Bar +Foo diff --git a/test/files/run/patmat_unapp_abstype-old.flags b/test/files/run/patmat_unapp_abstype-old.flags new file mode 100644 index 0000000000..ba80cad69b --- /dev/null +++ b/test/files/run/patmat_unapp_abstype-old.flags @@ -0,0 +1 @@ +-Xoldpatmat diff --git a/test/files/run/patmat_unapp_abstype-old.scala b/test/files/run/patmat_unapp_abstype-old.scala new file mode 100644 index 0000000000..45496f08a2 --- /dev/null +++ b/test/files/run/patmat_unapp_abstype-old.scala @@ -0,0 +1,83 @@ +// abstract types and extractors, oh my! +trait TypesAPI { + trait Type + + // an alternative fix (implemented in the virtual pattern matcher, is to replace the isInstanceOf by a manifest-based run-time test) + // that's what typeRefMani is for + type TypeRef <: Type //; implicit def typeRefMani: Manifest[TypeRef] + val TypeRef: TypeRefExtractor; trait TypeRefExtractor { + def apply(x: Int): TypeRef + def unapply(x: TypeRef): Option[(Int)] + } + + // just for illustration, should follow the same pattern as TypeRef + case class MethodType(n: Int) extends Type +} + +// user should not be exposed to the implementation +trait TypesUser extends TypesAPI { + def shouldNotCrash(tp: Type): Unit = { + tp match { + case TypeRef(x) => println("TypeRef") + // the above checks tp.isInstanceOf[TypeRef], which is erased to tp.isInstanceOf[Type] + // before calling TypeRef.unapply(tp), which will then crash unless tp.isInstanceOf[TypesImpl#TypeRef] (which is not implied by tp.isInstanceOf[Type]) + // tp.isInstanceOf[TypesImpl#TypeRef] is equivalent to classOf[TypesImpl#TypeRef].isAssignableFrom(tp.getClass) + // this is equivalent to manifest + // it is NOT equivalent to manifest[Type] <:< typeRefMani + case MethodType(x) => println("MethodType") + case _ => println("none of the above") + } + } +} + +trait TypesImpl extends TypesAPI { + object TypeRef extends TypeRefExtractor // this will have a bridged unapply(x: Type) = unapply(x.asInstanceOf[TypeRef]) + case class TypeRef(n: Int) extends Type // this has a bridge from TypesAPI#Type to TypesImpl#TypeRef + // --> the cast in the bridge will fail because the pattern matcher can't type test against the abstract types in TypesUser + //lazy val typeRefMani = manifest[TypeRef] +} + +trait Foos { + trait Bar + type Foo <: Bar + trait FooExtractor { + def unapply(foo: Foo): Option[Int] + } + val Foo: FooExtractor +} + +trait RealFoos extends Foos { + class Foo(val x: Int) extends Bar + object Foo extends FooExtractor { + def unapply(foo: Foo): Option[Int] = Some(foo.x) + } +} + +trait Intermed extends Foos { + def crash(bar: Bar): Unit = + bar match { + case Foo(x) => println("Foo") + case _ => println("Bar") + } +} + +object TestUnappStaticallyKnownSynthetic extends TypesImpl with TypesUser { + def test() = { + shouldNotCrash(TypeRef(10)) // should and does print "TypeRef" + // once #1697/#2337 are fixed, this should generate the correct output + shouldNotCrash(MethodType(10)) // should print "MethodType" but prints "none of the above" -- good one, pattern matcher! + } +} + +object TestUnappDynamicSynth extends RealFoos with Intermed { + case class FooToo(n: Int) extends Bar + def test() = { + crash(FooToo(10)) + crash(new Foo(5)) + } +} + +object Test extends App { + TestUnappStaticallyKnownSynthetic.test() + TestUnappDynamicSynth.test() +} diff --git a/test/files/run/patmat_unapp_abstype.scala b/test/files/run/patmat_unapp_abstype.scala deleted file mode 100644 index e5adec5c16..0000000000 --- a/test/files/run/patmat_unapp_abstype.scala +++ /dev/null @@ -1,39 +0,0 @@ -// abstract types and extractors, oh my! -trait TypesAPI { - trait Type - - // an alternative fix (implemented in the virtual pattern matcher, is to replace the isInstanceOf by a manifest-based run-time test) - // that's what typeRefMani is for - type TypeRef <: Type //; implicit def typeRefMani: Manifest[TypeRef] - val TypeRef: TypeRefExtractor; trait TypeRefExtractor { - def apply(x: Int): TypeRef - def unapply(x: TypeRef): Option[(Int)] - } - - // just for illustration, should follow the same pattern as TypeRef - case class MethodType(n: Int) extends Type -} - -// user should not be exposed to the implementation -trait TypesUser extends TypesAPI { - def shouldNotCrash(tp: Type): Unit = { - tp match { - case TypeRef(x) => println("TypeRef") - case MethodType(x) => println("MethodType") - case _ => println("none of the above") - } - } -} - -trait TypesImpl extends TypesAPI { - object TypeRef extends TypeRefExtractor // this will have a bridged unapply(x: Type) = unapply(x.asInstanceOf[TypeRef]) - case class TypeRef(n: Int) extends Type // this has a bridge from TypesAPI#Type to TypesImpl#TypeRef - // --> the cast in the bridge will fail because the pattern matcher can't type test against the abstract types in TypesUser - //lazy val typeRefMani = manifest[TypeRef] -} - -object Test extends TypesImpl with TypesUser with App { - shouldNotCrash(TypeRef(10)) // should and does print "TypeRef" - // once #1697/#2337 are fixed, this should generate the correct output - shouldNotCrash(MethodType(10)) // should print "MethodType" but prints "none of the above" -- good one, pattern matcher! -}
\ No newline at end of file diff --git a/test/files/run/primitive-sigs-2.check b/test/files/run/primitive-sigs-2-new.check index 1b6e24ed20..b82ddbeaff 100644 --- a/test/files/run/primitive-sigs-2.check +++ b/test/files/run/primitive-sigs-2-new.check @@ -1,7 +1,7 @@ T<java.lang.Object>
List(A, char, class java.lang.Object)
a
-public <T> java.lang.Object Arr.arr4(java.lang.Object[],scala.reflect.api.TypeTags.scala.reflect.api.TypeTags$ConcreteTypeTag<T>)
+public <T> java.lang.Object Arr.arr4(java.lang.Object[],scala.reflect.ArrayTag<T>)
public float[] Arr.arr3(float[][])
public scala.collection.immutable.List<java.lang.Character> Arr.arr2(java.lang.Character[])
public scala.collection.immutable.List<java.lang.Object> Arr.arr1(int[])
diff --git a/test/files/run/primitive-sigs-2-new.scala b/test/files/run/primitive-sigs-2-new.scala new file mode 100644 index 0000000000..7e13014cb2 --- /dev/null +++ b/test/files/run/primitive-sigs-2-new.scala @@ -0,0 +1,31 @@ +import java.{ lang => jl } + +trait T[A] { + def f(): A +} +class C extends T[Char] { + def f(): Char = 'a' +} +class Arr { + def arr1(xs: Array[Int]): List[Int] = xs.toList + def arr2(xs: Array[jl.Character]): List[jl.Character] = xs.toList + def arr3(xss: Array[Array[Float]]): Array[Float] = xss map (_.sum) + def arr4[T: ArrayTag](xss: Array[Array[T]]): Array[T] = xss map (_.head) +} + +object Test { + val c1: Class[_] = classOf[T[_]] + val c2: Class[_] = classOf[C] + val c3: Class[_] = classOf[Arr] + + val c1m = c1.getMethods.toList filter (_.getName == "f") map (_.getGenericReturnType.toString) + val c2m = c2.getMethods.toList filter (_.getName == "f") map (_.getGenericReturnType.toString) + val c3m = c3.getDeclaredMethods.toList map (_.toGenericString) + + def main(args: Array[String]): Unit = { + println(c2.getGenericInterfaces.map(_.toString).sorted mkString " ") + println(c1m ++ c2m sorted) + println(new C f) + c3m.sorted foreach println + } +} diff --git a/test/files/run/primitive-sigs-2-old.check b/test/files/run/primitive-sigs-2-old.check new file mode 100644 index 0000000000..9132b4d8ae --- /dev/null +++ b/test/files/run/primitive-sigs-2-old.check @@ -0,0 +1,7 @@ +T<java.lang.Object>
+List(A, char, class java.lang.Object)
+a
+public <T> java.lang.Object Arr.arr4(java.lang.Object[],scala.reflect.Manifest<T>)
+public float[] Arr.arr3(float[][])
+public scala.collection.immutable.List<java.lang.Character> Arr.arr2(java.lang.Character[])
+public scala.collection.immutable.List<java.lang.Object> Arr.arr1(int[])
diff --git a/test/files/run/primitive-sigs-2.scala b/test/files/run/primitive-sigs-2-old.scala index b7152f7e3d..b7152f7e3d 100644 --- a/test/files/run/primitive-sigs-2.scala +++ b/test/files/run/primitive-sigs-2-old.scala diff --git a/test/files/run/programmatic-main.check b/test/files/run/programmatic-main.check index d16e2c5178..bdf76ddce1 100644 --- a/test/files/run/programmatic-main.check +++ b/test/files/run/programmatic-main.check @@ -4,27 +4,28 @@ namer 2 resolve names, attach symbols to named trees packageobjects 3 load package objects typer 4 the meat and potatoes: type the trees - superaccessors 5 add super accessors in traits and nested classes - extmethods 6 add extension methods for inline classes - pickler 7 serialize symbol tables - refchecks 8 reference/override checking, translate nested objects - uncurry 9 uncurry, translate function values to anonymous classes - tailcalls 10 replace tail calls by jumps - specialize 11 @specialized-driven class and method specialization - explicitouter 12 this refs to outer pointers, translate patterns - erasure 13 erase types, add interfaces for traits - posterasure 14 clean up erased inline classes - lazyvals 15 allocate bitmaps, translate lazy vals into lazified defs - lambdalift 16 move nested functions to top level - constructors 17 move field definitions into constructors - flatten 18 eliminate inner classes - mixin 19 mixin composition - cleanup 20 platform-specific cleanups, generate reflective calls - icode 21 generate portable intermediate code - inliner 22 optimization: do inlining -inlineExceptionHandlers 23 optimization: inline exception handlers - closelim 24 optimization: eliminate uncalled closures - dce 25 optimization: eliminate dead code - jvm 26 generate JVM bytecode - terminal 27 The last phase in the compiler chain + patmat 5 translate match expressions + superaccessors 6 add super accessors in traits and nested classes + extmethods 7 add extension methods for inline classes + pickler 8 serialize symbol tables + refchecks 9 reference/override checking, translate nested objects + uncurry 10 uncurry, translate function values to anonymous classes + tailcalls 11 replace tail calls by jumps + specialize 12 @specialized-driven class and method specialization + explicitouter 13 this refs to outer pointers, translate patterns + erasure 14 erase types, add interfaces for traits + posterasure 15 clean up erased inline classes + lazyvals 16 allocate bitmaps, translate lazy vals into lazified defs + lambdalift 17 move nested functions to top level + constructors 18 move field definitions into constructors + flatten 19 eliminate inner classes + mixin 20 mixin composition + cleanup 21 platform-specific cleanups, generate reflective calls + icode 22 generate portable intermediate code + inliner 23 optimization: do inlining +inlineExceptionHandlers 24 optimization: inline exception handlers + closelim 25 optimization: eliminate uncalled closures + dce 26 optimization: eliminate dead code + jvm 27 generate JVM bytecode + terminal 28 The last phase in the compiler chain diff --git a/test/files/run/promotion-msil.check b/test/files/run/promotion-msil.check deleted file mode 100644 index 41e36c369d..0000000000 --- a/test/files/run/promotion-msil.check +++ /dev/null @@ -1,4 +0,0 @@ -2 -6 -20 -30 diff --git a/test/files/run/reflection-implClass-new.scala b/test/files/run/reflection-implClass-new.scala new file mode 100644 index 0000000000..27374f2106 --- /dev/null +++ b/test/files/run/reflection-implClass-new.scala @@ -0,0 +1,38 @@ +/** + * Tries to load a symbol for the `Foo$class` using Scala reflection. + * Since trait implementation classes do not get pickling information + * symbol for them should be created using fallback mechanism + * that exposes Java reflection information dressed up in + * a Scala symbol. + */ +object Test extends App with Outer { + import scala.reflect.mirror + + assert(mirror.classToSymbol(classTag[Foo].erasure).typeSignature.declaration(mirror.newTermName("bar")).typeSignature == + mirror.classToSymbol(classTag[Bar].erasure).typeSignature.declaration(mirror.newTermName("foo")).typeSignature) + + val s1 = implClass(classTag[Foo].erasure) + assert(s1 != mirror.NoSymbol) + assert(s1.typeSignature != mirror.NoType) + assert(s1.companionSymbol.typeSignature != mirror.NoType) + assert(s1.companionSymbol.typeSignature.declaration(mirror.newTermName("bar")) != mirror.NoSymbol) + val s2 = implClass(classTag[Bar].erasure) + assert(s2 != mirror.NoSymbol) + assert(s2.typeSignature != mirror.NoType) + assert(s2.companionSymbol.typeSignature != mirror.NoType) + assert(s2.companionSymbol.typeSignature.declaration(mirror.newTermName("foo")) != mirror.NoSymbol) + def implClass(clazz: Class[_]) = { + val implClass = Class.forName(clazz.getName + "$class") + mirror.classToSymbol(implClass) + } +} + +trait Foo { + def bar = 1 +} + +trait Outer { + trait Bar { + def foo = 1 + } +} diff --git a/test/files/run/reflection-implClass.scala b/test/files/run/reflection-implClass-old.scala index 7718b52f33..6583624d8b 100644 --- a/test/files/run/reflection-implClass.scala +++ b/test/files/run/reflection-implClass-old.scala @@ -1,5 +1,5 @@ -/** - * Tries to load a symbol for the `Foo$class` using Scala reflection. +/** + * Tries to load a symbol for the `Foo$class` using Scala reflection. * Since trait implementation classes do not get pickling information * symbol for them should be created using fallback mechanism * that exposes Java reflection information dressed up in diff --git a/test/files/run/reflection-simple.check b/test/files/run/reflection-simple.check new file mode 100644 index 0000000000..671d9d2716 --- /dev/null +++ b/test/files/run/reflection-simple.check @@ -0,0 +1,45 @@ +Running +constructor Foo$3 +constructor Object +method != +method != +method ## +method $asInstanceOf +method $init$ +method $isInstanceOf +method == +method == +method _1 +method _2 +method _3 +method a +method asInstanceOf +method b +method c +method canEqual +method clone +method copy +method copy$default$1 +method copy$default$2 +method copy$default$3 +method eq +method equals +method finalize +method getClass +method hashCode +method isInstanceOf +method ne +method notify +method notifyAll +method productArity +method productElement +method productIterator +method productPrefix +method synchronized +method toString +method wait +method wait +method wait +value a +value b +value c diff --git a/test/files/run/reflection-simple.scala b/test/files/run/reflection-simple.scala new file mode 100644 index 0000000000..fb3feec3cb --- /dev/null +++ b/test/files/run/reflection-simple.scala @@ -0,0 +1,11 @@ +// a.scala +// Wed May 2 01:01:22 PDT 2012 + +object Test { + def main(args: Array[String]) { + System.out.println("Running") + case class Foo(a: Int, b: Int, c: Int) + val props = reflect.mirror.classToType(classOf[Foo]).members.filter(_.isTerm).map(_.toString) + props.toList.sorted foreach System.out.println + } +} diff --git a/test/files/run/reify-repl-fail-gracefully.check b/test/files/run/reify-repl-fail-gracefully.check new file mode 100644 index 0000000000..680db12667 --- /dev/null +++ b/test/files/run/reify-repl-fail-gracefully.check @@ -0,0 +1,21 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> + +scala> import language.experimental.macros +import language.experimental.macros + +scala> import scala.reflect.mirror._ +import scala.reflect.mirror._ + +scala> + +scala> reify +<console>:12: error: macros cannot be partially applied + reify + ^ + +scala> + +scala> diff --git a/test/files/run/reify-repl-fail-gracefully.scala b/test/files/run/reify-repl-fail-gracefully.scala new file mode 100644 index 0000000000..d7a06e8da8 --- /dev/null +++ b/test/files/run/reify-repl-fail-gracefully.scala @@ -0,0 +1,10 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + def code = """ + |import language.experimental.macros + |import scala.reflect.mirror._ + | + |reify + """.stripMargin +} diff --git a/test/files/run/reify_ann1a.scala b/test/files/run/reify_ann1a.scala index 1f5d1daccd..6c062ca2c2 100644 --- a/test/files/run/reify_ann1a.scala +++ b/test/files/run/reify_ann1a.scala @@ -1,6 +1,6 @@ import scala.reflect.mirror._ -class ann(bar: List[String]) extends StaticAnnotation +class ann(bar: List[String]) extends annotation.StaticAnnotation object Test extends App { // test 1: reify diff --git a/test/files/run/reify_ann1b.scala b/test/files/run/reify_ann1b.scala index 13d861a15c..4faddef72c 100644 --- a/test/files/run/reify_ann1b.scala +++ b/test/files/run/reify_ann1b.scala @@ -1,6 +1,6 @@ import scala.reflect.mirror._ -class ann(bar: String) extends ClassfileAnnotation +class ann(bar: String) extends annotation.ClassfileAnnotation object Test extends App { // test 1: reify diff --git a/test/files/run/reify_ann2a.scala b/test/files/run/reify_ann2a.scala index 370abadba0..a1723c221d 100644 --- a/test/files/run/reify_ann2a.scala +++ b/test/files/run/reify_ann2a.scala @@ -3,7 +3,7 @@ import scala.reflect.mirror._ object Test extends App { // test 1: reify val tree = reify{ - class ann(bar: List[String]) extends StaticAnnotation + class ann(bar: List[String]) extends annotation.StaticAnnotation @ann(bar=List("1a")) @ann(bar=List("1b")) class C[@ann(bar=List("2a")) @ann(bar=List("2b")) T](@ann(bar=List("3a")) @ann(bar=List("3b")) x: T @ann(bar=List("4a")) @ann(bar=List("4b"))) { @ann(bar=List("5a")) @ann(bar=List("5b")) def f(x: Int @ann(bar=List("6a")) @ann(bar=List("6b"))) = { diff --git a/test/files/run/reify_classfileann_a.scala b/test/files/run/reify_classfileann_a.scala index c3e7d8d2e9..9aec69b4a3 100644 --- a/test/files/run/reify_classfileann_a.scala +++ b/test/files/run/reify_classfileann_a.scala @@ -1,6 +1,6 @@ import scala.reflect.mirror._ -class ann(bar: String, quux: Array[String] = Array(), baz: ann = null) extends ClassfileAnnotation +class ann(bar: String, quux: Array[String] = Array(), baz: ann = null) extends annotation.ClassfileAnnotation object Test extends App { // test 1: reify diff --git a/test/files/run/reify_classfileann_b.scala b/test/files/run/reify_classfileann_b.scala index 4e50494af3..a37f20e72e 100644 --- a/test/files/run/reify_classfileann_b.scala +++ b/test/files/run/reify_classfileann_b.scala @@ -1,6 +1,6 @@ import scala.reflect.mirror._ -class ann(bar: String, quux: Array[String] = Array(), baz: ann = null) extends ClassfileAnnotation +class ann(bar: String, quux: Array[String] = Array(), baz: ann = null) extends annotation.ClassfileAnnotation object Test extends App { // test 1: reify diff --git a/test/files/run/reify_csv.check b/test/files/run/reify_csv.check new file mode 100644 index 0000000000..b56f4bb50b --- /dev/null +++ b/test/files/run/reify_csv.check @@ -0,0 +1,10 @@ +List(phase name, id, description) +record(parser,1,parse source into ASTs, perform simple desugaring) +record(namer,2,resolve names, attach symbols to named trees) +record(packageobjects,3,load package objects) +record(typer,4,the meat and potatoes: type the trees) +record(superaccessors,5,add super accessors in traits and nested classes) +record(pickler,6,serialize symbol tables) +record(refchecks,7,reference/override checking, translate nested objects) +record(selectiveanf,8,) +record(liftcode,9,reify trees) diff --git a/test/files/run/reify_csv.scala b/test/files/run/reify_csv.scala new file mode 100644 index 0000000000..966521575c --- /dev/null +++ b/test/files/run/reify_csv.scala @@ -0,0 +1,35 @@ +import scala.reflect.mirror._ + +object Test extends App { + val csv = """ + | phase name; id; description + | parser; 1; parse source into ASTs, perform simple desugaring + | namer; 2; resolve names, attach symbols to named trees + |packageobjects; 3; load package objects + | typer; 4; the meat and potatoes: type the trees + |superaccessors; 5; add super accessors in traits and nested classes + | pickler; 6; serialize symbol tables + | refchecks; 7; reference/override checking, translate nested objects + | selectiveanf; 8; + | liftcode; 9; reify trees""".stripMargin.split("\n").map{_.trim()}.drop(1).toList + + val fields = csv.head.split(";").map{_.trim()}.toList + println(fields) + + reify({ + object Csv { + case class record(`phase name`: String, id: String, description: String) + + object record { + def parse(lines: List[String]) = { + lines drop(1) map { line => line.split(";", -1).toList match { + case phase$whitespace$name :: id :: description :: _ => record(phase$whitespace$name.trim(), id.trim(), description.trim()) + case _ => throw new Exception("format error") + }} + } + } + } + + Csv.record.parse(csv) foreach println + }).eval +} diff --git a/test/files/run/macro-invalidret-doesnt-conform-to-impl-rettype.check b/test/files/run/reify_fors.flags index e69de29bb2..e69de29bb2 100644 --- a/test/files/run/macro-invalidret-doesnt-conform-to-impl-rettype.check +++ b/test/files/run/reify_fors.flags diff --git a/test/files/run/reify_implicits.check b/test/files/run/reify_implicits-new.check index e3aeb20f6b..e3aeb20f6b 100644 --- a/test/files/run/reify_implicits.check +++ b/test/files/run/reify_implicits-new.check diff --git a/test/files/run/reify_implicits-new.scala b/test/files/run/reify_implicits-new.scala new file mode 100644 index 0000000000..69198391d1 --- /dev/null +++ b/test/files/run/reify_implicits-new.scala @@ -0,0 +1,14 @@ +import scala.reflect.mirror._ + +object Test extends App { + reify { + implicit def arrayWrapper[A : ArrayTag](x: Array[A]) = + new { + def sort(p: (A, A) => Boolean) = { + util.Sorting.stableSort(x, p); x + } + } + val x = Array(2, 3, 1, 4) + println("x = "+ x.sort((x: Int, y: Int) => x < y).toList) + }.eval +} diff --git a/test/files/run/reify_implicits-old.check b/test/files/run/reify_implicits-old.check new file mode 100644 index 0000000000..e3aeb20f6b --- /dev/null +++ b/test/files/run/reify_implicits-old.check @@ -0,0 +1 @@ +x = List(1, 2, 3, 4) diff --git a/test/files/run/reify_implicits.scala b/test/files/run/reify_implicits-old.scala index 60971c3cfb..60971c3cfb 100644 --- a/test/files/run/reify_implicits.scala +++ b/test/files/run/reify_implicits-old.scala diff --git a/test/files/run/reify_lazyevaluation.check b/test/files/run/reify_lazyevaluation.check new file mode 100644 index 0000000000..1c7f96cd96 --- /dev/null +++ b/test/files/run/reify_lazyevaluation.check @@ -0,0 +1,8 @@ +s = Susp(?) +evaluating... +s() = 3 +s = Susp(3) +2 + s = 5 +sl2 = Susp(?) +sl2() = Some(3) +sl2 = Susp(Some(3)) diff --git a/test/files/run/reify_lazyevaluation.scala b/test/files/run/reify_lazyevaluation.scala new file mode 100644 index 0000000000..1a0c858914 --- /dev/null +++ b/test/files/run/reify_lazyevaluation.scala @@ -0,0 +1,58 @@ +import scala.reflect.mirror._ + +object Test extends App { + reify { + object lazyLib { + + /** Delay the evaluation of an expression until it is needed. */ + def delay[A](value: => A): Susp[A] = new SuspImpl[A](value) + + /** Get the value of a delayed expression. */ + implicit def force[A](s: Susp[A]): A = s() + + /** + * Data type of suspended computations. (The name froms from ML.) + */ + abstract class Susp[+A] extends Function0[A] + + /** + * Implementation of suspended computations, separated from the + * abstract class so that the type parameter can be invariant. + */ + class SuspImpl[A](lazyValue: => A) extends Susp[A] { + private var maybeValue: Option[A] = None + + override def apply() = maybeValue match { + case None => + val value = lazyValue + maybeValue = Some(value) + value + case Some(value) => + value + } + + override def toString() = maybeValue match { + case None => "Susp(?)" + case Some(value) => "Susp(" + value + ")" + } + } + } + + import lazyLib._ + + val s: Susp[Int] = delay { println("evaluating..."); 3 } + + println("s = " + s) // show that s is unevaluated + println("s() = " + s()) // evaluate s + println("s = " + s) // show that the value is saved + println("2 + s = " + (2 + s)) // implicit call to force() + + val sl = delay { Some(3) } + val sl1: Susp[Some[Int]] = sl + val sl2: Susp[Option[Int]] = sl1 // the type is covariant + + println("sl2 = " + sl2) + println("sl2() = " + sl2()) + println("sl2 = " + sl2) + }.eval +} diff --git a/test/files/run/macro-reflective-mamd-normal-mi.flags b/test/files/run/reify_maps.flags index e69de29bb2..e69de29bb2 100644 --- a/test/files/run/macro-reflective-mamd-normal-mi.flags +++ b/test/files/run/reify_maps.flags diff --git a/test/files/run/reify_newimpl_26.check b/test/files/run/reify_newimpl_26.check index bfbf1d653d..d92b3bd817 100644 --- a/test/files/run/reify_newimpl_26.check +++ b/test/files/run/reify_newimpl_26.check @@ -16,7 +16,7 @@ scala> def foo[T]{ foo: [T]=> Unit
scala> foo[Int]
-ConcreteTypeTag[List[T]]
+TypeTag[List[T]]
scala>
diff --git a/test/files/run/reify_newimpl_45.scala b/test/files/run/reify_newimpl_45.scala index 241b7d4bc3..b2b52eaf5b 100644 --- a/test/files/run/reify_newimpl_45.scala +++ b/test/files/run/reify_newimpl_45.scala @@ -3,9 +3,9 @@ import scala.reflect.mirror._ object Test extends App { class C[T >: Null] { val code = reify{val x: T = "2".asInstanceOf[T]; println("ima worx: %s".format(x)); x} - println(freeTypes(code)) - val T = freeTypes(code)(0) - mkToolBox().runExpr(code, Map(T -> definitions.StringClass.asType)) + println(freeTypes(code.tree)) + val T = freeTypes(code.tree)(0) + mkToolBox().runExpr(code.tree, Map(T -> definitions.StringClass.asType)) } new C[String] diff --git a/test/files/run/reify_properties.check b/test/files/run/reify_properties.check new file mode 100644 index 0000000000..d769bea4b0 --- /dev/null +++ b/test/files/run/reify_properties.check @@ -0,0 +1,2 @@ +user1: MR. ROBERT <noname> +user2: MR. BOB KUZ diff --git a/test/files/run/reify_properties.scala b/test/files/run/reify_properties.scala new file mode 100644 index 0000000000..5cacc262ac --- /dev/null +++ b/test/files/run/reify_properties.scala @@ -0,0 +1,56 @@ +import scala.reflect.mirror._ + +object Test extends App { + reify { + /** A mutable property whose getter and setter may be customized. */ + case class Property[T](init: T) { + private var value: T = init + + /** The getter function, defaults to identity. */ + private var setter: T => T = identity[T] + + /** The setter function, defaults to identity. */ + private var getter: T => T = identity[T] + + /** Retrive the value held in this property. */ + def apply(): T = getter(value) + + /** Update the value held in this property, through the setter. */ + def update(newValue: T) = value = setter(newValue) + + /** Change the getter. */ + def get(newGetter: T => T) = { getter = newGetter; this } + + /** Change the setter */ + def set(newSetter: T => T) = { setter = newSetter; this } + } + + class User { + // Create a property with custom getter and setter + val firstname = Property("") + .get { v => v.toUpperCase() } + .set { v => "Mr. " + v } + val lastname = Property("<noname>") + + /** Scala provides syntactic sugar for calling 'apply'. Simply + * adding a list of arguments between parenthesis (in this case, + * an empty list) is translated to a call to 'apply' with those + * arguments. + */ + override def toString() = firstname() + " " + lastname() + } + + val user1 = new User + + // Syntactic sugar for 'update': an assignment is translated to a + // call to method 'update' + user1.firstname() = "Robert" + + val user2 = new User + user2.firstname() = "bob" + user2.lastname() = "KUZ" + + println("user1: " + user1) + println("user2: " + user2) + }.eval +} diff --git a/test/files/run/repl-backticks.scala b/test/files/run/repl-backticks.scala index 11c58e18a1..5eaa1ec4c1 100644 --- a/test/files/run/repl-backticks.scala +++ b/test/files/run/repl-backticks.scala @@ -11,7 +11,7 @@ object Test { def main(args: Array[String]) = { val settings = new Settings() settings.classpath.value = System.getProperty("java.class.path") - val repl = new Interpreter(settings) + val repl = new interpreter.IMain(settings) repl.interpret(testCode) } } diff --git a/test/files/run/repl-colon-type.check b/test/files/run/repl-colon-type.check index 66c2fcc77f..cb0b9a6c8b 100644 --- a/test/files/run/repl-colon-type.check +++ b/test/files/run/repl-colon-type.check @@ -7,6 +7,12 @@ scala> :type List[1, 2, 3] <console>:2: error: identifier expected but integer literal found. List[1, 2, 3] ^ +<console>:3: error: ']' expected but '}' found. + } + ^ +<console>:1: error: identifier expected but integer literal found. + List[1, 2, 3] + ^ scala> :type List(1, 2, 3) @@ -25,7 +31,7 @@ scala> :type def f[T >: Null, U <: String](x: T, y: U) = Set(x, y) [T >: Null, U <: String](x: T, y: U)scala.collection.immutable.Set[Any] scala> :type def x = 1 ; def bar[T >: Null <: AnyRef](xyz: T) = 5 -[T >: Null <: AnyRef](xyz: T)Int +=> Int <and> [T >: Null <: AnyRef](xyz: T)Int scala> @@ -39,10 +45,19 @@ scala> :type lazy val f = 5 Int scala> :type protected lazy val f = 5 -Int +<console>:2: error: illegal start of statement (no modifiers allowed here) + protected lazy val f = 5 + ^ +<console>:5: error: lazy value f cannot be accessed in object $iw + Access to protected value f not permitted because + enclosing object $eval in package $line19 is not a subclass of + object $iw where target is defined + lazy val $result = `f` + ^ + scala> :type def f = 5 -Int +=> Int scala> :type def f() = 5 ()Int @@ -54,4 +69,156 @@ scala> :type def g[T](xs: Set[_ <: T]) = Some(xs.head) scala> +scala> // verbose! + +scala> :type -v List(1,2,3) filter _ +// Type signature +(Int => Boolean) => List[Int] + +// Internal Type structure +TypeRef( + TypeSymbol(abstract trait Function1[-T1, +R] extends Object) + args = List( + TypeRef( + TypeSymbol(abstract trait Function1[-T1, +R] extends Object) + args = List( + TypeRef(TypeSymbol(final class Int extends AnyVal)) + TypeRef(TypeSymbol(final class Boolean extends AnyVal)) + ) + ) + TypeRef( + TypeSymbol( + sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] + + ) + args = List( + TypeRef(TypeSymbol(final class Int extends AnyVal)) + ) + ) + ) +) + +scala> :type -v def f[T >: Null, U <: String](x: T, y: U) = Set(x, y) +// Type signature +[T >: Null, U <: String](x: T, y: U)scala.collection.immutable.Set[Any] + +// Internal Type structure +PolyType( + typeParams = List(TypeParam(T >: Null), TypeParam(U <: String)) + resultType = MethodType( + params = List(TermSymbol(x: T), TermSymbol(y: U)) + resultType = TypeRef( + TypeSymbol( + abstract trait Set[A] extends Iterable[A] with Set[A] with GenericSetTemplate[A,scala.collection.immutable.Set] with SetLike[A,scala.collection.immutable.Set[A]] with Parallelizable[A,scala.collection.parallel.immutable.ParSet[A]] + + ) + args = List(TypeRef(TypeSymbol(abstract class Any extends ))) + ) + ) +) + +scala> :type -v def x = 1 ; def bar[T >: Null <: AnyRef](xyz: T) = 5 +// Type signature +=> Int <and> [T >: Null <: AnyRef](xyz: T)Int + +// Internal Type structure +OverloadedType( + alts = List( + NullaryMethodType( + TypeRef(TypeSymbol(final class Int extends AnyVal)) + ) + PolyType( + typeParams = List(TypeParam(T >: Null <: AnyRef)) + resultType = MethodType( + params = List(TermSymbol(xyz: T)) + resultType = TypeRef( + TypeSymbol(final class Int extends AnyVal) + ) + ) + ) + ) +) + +scala> :type -v Nil.combinations _ +// Type signature +Int => Iterator[List[Nothing]] + +// Internal Type structure +TypeRef( + TypeSymbol(abstract trait Function1[-T1, +R] extends Object) + args = List( + TypeRef(TypeSymbol(final class Int extends AnyVal)) + TypeRef( + TypeSymbol( + abstract trait Iterator[+A] extends TraversableOnce[A] + ) + args = List( + TypeRef( + TypeSymbol( + sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] + + ) + args = List( + TypeRef( + TypeSymbol(final abstract class Nothing extends Any) + ) + ) + ) + ) + ) + ) +) + +scala> :type -v def f[T <: AnyVal] = List[T]().combinations _ +// Type signature +[T <: AnyVal]=> Int => Iterator[List[T]] + +// Internal Type structure +PolyType( + typeParams = List(TypeParam(T <: AnyVal)) + resultType = NullaryMethodType( + TypeRef( + TypeSymbol(abstract trait Function1[-T1, +R] extends Object) + args = List( + TypeRef(TypeSymbol(final class Int extends AnyVal)) + TypeRef( + TypeSymbol( + abstract trait Iterator[+A] extends TraversableOnce[A] + ) + args = List( + TypeRef( + TypeSymbol( + sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] + + ) + args = List(TypeParamTypeRef(TypeParam(T <: AnyVal))) + ) + ) + ) + ) + ) + ) +) + +scala> :type -v def f[T, U >: T](x: T, y: List[U]) = x :: y +// Type signature +[T, U >: T](x: T, y: List[U])List[U] + +// Internal Type structure +PolyType( + typeParams = List(TypeParam(T), TypeParam(U >: T)) + resultType = MethodType( + params = List(TermSymbol(x: T), TermSymbol(y: List[U])) + resultType = TypeRef( + TypeSymbol( + sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] + + ) + args = List(TypeParamTypeRef(TypeParam(U >: T))) + ) + ) +) + +scala> + scala> diff --git a/test/files/run/repl-colon-type.scala b/test/files/run/repl-colon-type.scala index 39ab580d2a..c055b215c2 100644 --- a/test/files/run/repl-colon-type.scala +++ b/test/files/run/repl-colon-type.scala @@ -18,6 +18,14 @@ object Test extends ReplTest { |:type def f() = 5 | |:type def g[T](xs: Set[_ <: T]) = Some(xs.head) + | + |// verbose! + |:type -v List(1,2,3) filter _ + |:type -v def f[T >: Null, U <: String](x: T, y: U) = Set(x, y) + |:type -v def x = 1 ; def bar[T >: Null <: AnyRef](xyz: T) = 5 + |:type -v Nil.combinations _ + |:type -v def f[T <: AnyVal] = List[T]().combinations _ + |:type -v def f[T, U >: T](x: T, y: List[U]) = x :: y """.stripMargin } diff --git a/test/files/run/repl-exceptions.check b/test/files/run/repl-exceptions.check deleted file mode 100644 index f7ce018422..0000000000 --- a/test/files/run/repl-exceptions.check +++ /dev/null @@ -1,25 +0,0 @@ -Type in expressions to have them evaluated. -Type :help for more information. - -scala> - -scala> sys.SystemProperties.traceSourcePath setValue "" -res0: String = null - -scala> def f = sys.error("hi mom") -f: Nothing - -scala> f -[package.error] (package.scala:27) -(access lastException for the full trace) - -scala> lastException.show -/* The repl internal portion of the stack trace is elided. */ -[package.error] (package.scala:27) -[.f] (<console>:7) -[.<init>] (<console>:9) -[.<clinit>] (<console>:-1) - -scala> - -scala> diff --git a/test/files/run/repl-exceptions.scala b/test/files/run/repl-exceptions.scala deleted file mode 100644 index bccedeba6b..0000000000 --- a/test/files/run/repl-exceptions.scala +++ /dev/null @@ -1,13 +0,0 @@ -import scala.tools.partest.ReplTest -import scala.tools.util.Javap - -// This test blows up under -Yrepl-sync. -object Test extends ReplTest { - override def extraSettings = "-Yrich-exceptions" - def code = """ - |sys.SystemProperties.traceSourcePath setValue "" - |def f = sys.error("hi mom") - |f - |lastException.show - """.stripMargin -} diff --git a/test/files/run/repl-parens.check b/test/files/run/repl-parens.check index 69f0a9ce30..4b7ce6b059 100644 --- a/test/files/run/repl-parens.check +++ b/test/files/run/repl-parens.check @@ -34,7 +34,7 @@ res7: (Int, Int) = (4,4) scala> (((2 + 2)), ((2 + 2)), 2) res8: (Int, Int, Int) = (4,4,2) -scala> ((((2 + 2)), ((2 + 2)), 2).productIterator ++ Iterator(3) mkString) +scala> (((((2 + 2)), ((2 + 2)), 2).productIterator ++ Iterator(3)).mkString) res9: String = 4423 scala> diff --git a/test/files/run/repl-parens.scala b/test/files/run/repl-parens.scala index c1cf9b50e1..e25933b1a2 100644 --- a/test/files/run/repl-parens.scala +++ b/test/files/run/repl-parens.scala @@ -11,7 +11,7 @@ object Test extends ReplTest { 5 ; ( (2 + 2 ) ) ; ((5)) (((2 + 2)), ((2 + 2))) (((2 + 2)), ((2 + 2)), 2) -((((2 + 2)), ((2 + 2)), 2).productIterator ++ Iterator(3) mkString) +(((((2 + 2)), ((2 + 2)), 2).productIterator ++ Iterator(3)).mkString) 55 ; ((2 + 2)) ; (1, 2, 3) 55 ; (x: Int) => x + 1 ; () => ((5)) @@ -26,4 +26,4 @@ foo(5)(10)(15)+foo(5)(10)(15) List(1) ++ List('a') """.trim -}
\ No newline at end of file +} diff --git a/test/files/run/repl-power.check b/test/files/run/repl-power.check index b811a4a8c5..c509434116 100644 --- a/test/files/run/repl-power.check +++ b/test/files/run/repl-power.check @@ -13,7 +13,7 @@ scala> // guarding against "error: reference to global is ambiguous" scala> global.emptyValDef // "it is imported twice in the same scope by ..."
res0: $r.global.emptyValDef.type = private val _ = _
-scala> val tp = ArrayClass[scala.util.Random] // magic with manifests
+scala> val tp = ArrayClass[scala.util.Random] // magic with tags
tp: $r.global.Type = Array[scala.util.Random]
scala> tp.memberType(Array_apply) // evidence
diff --git a/test/files/run/repl-power.scala b/test/files/run/repl-power.scala index 27da3df106..f7c88c63ff 100644 --- a/test/files/run/repl-power.scala +++ b/test/files/run/repl-power.scala @@ -5,10 +5,9 @@ object Test extends ReplTest { :power // guarding against "error: reference to global is ambiguous" global.emptyValDef // "it is imported twice in the same scope by ..." -val tp = ArrayClass[scala.util.Random] // magic with manifests +val tp = ArrayClass[scala.util.Random] // magic with tags tp.memberType(Array_apply) // evidence val m = LIT(10) MATCH (CASE(LIT(5)) ==> FALSE, DEFAULT ==> TRUE) // treedsl typed(m).tpe // typed is in scope """.trim } - diff --git a/test/files/run/repl-suppressed-warnings.check b/test/files/run/repl-suppressed-warnings.check deleted file mode 100644 index ef9e5c1270..0000000000 --- a/test/files/run/repl-suppressed-warnings.check +++ /dev/null @@ -1,65 +0,0 @@ -Type in expressions to have them evaluated. -Type :help for more information. - -scala> - -scala> - -scala> // "Is this thing on?" Not working on first couple - -scala> // commands, needs investigation. - -scala> 123 -res0: Int = 123 - -scala> 123 -res1: Int = 123 - -scala> 123 -res2: Int = 123 - -scala> - -scala> object o { - case class Bippy() - case class Dingus { - def f[T](xs: TraversableOnce[T]) = xs match { - case _: List[Int] => 1 - case _: Set[String] => 2 - case _ => xs.isInstanceOf[Iterator[Double]] - } - } - case class DingDangDoobie(ding: Int, dang: Int, doobie: Double) - case class Dongoo - @serializable case class Heyooooo - - @deprecated("I'm an ironic deprecation warning") def f0 = 5 // where's this disappearing? - def f1 = Double.Epsilon // and this? -} -warning: there were 6 deprecation warnings; re-run with -deprecation for details -warning: there were 3 unchecked warnings; re-run with -unchecked for details -defined module o - -scala> - -scala> :warnings -<console>:3: warning: case classes without a parameter list have been deprecated; -use either case objects or case classes with `()' as parameter list. - case class Dingus { - ^ -<console>:11: warning: case classes without a parameter list have been deprecated; -use either case objects or case classes with `()' as parameter list. - case class Dongoo - ^ -<console>:11: warning: case classes without a parameter list have been deprecated; -use either case objects or case classes with `()' as parameter list. - case class Dongoo - ^ -<console>:12: warning: case classes without a parameter list have been deprecated; -use either case objects or case classes with `()' as parameter list. - @serializable case class Heyooooo - ^ - -scala> - -scala> diff --git a/test/files/run/repl-suppressed-warnings.scala b/test/files/run/repl-suppressed-warnings.scala deleted file mode 100644 index a78b00f36e..0000000000 --- a/test/files/run/repl-suppressed-warnings.scala +++ /dev/null @@ -1,31 +0,0 @@ -import scala.tools.partest.ReplTest - -object Test extends ReplTest { - def code = """ - -// "Is this thing on?" Not working on first couple -// commands, needs investigation. -123 -123 -123 - -object o { - case class Bippy() - case class Dingus { - def f[T](xs: TraversableOnce[T]) = xs match { - case _: List[Int] => 1 - case _: Set[String] => 2 - case _ => xs.isInstanceOf[Iterator[Double]] - } - } - case class DingDangDoobie(ding: Int, dang: Int, doobie: Double) - case class Dongoo - @serializable case class Heyooooo - - @deprecated("I'm an ironic deprecation warning") def f0 = 5 // where's this disappearing? - def f1 = Double.Epsilon // and this? -} - -:warnings - """ -} diff --git a/test/files/run/repl-type-verbose.check b/test/files/run/repl-type-verbose.check new file mode 100644 index 0000000000..103ac3e64d --- /dev/null +++ b/test/files/run/repl-type-verbose.check @@ -0,0 +1,186 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> + +scala> // verbose! + +scala> :type -v def f = 5 +// Type signature +=> Int + +// Internal Type structure +NullaryMethodType( + TypeRef(TypeSymbol(final class Int extends AnyVal)) +) + +scala> :type -v def f() = 5 +// Type signature +()Int + +// Internal Type structure +NullaryMethodType( + resultType = TypeRef(TypeSymbol(final class Int extends AnyVal)) +) + +scala> :type -v def f[T] = 5 +// Type signature +[T]=> Int + +// Internal Type structure +PolyType( + typeParams = List(TypeParam(T)) + resultType = NullaryMethodType( + TypeRef(TypeSymbol(final class Int extends AnyVal)) + ) +) + +scala> :type -v def f[T >: Null] = 5 +// Type signature +[T >: Null]=> Int + +// Internal Type structure +PolyType( + typeParams = List(TypeParam(T >: Null)) + resultType = NullaryMethodType( + TypeRef(TypeSymbol(final class Int extends AnyVal)) + ) +) + +scala> :type -v def f[T <: String] = 5 +// Type signature +[T <: String]=> Int + +// Internal Type structure +PolyType( + typeParams = List(TypeParam(T <: String)) + resultType = NullaryMethodType( + TypeRef(TypeSymbol(final class Int extends AnyVal)) + ) +) + +scala> :type -v def f[T]() = 5 +// Type signature +[T]()Int + +// Internal Type structure +PolyType( + typeParams = List(TypeParam(T)) + resultType = NullaryMethodType( + resultType = TypeRef(TypeSymbol(final class Int extends AnyVal)) + ) +) + +scala> :type -v def f[T, U]() = 5 +// Type signature +[T, U]()Int + +// Internal Type structure +PolyType( + typeParams = List(TypeParam(T), TypeParam(U)) + resultType = NullaryMethodType( + resultType = TypeRef(TypeSymbol(final class Int extends AnyVal)) + ) +) + +scala> :type -v def f[T, U]()() = 5 +// Type signature +[T, U]()()Int + +// Internal Type structure +PolyType( + typeParams = List(TypeParam(T), TypeParam(U)) + resultType = NullaryMethodType( + resultType = NullaryMethodType( + resultType = TypeRef( + TypeSymbol(final class Int extends AnyVal) + ) + ) + ) +) + +scala> :type -v def f[T, U <: T] = 5 +// Type signature +[T, U <: T]=> Int + +// Internal Type structure +PolyType( + typeParams = List(TypeParam(T), TypeParam(U <: T)) + resultType = NullaryMethodType( + TypeRef(TypeSymbol(final class Int extends AnyVal)) + ) +) + +scala> :type -v def f[T, U <: T](x: T)(y: U) = 5 +// Type signature +[T, U <: T](x: T)(y: U)Int + +// Internal Type structure +PolyType( + typeParams = List(TypeParam(T), TypeParam(U <: T)) + resultType = MethodType( + params = List(TermSymbol(x: T)) + resultType = MethodType( + params = List(TermSymbol(y: U)) + resultType = TypeRef( + TypeSymbol(final class Int extends AnyVal) + ) + ) + ) +) + +scala> :type -v def f[T: Ordering] = 5 +// Type signature +[T](implicit evidence$1: Ordering[T])Int + +// Internal Type structure +PolyType( + typeParams = List(TypeParam(T)) + resultType = MethodType( + params = List(TermSymbol(implicit evidence$1: Ordering[T])) + resultType = TypeRef(TypeSymbol(final class Int extends AnyVal)) + ) +) + +scala> :type -v def f[T: Ordering] = implicitly[Ordering[T]] +// Type signature +[T](implicit evidence$1: Ordering[T])Ordering[T] + +// Internal Type structure +PolyType( + typeParams = List(TypeParam(T)) + resultType = MethodType( + params = List(TermSymbol(implicit evidence$1: Ordering[T])) + resultType = AliasTypeRef( + Alias(type Ordering[T] = scala.math.Ordering[T]) + args = List(TypeParamTypeRef(TypeParam(T))) + normalize = TypeRef( + TypeSymbol( + abstract trait Ordering[T] extends Comparator[T] with PartialOrdering[T] with Serializable + + ) + args = List(TypeParamTypeRef(TypeParam(T))) + ) + ) + ) +) + +scala> :type -v def f[T <: { type Bippy = List[Int] ; def g(): Bippy }] = 5 +// Type signature +[T <: AnyRef{type Bippy = List[Int]; def g(): this.Bippy}]=> Int + +// Internal Type structure +PolyType( + typeParams = List( + TypeParam( + T <: AnyRef{type Bippy = List[Int]; def g(): this.Bippy} + ) + ) + resultType = NullaryMethodType( + TypeRef(TypeSymbol(final class Int extends AnyVal)) + ) +) + +scala> + +scala> diff --git a/test/files/run/repl-type-verbose.scala b/test/files/run/repl-type-verbose.scala new file mode 100644 index 0000000000..10c390550a --- /dev/null +++ b/test/files/run/repl-type-verbose.scala @@ -0,0 +1,20 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + def code = """ + |// verbose! + |:type -v def f = 5 + |:type -v def f() = 5 + |:type -v def f[T] = 5 + |:type -v def f[T >: Null] = 5 + |:type -v def f[T <: String] = 5 + |:type -v def f[T]() = 5 + |:type -v def f[T, U]() = 5 + |:type -v def f[T, U]()() = 5 + |:type -v def f[T, U <: T] = 5 + |:type -v def f[T, U <: T](x: T)(y: U) = 5 + |:type -v def f[T: Ordering] = 5 + |:type -v def f[T: Ordering] = implicitly[Ordering[T]] + |:type -v def f[T <: { type Bippy = List[Int] ; def g(): Bippy }] = 5 + """.stripMargin +} diff --git a/test/files/run/richs-msil.check b/test/files/run/richs-msil.check deleted file mode 100644 index e628ad3998..0000000000 --- a/test/files/run/richs-msil.check +++ /dev/null @@ -1,66 +0,0 @@ - -RichCharTest1: -True -True -True -False - -RichIntTest: -10 -11 -12 -13 -0 -0 - -RichStringTest1: -s1: abc -s2: abc\txyz\n -s3: abc - xyz -s4: abc - |xyz -s5: abc - #xyz - -RichStringTest2: -s1: abc -s2: abc\txyz\n -s3: abc - xyz -s4: abc - |xyz -s5: abc - #xyz - -RichStringTest3: -s1: abc -s2: abc\txyz\n -s3: abc - xyz -s4: abc - |xyz -s5: abc - #xyz - -RichStringTest4: -s1: abc -s2: abc\txyz\n -s3: abc - xyz -s4: abc -xyz -s5: abc - #xyz - -RichStringTest5: -s1: abc - xyz -s2: abc - xyz -s3: abc - xyz -s4: abc - |xyz -s5: abc -xyz diff --git a/test/files/run/runtime-msil.check b/test/files/run/runtime-msil.check deleted file mode 100644 index 70e7608a11..0000000000 --- a/test/files/run/runtime-msil.check +++ /dev/null @@ -1,64 +0,0 @@ -<<< Test0 -[False,True] -[0,1,2] -[3,4,5] -[a,b,c] -[6,7,8] -[9,10,11] -[12,13] -[14,15] -[string] ->>> Test0 - -<<< Test1 -10 -14 -15 -16 -20 -23 -24 -25 -26 ->>> Test1 - -<<< Test2 -A -M0 -N0 - -A -N0 -M0 - -A -M0 -M1 -N0 - -A -N0 -N1 -M0 - ->>> Test2 - -<<< Test3 -Ok -Ok -Ok -Ok -Ok -Ok -Ok -Ok -Ok -Ok -Ok -Ok -Ok -Ok -Ok -Ok ->>> Test3 - diff --git a/test/files/run/si5045.check b/test/files/run/si5045.check new file mode 100644 index 0000000000..7e9c1961b7 --- /dev/null +++ b/test/files/run/si5045.check @@ -0,0 +1,6 @@ + extract an exact match 2011-07-15 2011-07-15 + extract from middle of string 2011-07-15 2011-07-15 + extract from middle of string (P2) 2011-07-15 2011-07-15 + extract from middle of string (P3) 2011-07-15 2011-07-15 + copyright example has date Copyright 2011 Copyright 2011 + copyright example missing date No copyright No copyright diff --git a/test/files/run/si5045.scala b/test/files/run/si5045.scala new file mode 100644 index 0000000000..e198b101f3 --- /dev/null +++ b/test/files/run/si5045.scala @@ -0,0 +1,46 @@ +object Test extends App { + + import scala.util.matching.{ Regex, UnanchoredRegex } + + val dateP1 = """(\d\d\d\d)-(\d\d)-(\d\d)""".r.unanchored + val dateP2 = """(\d\d\d\d)-(\d\d)-(\d\d)""" r ("year", "month", "day") unanchored + val dateP3 = new Regex("""(\d\d\d\d)-(\d\d)-(\d\d)""", "year", "month", "day") with UnanchoredRegex + + val yearStr = "2011" + val dateStr = List(yearStr,"07","15").mkString("-") + + def test(msg: String)(strs: Seq[String]): Unit = println("%40s %s".format(msg, strs mkString " ")) + + test("extract an exact match") { + val dateP1(y,m,d) = dateStr + Seq(List(y,m,d).mkString("-"), dateStr) + } + + test("extract from middle of string") { + val dateP1(y,m,d) = "Tested on "+dateStr+"." + Seq(List(y,m,d).mkString("-"), dateStr) + } + + test("extract from middle of string (P2)") { + val dateP2(y,m,d) = "Tested on "+dateStr+"." + Seq(List(y,m,d).mkString("-"), dateStr) + } + + test("extract from middle of string (P3)") { + val dateP2(y,m,d) = "Tested on "+dateStr+"." + Seq(List(y,m,d).mkString("-"), dateStr) + } + + def copyright(in: String): String = in match { + case dateP1(year, month, day) => "Copyright "+year + case _ => "No copyright" + } + + test("copyright example has date") { + Seq(copyright("Date of this document: "+dateStr), "Copyright "+yearStr) + } + + test("copyright example missing date") { + Seq(copyright("Date of this document: unknown"), "No copyright") + } +} diff --git a/test/files/run/t0421.check b/test/files/run/t0421-new.check index cdcf042f19..cdcf042f19 100644 --- a/test/files/run/t0421.check +++ b/test/files/run/t0421-new.check diff --git a/test/files/run/t0421-new.scala b/test/files/run/t0421-new.scala new file mode 100644 index 0000000000..7de6b7f2c4 --- /dev/null +++ b/test/files/run/t0421-new.scala @@ -0,0 +1,30 @@ +// ticket #421 +object Test extends App { + + def transpose[A: ArrayTag](xss: Array[Array[A]]) = { + for (i <- Array.range(0, xss(0).length)) yield + for (xs <- xss) yield xs(i) + } + + def scalprod(xs: Array[Double], ys: Array[Double]) = { + var acc = 0.0 + for ((x, y) <- xs zip ys) acc = acc + x * y + acc + } + + def matmul(xss: Array[Array[Double]], yss: Array[Array[Double]]) = { + val ysst = transpose(yss) + val ysst1: Array[Array[Double]] = yss.transpose + assert(ysst.deep == ysst1.deep) + for (xs <- xss) yield + for (yst <- ysst) yield + scalprod(xs, yst) + } + + val a1 = Array(Array(0, 2, 4), Array(1, 3, 5)) + println(transpose(a1).deep.mkString("[", ",", "]")) + + println(matmul(Array(Array(2, 3)), Array(Array(5), Array(7))).deep.mkString("[", ",", "]")) + + println(matmul(Array(Array(4)), Array(Array(6, 8))).deep.mkString("[", ",", "]")) +} diff --git a/test/files/run/t0421-old.check b/test/files/run/t0421-old.check new file mode 100644 index 0000000000..cdcf042f19 --- /dev/null +++ b/test/files/run/t0421-old.check @@ -0,0 +1,3 @@ +[Array(0, 1),Array(2, 3),Array(4, 5)] +[Array(31.0)] +[Array(24.0, 32.0)] diff --git a/test/files/run/t0421.scala b/test/files/run/t0421-old.scala index 8d51013924..8d51013924 100644 --- a/test/files/run/t0421.scala +++ b/test/files/run/t0421-old.scala diff --git a/test/files/run/t0677-new.scala b/test/files/run/t0677-new.scala new file mode 100644 index 0000000000..bf7a3971dc --- /dev/null +++ b/test/files/run/t0677-new.scala @@ -0,0 +1,8 @@ +object Test extends App { + class X[T: ArrayTag] { + val a = Array.ofDim[T](3, 4) + } + val x = new X[String] + x.a(1)(2) = "hello" + assert(x.a(1)(2) == "hello") +} diff --git a/test/files/run/t0677.scala b/test/files/run/t0677-old.scala index 6c8a3a7e99..6c8a3a7e99 100644 --- a/test/files/run/t0677.scala +++ b/test/files/run/t0677-old.scala diff --git a/test/files/run/t1195-new.check b/test/files/run/t1195-new.check new file mode 100644 index 0000000000..554e3fd03d --- /dev/null +++ b/test/files/run/t1195-new.check @@ -0,0 +1,6 @@ +ConcreteTypeTag[Bar.type], underlying = <: scala.runtime.AbstractFunction1[Int,Bar] with Serializable{case def unapply(x$0: Bar): Option[Int]} with Singleton
+ConcreteTypeTag[Bar], underlying = <: Product with Serializable{val x: Int; def copy(x: Int): Bar; def copy$default$1: Int; def _1: Int}
+ConcreteTypeTag[Product with Serializable], underlying = Product with Serializable
+ConcreteTypeTag[Bar.type], underlying = <: scala.runtime.AbstractFunction1[Int,Bar] with Serializable{case def unapply(x$0: Bar): Option[Int]} with Singleton
+ConcreteTypeTag[Bar], underlying = <: Product with Serializable{val x: Int; def copy(x: Int): Bar; def copy$default$1: Int; def _1: Int}
+ConcreteTypeTag[Product with Serializable], underlying = Product with Serializable
diff --git a/test/files/run/t1195-new.scala b/test/files/run/t1195-new.scala new file mode 100644 index 0000000000..6f28a4a167 --- /dev/null +++ b/test/files/run/t1195-new.scala @@ -0,0 +1,26 @@ +object Test { + def f() = { case class Bar(x: Int); Bar } + def g() = { case class Bar(x: Int); Bar(5) } + def h() = { case object Bar ; Bar } + + val f1 = f() + val g1 = g() + val h1 = h() + + def m[T: TypeTag](x: T) = println(typeTag[T] + ", underlying = " + typeTag[T].sym.typeSignature) + + def main(args: Array[String]): Unit = { + m(f) + m(g) + m(h) + m(f1) + m(g1) + m(h1) + } +} + +class A1[T] { + class B1[U] { + def f = { case class D(x: Int) extends A1[String] ; new D(5) } + } +} diff --git a/test/files/run/t1195.check.temporarily.disabled b/test/files/run/t1195-old.check index d023bc91f7..eb60eceb17 100644 --- a/test/files/run/t1195.check.temporarily.disabled +++ b/test/files/run/t1195-old.check @@ -1,6 +1,6 @@ -_ <: scala.runtime.AbstractFunction1[Int, _ <: Object with scala.Product with scala.Serializable] with scala.Serializable with java.lang.Object -_ <: Object with scala.Product with scala.Serializable -Object with scala.Product with scala.Serializable -_ <: scala.runtime.AbstractFunction1[Int, _ <: Object with scala.Product with scala.Serializable] with scala.Serializable with java.lang.Object -_ <: Object with scala.Product with scala.Serializable -Object with scala.Product with scala.Serializable +_ <: scala.runtime.AbstractFunction1[Int, _ <: Object with scala.Product with scala.Serializable] with scala.Serializable with java.lang.Object
+_ <: Object with scala.Product with scala.Serializable
+Object with scala.Product with scala.Serializable
+_ <: scala.runtime.AbstractFunction1[Int, _ <: Object with scala.Product with scala.Serializable] with scala.Serializable with java.lang.Object
+_ <: Object with scala.Product with scala.Serializable
+Object with scala.Product with scala.Serializable
diff --git a/test/files/run/t1195.scala.temporarily.disabled b/test/files/run/t1195-old.scala index 81ef5bdb0e..b46a3b70f5 100644 --- a/test/files/run/t1195.scala.temporarily.disabled +++ b/test/files/run/t1195-old.scala @@ -6,7 +6,7 @@ object Test { val f1 = f() val g1 = g() val h1 = h() - + def m[T: Manifest](x: T) = println(manifest[T]) def main(args: Array[String]): Unit = { diff --git a/test/files/run/t1247.check b/test/files/run/t1247.check new file mode 100644 index 0000000000..ce123032fd --- /dev/null +++ b/test/files/run/t1247.check @@ -0,0 +1 @@ +Is same closure class: true is same closure: true diff --git a/test/files/run/t1247.scala b/test/files/run/t1247.scala new file mode 100644 index 0000000000..c709b73bc8 --- /dev/null +++ b/test/files/run/t1247.scala @@ -0,0 +1,11 @@ +object Test extends App { + val f = () => 5 + def test(g: => Int) { + val gFunc = g _ + val isSameClosureClass = gFunc.getClass == f.getClass + val isSame = gFunc eq f + println("Is same closure class: "+isSameClosureClass+" is same closure: "+isSame) + } + + test(f()) +} diff --git a/test/files/run/t1500.scala b/test/files/run/t1500.scala index c312a9a883..ab132b724f 100644 --- a/test/files/run/t1500.scala +++ b/test/files/run/t1500.scala @@ -1,4 +1,4 @@ -import scala.tools.nsc._ +import scala.tools.nsc._ object Test { @@ -8,7 +8,7 @@ object Test { val testCode = <code> - class posingAs[A] extends TypeConstraint + class posingAs[A] extends annotation.TypeConstraint def resolve[A,B](x: A @posingAs[B]): B = x.asInstanceOf[B] @@ -20,7 +20,7 @@ object Test { val settings = new Settings() settings.classpath.value = System.getProperty("java.class.path") - val tool = new Interpreter(settings) + val tool = new interpreter.IMain(settings) val global = tool.compiler import global._ diff --git a/test/files/run/t1501.scala b/test/files/run/t1501.scala index 05e4da8c7a..aba206bc7a 100644 --- a/test/files/run/t1501.scala +++ b/test/files/run/t1501.scala @@ -8,7 +8,7 @@ object Test { val testCode = <code> - class xyz[A] extends TypeConstraint + class xyz[A] extends annotation.TypeConstraint def loopWhile[T](cond: =>Boolean)(body: =>(Unit @xyz[T])): Unit @ xyz[T] = {{ if (cond) {{ @@ -30,7 +30,7 @@ object Test { def main(args: Array[String]) = { val settings = new Settings() settings.classpath.value = System.getProperty("java.class.path") - val tool = new Interpreter(settings) + val tool = new interpreter.IMain(settings) val global = tool.compiler import global._ diff --git a/test/files/run/t1697.scala b/test/files/run/t1697.scala new file mode 100644 index 0000000000..01590dd405 --- /dev/null +++ b/test/files/run/t1697.scala @@ -0,0 +1,19 @@ +class Term +case class Num(n: Int) extends Term +case class Add(x: Term, y: Term) extends Term + +object Value { + def unapply(term: Any): Boolean = true +} + +object Test { + def main(args: Array[String]) { + val term = Add(Num(1), Add(Num(2), Num(3))) + val res = term match { + case Add(Num(x), Num(y)) => "Add(Num, Num)" + case Add(Value(), y) => "Add(Value, ?)" + case _ => "?" + } + assert(res == "Add(Value, ?)") + } +} diff --git a/test/files/run/t2236-new.scala b/test/files/run/t2236-new.scala new file mode 100644 index 0000000000..bbabe8e7d9 --- /dev/null +++ b/test/files/run/t2236-new.scala @@ -0,0 +1,17 @@ +class T[A](implicit val m:TypeTag[A]) +class Foo +class Bar extends T[Foo] +object Test extends App { + new Bar +} + +object EvidenceTest { + trait E[T] + trait A[T] { implicit val e: E[T] = null } + class B[T : E] extends A[T] { override val e = null } + + def f[T] { + implicit val e: E[T] = null + new B[T]{} + } +} diff --git a/test/files/run/t2236.scala b/test/files/run/t2236-old.scala index 64ed18c805..64ed18c805 100755..100644 --- a/test/files/run/t2236.scala +++ b/test/files/run/t2236-old.scala diff --git a/test/files/run/t2296c.check b/test/files/run/t2296c.check new file mode 100644 index 0000000000..076e9180a8 --- /dev/null +++ b/test/files/run/t2296c.check @@ -0,0 +1 @@ +RUNNING ACTION diff --git a/test/files/run/t2296c/Action.java b/test/files/run/t2296c/Action.java new file mode 100644 index 0000000000..50ba9a4de1 --- /dev/null +++ b/test/files/run/t2296c/Action.java @@ -0,0 +1,21 @@ +package bug.action; + +import bug.Global; + +public abstract class Action { + protected Global m_glob; + + public Action(Global glob0) { + m_glob = glob0; + } + + public Action() { + this(null); + } + + public abstract void run(int v); + + public void setGlobal(Global g) { + m_glob = g; + } +} diff --git a/test/files/run/t2296c/Display.java b/test/files/run/t2296c/Display.java new file mode 100644 index 0000000000..7f7e6a73d0 --- /dev/null +++ b/test/files/run/t2296c/Display.java @@ -0,0 +1,9 @@ +package bug; + +public class Display { + protected Global m_glob; + + public void start() { + m_glob.runActions(); + } +} diff --git a/test/files/run/t2296c/Global.java b/test/files/run/t2296c/Global.java new file mode 100644 index 0000000000..7e5a762de2 --- /dev/null +++ b/test/files/run/t2296c/Global.java @@ -0,0 +1,29 @@ +package bug; + +import bug.action.Action; +import java.util.List; +import java.util.LinkedList; + +public class Global { + public int items() { + return 0; + } + + public int items(int i) { + return i + ls.size(); + } + + private List<Action> ls = new LinkedList<Action>(); + + public void putAction(Action a) { + a.setGlobal(this); + ls.add(a); + } + + public void runActions() { + for (Action action: ls) { + System.out.println("RUNNING ACTION"); + action.run(0); + } + } +} diff --git a/test/files/run/t2296c/ScalaActivity.scala b/test/files/run/t2296c/ScalaActivity.scala new file mode 100644 index 0000000000..aa7648a944 --- /dev/null +++ b/test/files/run/t2296c/ScalaActivity.scala @@ -0,0 +1,18 @@ +package test + +import bug.Display +import bug.action.Action + +abstract class Outer extends Display { + + def init() { + m_glob.putAction(ScalaActivity) + } + + object ScalaActivity extends Action { + def run(v: Int) { + val testSet = List(1,2,3) + testSet.map(p => m_glob.items(p)) // crash with illegal access + } + } +} diff --git a/test/files/run/t2296c/Test.scala b/test/files/run/t2296c/Test.scala new file mode 100644 index 0000000000..1132bebebb --- /dev/null +++ b/test/files/run/t2296c/Test.scala @@ -0,0 +1,15 @@ +package test + +import bug.Global + +object Test { + def main(args: Array[String]) { + val m = new Main() + m.init() + m.start() + } +} + +class Main extends Outer { + m_glob = new Global() +} diff --git a/test/files/run/t2296c/a.scala b/test/files/run/t2296c/a.scala new file mode 100644 index 0000000000..fae32f4ec4 --- /dev/null +++ b/test/files/run/t2296c/a.scala @@ -0,0 +1,5 @@ +object Test { + def main(args: Array[String]): Unit = { + test.Test main args + } +} diff --git a/test/files/run/t2337.check b/test/files/run/t2337.check new file mode 100644 index 0000000000..18f1f66fc3 --- /dev/null +++ b/test/files/run/t2337.check @@ -0,0 +1,4 @@ +(Both Int,-1,-1) +(Both Float,1,1) +(Float then Int,0,0) +(Int then Float,0,0) diff --git a/test/files/run/t2337.scala b/test/files/run/t2337.scala new file mode 100644 index 0000000000..86a372ce56 --- /dev/null +++ b/test/files/run/t2337.scala @@ -0,0 +1,21 @@ + +object Test { + + def compare(first: Any, second: Any): Any = { + (first, second) match { + case (k: Int, o: Int) => k compare o + //why the next case matches (Float, Int) but does not match (Int, Float) ??? + case (k: Number, o: Number) => k.doubleValue() compare o.doubleValue() + case _ => "BOGON" + // throw new Exception("Unsupported compare " + first + "; " + second) + } + } + + def main(args: Array[String]): Unit = { + println("Both Int", -1, compare(0, 1)) + println("Both Float", 1, compare(1.0, 0.0)) + println("Float then Int", 0, compare(10.0, 10)) + println("Int then Float", 0, compare(10, 10.0)) //this fails with an exception + } +} + diff --git a/test/files/run/t2386-new.check b/test/files/run/t2386-new.check new file mode 100644 index 0000000000..98e226f946 --- /dev/null +++ b/test/files/run/t2386-new.check @@ -0,0 +1,2 @@ +a(0) = Array(1, 2)
+a(1) = Array("a", "b")
diff --git a/test/files/run/t2386-new.scala b/test/files/run/t2386-new.scala new file mode 100644 index 0000000000..15d1859759 --- /dev/null +++ b/test/files/run/t2386-new.scala @@ -0,0 +1,5 @@ +object Test extends App { + val a = Array(Array(1, 2), Array("a","b")) + println("a(0) = Array(" + (a(0) mkString ", ") + ")") + println("a(1) = Array(" + (a(1) map (s => "\"" + s + "\"") mkString ", ") + ")") +} diff --git a/test/files/run/t2488.check b/test/files/run/t2488.check new file mode 100644 index 0000000000..1af4bf8965 --- /dev/null +++ b/test/files/run/t2488.check @@ -0,0 +1,4 @@ +1 +1 +1 +2 diff --git a/test/files/run/t2488.scala b/test/files/run/t2488.scala new file mode 100644 index 0000000000..22abdf8af2 --- /dev/null +++ b/test/files/run/t2488.scala @@ -0,0 +1,11 @@ +class C { + def f(a:Int, b:Int) = 1 + def f() = 2 +} +object Test extends App { + val c = new C() + println(c.f(a = 1,2)) + println(c.f(a = 1, b = 2)) + println(c.f(b = 2, a = 1)) + println(c.f()) +} diff --git a/test/files/run/t2886.check b/test/files/run/t2886.check index 5fe1e73a45..8d97a82799 100644 --- a/test/files/run/t2886.check +++ b/test/files/run/t2886.check @@ -1,5 +1,5 @@ -((x: scala.Predef.String) => { - val x$1 = x; - val x$2 = x; - Test.test(x$2, x$1) -}) +((x: String) => {
+ val x$1 = x;
+ val x$2 = x;
+ Test.this.test(x$2, x$1)
+})
diff --git a/test/files/run/t2886.scala b/test/files/run/t2886.scala new file mode 100644 index 0000000000..e0835a0a44 --- /dev/null +++ b/test/files/run/t2886.scala @@ -0,0 +1,9 @@ +import scala.reflect.mirror._ + +object Test { + def test(name: String, address: String) = null + def main(args: Array[String]) = { + val tree = reify((x:String) => test(address=x,name=x)).tree + println(tree) + } +} diff --git a/test/files/run/t3097.check b/test/files/run/t3097.check new file mode 100644 index 0000000000..63695f771b --- /dev/null +++ b/test/files/run/t3097.check @@ -0,0 +1 @@ +atomic diff --git a/test/files/run/t3097.scala b/test/files/run/t3097.scala new file mode 100644 index 0000000000..4aaf8056ca --- /dev/null +++ b/test/files/run/t3097.scala @@ -0,0 +1,18 @@ +sealed trait ISimpleValue + +sealed trait IListValue extends ISimpleValue +sealed trait IAtomicValue[O] extends ISimpleValue + +sealed trait IAbstractDoubleValue[O] extends IAtomicValue[O] +sealed trait IDoubleValue extends IAbstractDoubleValue[Double] + +case class ListValue(val items: List[IAtomicValue[_]]) extends IListValue +class DoubleValue(val data: Double) extends IDoubleValue + +object Test extends App { + // match is exhaustive + (new DoubleValue(1): ISimpleValue) match { + case m: IListValue => println("list") + case a: IAtomicValue[_] => println("atomic") + } +} diff --git a/test/files/run/t3488.check b/test/files/run/t3488.check new file mode 100644 index 0000000000..0d66ea1aee --- /dev/null +++ b/test/files/run/t3488.check @@ -0,0 +1,2 @@ +0 +1 diff --git a/test/files/run/t3488.scala b/test/files/run/t3488.scala new file mode 100644 index 0000000000..20a1400dce --- /dev/null +++ b/test/files/run/t3488.scala @@ -0,0 +1,6 @@ +object Test extends App { + def foo(p: => Unit)(x:Int = 0) = x + + println(foo { val List(_*)=List(0); 1 } ()) + println(foo { val List(_*)=List(0); 1 } (1)) +} diff --git a/test/files/run/t3507-new.check b/test/files/run/t3507-new.check new file mode 100644 index 0000000000..6e4fa4170e --- /dev/null +++ b/test/files/run/t3507-new.check @@ -0,0 +1 @@ +ConcreteTypeTag[_1.b.c.type]
diff --git a/test/files/run/t3507-new.scala b/test/files/run/t3507-new.scala new file mode 100644 index 0000000000..c7a529e8b8 --- /dev/null +++ b/test/files/run/t3507-new.scala @@ -0,0 +1,15 @@ +class A { + object b { + object c + } + def m = b.c +} + +object Test extends App { + var a: A = new A // mutable + val c /*: object _1.b.c forSome { val _1: A } */ = a.m // widening using existential + + def mani[T: TypeTag](x: T) = println(typeTag[T]) + mani/*[object _1.b.c]*/(c) // kaboom in manifestOfType / TreeGen.mkAttributedQualifier + // --> _1 is not in scope here +}
\ No newline at end of file diff --git a/test/files/run/t3569.check b/test/files/run/t3569.check index 24cee4bf00..a9fb5ff32e 100644 --- a/test/files/run/t3569.check +++ b/test/files/run/t3569.check @@ -8,10 +8,9 @@ private int Test$X.lval3 private int Test$X.var1 private int Test$X.var2 private int Test$X.var3 -private volatile int Test$X.bitmap$priv$0 -public int Test$X.x -public volatile int Test$X.bitmap$0 -public final int Test$Y.z1 -public final int Test$Y.z2 -public int Test$Y.x -public int Test$Y.y +private int Test$X.x +private volatile byte Test$X.bitmap$0 +private final int Test$Y.z1 +private final int Test$Y.z2 +private int Test$Y.x +private int Test$Y.y diff --git a/test/files/run/t3702.check b/test/files/run/t3702.check new file mode 100644 index 0000000000..31c2ac4ed1 --- /dev/null +++ b/test/files/run/t3702.check @@ -0,0 +1,2 @@ +() +6 diff --git a/test/files/run/t3702.scala b/test/files/run/t3702.scala new file mode 100644 index 0000000000..021abcb625 --- /dev/null +++ b/test/files/run/t3702.scala @@ -0,0 +1,11 @@ +object Test { + def foo(h: Any, t: List[Any]) = h match { + case 5 :: _ => () + case List(from) => from + } + + def main(args: Array[String]): Unit = { + println(foo(5 :: Nil, List(1,2,3))) + println(foo(6 :: Nil, List(1,2,3))) + } +} diff --git a/test/files/run/t3705.scala b/test/files/run/t3705.scala new file mode 100644 index 0000000000..fcc020f28c --- /dev/null +++ b/test/files/run/t3705.scala @@ -0,0 +1,17 @@ +// package foo + +import scala.xml._ +object Test { + def updateNodes(ns: Seq[Node]): Seq[Node] = + for(subnode <- ns) yield subnode match { + case <d>{_}</d> if true => <d>abc</d> + case Elem(prefix, label, attribs, scope, children @ _*) => + Elem(prefix, label, attribs, scope, updateNodes(children) : _*) + case other => other + } + def main(args: Array[String]): Unit = { + updateNodes(<b />) + + } +} + diff --git a/test/files/run/t3758-old.scala b/test/files/run/t3758-old.scala new file mode 100644 index 0000000000..f00254afee --- /dev/null +++ b/test/files/run/t3758-old.scala @@ -0,0 +1,10 @@ +object Test { + def main(args: Array[String]): Unit = { + assert(classManifest[Array[String]].typeArguments contains classManifest[String]) + assert(classManifest[Array[Int]].typeArguments contains classManifest[Int]) + assert(classManifest[Array[Float]].typeArguments contains classManifest[Float]) + assert(manifest[Array[String]].typeArguments contains manifest[String]) + assert(manifest[Array[Int]].typeArguments contains manifest[Int]) + assert(manifest[Array[Float]].typeArguments contains manifest[Float]) + } +}
\ No newline at end of file diff --git a/test/files/run/t3758.check b/test/files/run/t3758.check deleted file mode 100644 index 9c6ab655a3..0000000000 --- a/test/files/run/t3758.check +++ /dev/null @@ -1,6 +0,0 @@ -List(String)
-List(Int)
-List(Float)
-List(String)
-List(Int)
-List(Float)
diff --git a/test/files/run/t3758.scala b/test/files/run/t3758.scala deleted file mode 100644 index 10bfb5724b..0000000000 --- a/test/files/run/t3758.scala +++ /dev/null @@ -1,10 +0,0 @@ -object Test { - def main(args: Array[String]): Unit = { - println(classManifest[Array[String]].tpe.typeArguments) - println(classManifest[Array[Int]].tpe.typeArguments) - println(classManifest[Array[Float]].tpe.typeArguments) - println(manifest[Array[String]].tpe.typeArguments) - println(manifest[Array[Int]].tpe.typeArguments) - println(manifest[Array[Float]].tpe.typeArguments) - } -} diff --git a/test/files/run/t3761-overload-byname.check b/test/files/run/t3761-overload-byname.check new file mode 100644 index 0000000000..ab7eff0d8a --- /dev/null +++ b/test/files/run/t3761-overload-byname.check @@ -0,0 +1,12 @@ +hello! +hello working world +goodnight! +goodnight moon, nobody, noises everywhere +0 +1 +0 +1 +0 +1 +0 +1 diff --git a/test/files/run/t3761-overload-byname.scala b/test/files/run/t3761-overload-byname.scala new file mode 100644 index 0000000000..a52d866097 --- /dev/null +++ b/test/files/run/t3761-overload-byname.scala @@ -0,0 +1,39 @@ + +class OverTheTop { + def info0(m: String) = m + "!" + def info0(m: String, args: Any*) = m +" "+ args.mkString(" ") + + // as reported + def info1(m: =>String) = m + "!" + def info1(m: =>String, args: Any*) = m +" "+ args.mkString(", ") + + // @lrytz + def m[A](x: => Int) = 0; def m[A](x: => Int, xs: Int*) = 1 + + def m1(x: => Int, s: String) = 0 + def m1(x: => Int, s: Object) = 1 + + def m2(x: => Int, s: String) = 0 + def m2(x: => AnyVal, s: Object) = 1 + + def m3(x: => Int, s: String) = 0 + def m3(x: => Any, s: Object) = 1 +} + +object Test { + def main(args: Array[String]) { + val top = new OverTheTop + println(top.info0("hello")) + println(top.info0("hello","working","world")) + println(top.info1("goodnight")) + println(top.info1("goodnight", "moon", "nobody", "noises everywhere")) + println(top.m(17)) + println(top.m(17,19)) + println(top.m1(1, "two")) + println(top.m1(1, new Object())) + println(top.m2(1, "")) + println(top.m2(1d, "")) + println(top.m3(1, "")) + println(top.m3("", "")) + } +} diff --git a/test/files/run/t3798.check b/test/files/run/t3798.check new file mode 100644 index 0000000000..27ba77ddaf --- /dev/null +++ b/test/files/run/t3798.check @@ -0,0 +1 @@ +true diff --git a/test/files/run/t3798.scala b/test/files/run/t3798.scala new file mode 100644 index 0000000000..3ede57bee7 --- /dev/null +++ b/test/files/run/t3798.scala @@ -0,0 +1,10 @@ +object Test { + def main(args: Array[String]) { + val seq: MySeq[Undefined] = new MySeq[Floats](new Array[Float](10)) + println(10 == seq.array.length) + } +} + +sealed trait Undefined { type ArrayType <: Array[_] } +sealed trait Floats extends Undefined { type ArrayType = Array[Float] } +class MySeq[+T <: Undefined](val array: T#ArrayType) diff --git a/test/files/run/t3835.scala b/test/files/run/t3835.scala index 49e591195f..c120a61f6e 100644 --- a/test/files/run/t3835.scala +++ b/test/files/run/t3835.scala @@ -1,4 +1,9 @@ object Test extends App { - println((1, 2, 3) match { case (r, \u03b8, \u03c6) => r + \u03b8 + \u03c6 }) - println(1 match { case \u00e9 => \u00e9 }) + // work around optimizer bug SI-5672 -- generates wrong bytecode for switches in arguments + // virtpatmat happily emits a switch for a one-case switch, whereas -Xoldpatmat did not + // this is not the focus of this test, hence the temporary workaround + def a = (1, 2, 3) match { case (r, \u03b8, \u03c6) => r + \u03b8 + \u03c6 } + println(a) + def b = (1 match { case \u00e9 => \u00e9 }) + println(b) } diff --git a/test/files/run/t4025.check b/test/files/run/t4025.check new file mode 100644 index 0000000000..6715003cb6 --- /dev/null +++ b/test/files/run/t4025.check @@ -0,0 +1,19 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> + +scala> class Color(val red: Int) +defined class Color + +scala> + +scala> case class Red(r:Int) extends Color(r) +defined class Red + +scala> + +scala> def f(c: Any) = c match { case Red(_) => () } +f: (c: Any)Unit + +scala> diff --git a/test/files/run/t4025.scala b/test/files/run/t4025.scala new file mode 100644 index 0000000000..5db0093970 --- /dev/null +++ b/test/files/run/t4025.scala @@ -0,0 +1,12 @@ +import scala.tools.nsc.Settings +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + def code = """ +class Color(val red: Int) + +case class Red(r:Int) extends Color(r) + +def f(c: Any) = c match { case Red(_) => () } +""" +} diff --git a/test/files/run/t4110-new.check b/test/files/run/t4110-new.check new file mode 100644 index 0000000000..28f220e1fe --- /dev/null +++ b/test/files/run/t4110-new.check @@ -0,0 +1,2 @@ +ConcreteTypeTag[Test.A with Test.B]
+ConcreteTypeTag[Test.A with Test.B]
diff --git a/test/files/run/t4110-new.scala b/test/files/run/t4110-new.scala new file mode 100644 index 0000000000..3285b82c61 --- /dev/null +++ b/test/files/run/t4110-new.scala @@ -0,0 +1,11 @@ +object Test extends App { + def inferredType[T : TypeTag](v : T) = println(typeTag[T]) + + trait A + trait B + + inferredType(new A with B) + + val name = new A with B + inferredType(name) +}
\ No newline at end of file diff --git a/test/files/run/t4110.check.temporarily.disabled b/test/files/run/t4110-old.check index 8b005989de..8b005989de 100644 --- a/test/files/run/t4110.check.temporarily.disabled +++ b/test/files/run/t4110-old.check diff --git a/test/files/run/t4110.scala.temporarily.disabled b/test/files/run/t4110-old.scala index 4bd377b73e..a42646ce52 100644 --- a/test/files/run/t4110.scala.temporarily.disabled +++ b/test/files/run/t4110-old.scala @@ -3,7 +3,7 @@ object Test extends App { trait A trait B - + inferredType(new A with B) val name = new A with B diff --git a/test/files/run/t4124.check b/test/files/run/t4124.check new file mode 100644 index 0000000000..66a0092d93 --- /dev/null +++ b/test/files/run/t4124.check @@ -0,0 +1,4 @@ +hi +hi +bye +bye diff --git a/test/files/run/t4124.scala b/test/files/run/t4124.scala new file mode 100644 index 0000000000..9f35b57ce3 --- /dev/null +++ b/test/files/run/t4124.scala @@ -0,0 +1,24 @@ +import xml.Node + +object Test extends App { + val body: Node = <elem>hi</elem> + println ((body: AnyRef, "foo") match { + case (node: Node, "bar") => "bye" + case (ser: Serializable, "foo") => "hi" + }) + + println ((body, "foo") match { + case (node: Node, "bar") => "bye" + case (ser: Serializable, "foo") => "hi" + }) + + println ((body: AnyRef, "foo") match { + case (node: Node, "foo") => "bye" + case (ser: Serializable, "foo") => "hi" + }) + + println ((body: AnyRef, "foo") match { + case (node: Node, "foo") => "bye" + case (ser: Serializable, "foo") => "hi" + }) +} diff --git a/test/files/run/t4138.check b/test/files/run/t4138.check new file mode 100644 index 0000000000..f561b5e6b0 --- /dev/null +++ b/test/files/run/t4138.check @@ -0,0 +1,2 @@ +[1.45] parsed: "lir 'de\' ' \\ \n / upa \"new\" \t parsing" +[1.5] parsed: "s " diff --git a/test/files/run/t4138.scala b/test/files/run/t4138.scala new file mode 100644 index 0000000000..131489e581 --- /dev/null +++ b/test/files/run/t4138.scala @@ -0,0 +1,6 @@ +object Test extends App { + object p extends scala.util.parsing.combinator.JavaTokenParsers + + println(p.parse(p.stringLiteral, """"lir 'de\' ' \\ \n / upa \"new\" \t parsing"""")) + println(p.parse(p.stringLiteral, """"s " lkjse"""")) +} diff --git a/test/files/run/t4172.check b/test/files/run/t4172.check index da467e27ea..4598e02d1f 100644 --- a/test/files/run/t4172.check +++ b/test/files/run/t4172.check @@ -4,6 +4,8 @@ Type :help for more information. scala> scala> val c = { class C { override def toString = "C" }; ((new C, new C { def f = 2 })) } +warning: there were 1 feature warnings; re-run with -feature for details +warning: there were 1 feature warnings; re-run with -feature for details c: (C, C{def f: Int}) forSome { type C <: Object } = (C,C) scala> diff --git a/test/files/run/t4190.check b/test/files/run/t4190.check new file mode 100644 index 0000000000..b8aae0c7a1 --- /dev/null +++ b/test/files/run/t4190.check @@ -0,0 +1,3 @@ +a0 +b0 +c0 diff --git a/test/files/run/t4190.scala b/test/files/run/t4190.scala new file mode 100644 index 0000000000..aa88b8708d --- /dev/null +++ b/test/files/run/t4190.scala @@ -0,0 +1,6 @@ +import collection.mutable._ + +object Test extends App { + val x: ArrayBuffer[String] = ArrayBuffer("a", "b", "c") + x.view map (_ + "0") foreach println +} diff --git a/test/files/run/t4216.check b/test/files/run/t4216.check new file mode 100644 index 0000000000..ac19a98315 --- /dev/null +++ b/test/files/run/t4216.check @@ -0,0 +1,34 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> def f[A: ArrayTag](a: A) = java.util.Arrays.asList(Array(a): _*) +f: [A](a: A)(implicit evidence$1: ArrayTag[A])java.util.List[A] + +scala> f(".") +res0: java.util.List[String] = [.] + +scala> f(0) +res1: java.util.List[Int] = [0] + +scala> def i(a: Int) = java.util.Arrays.asList(Array(a): _*) +i: (a: Int)java.util.List[Int] + +scala> i(0) +res2: java.util.List[Int] = [0] + +scala> def o(a: Any) = java.util.Arrays.asList(Array(a): _*) +o: (a: Any)java.util.List[Any] + +scala> o(".") +res3: java.util.List[Any] = [.] + +scala> class V(val a: Int) extends AnyVal +defined class V + +scala> f(new V(0)) +res4: java.util.List[V] = [V@0] + +scala> o(new V(0)) +res5: java.util.List[Any] = [V@0] + +scala> diff --git a/test/files/run/t4216.scala b/test/files/run/t4216.scala new file mode 100644 index 0000000000..4ada8f48aa --- /dev/null +++ b/test/files/run/t4216.scala @@ -0,0 +1,18 @@ +import scala.tools.partest.ReplTest + +// t4216 +object Test extends ReplTest { + def code = + """ + |def f[A: ArrayTag](a: A) = java.util.Arrays.asList(Array(a): _*) + |f(".") + |f(0) + |def i(a: Int) = java.util.Arrays.asList(Array(a): _*) + |i(0) + |def o(a: Any) = java.util.Arrays.asList(Array(a): _*) + |o(".") + |class V(val a: Int) extends AnyVal + |f(new V(0)) + |o(new V(0)) + |""".stripMargin.trim +} diff --git a/test/files/run/t4317/S_1.scala b/test/files/run/t4317/S_1.scala index 2de408268c..2756c879eb 100644 --- a/test/files/run/t4317/S_1.scala +++ b/test/files/run/t4317/S_1.scala @@ -1,3 +1,5 @@ +import language.existentials + object S_1 { def foo1(x: Class[_ <: AnyRef]) = 0 def foo2(x: Class[_ <: AnyRef], y: Int) = 99 diff --git a/test/files/run/t4415.scala b/test/files/run/t4415.scala new file mode 100644 index 0000000000..f96031d650 --- /dev/null +++ b/test/files/run/t4415.scala @@ -0,0 +1,86 @@ +/** + * Demonstration of issue with Extractors. If lines 15/16 are not present, get at runtime: + * + * Exception in thread "main" java.lang.VerifyError: (class: ExtractorIssue$$, method: convert signature: (LTopProperty;)LMyProp;) Accessing value from uninitialized register 5 + * at ExtractorIssue.main(ExtractorIssue.scala) + * at com.intellij.rt.execution.application.AppMain.main(AppMain.java:115)] + * + * If lines 15/16 are present, the compiler crashes: + * + * fatal error (server aborted): not enough arguments for method body%3: (val p: MyProp[java.lang.String])MyProp[_33]. + * Unspecified value parameter p. + */ +object Test { + + def main(args: Array[String]) { + convert(new SubclassProperty) + } + + def convert(prop: TopProperty): MyProp[_] = { + prop match { + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //case SubclassSecondMatch(p) => p // if these lines are present, the compiler crashes. If commented, unsafe byte + //case SecondMatch(p) => p // byte code is generated, which causes a java.lang.VerifyError at runtime + /////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + case SubclassMatch(p) => p + case StandardMatch(p) => p + } + } +} + +class TopProperty + +class StandardProperty extends TopProperty +class SubclassProperty extends StandardProperty + +class SecondProperty extends TopProperty +class SubclassSecondProperty extends StandardProperty + +trait MyProp[T] +case class MyPropImpl[T] extends MyProp[T] + +object SubclassMatch { + + def unapply(prop: SubclassProperty) : Option[MyProp[String]] = { + Some(new MyPropImpl) + } + + def apply(prop: MyProp[String]) : SubclassProperty = { + new SubclassProperty() + } +} + +object StandardMatch { + + def unapply(prop: StandardProperty) : Option[MyProp[String]] = { + Some(new MyPropImpl) + } + + def apply(prop: MyProp[String]) : StandardProperty = { + new StandardProperty() + } +} + +object SubclassSecondMatch { + + def unapply(prop: SubclassSecondProperty) : Option[MyProp[BigInt]] = { + Some(new MyPropImpl) + } + + def apply(prop: MyProp[String]) : SubclassSecondProperty = { + new SubclassSecondProperty() + } +} + +object SecondMatch { + + def unapply(prop: SecondProperty) : Option[MyProp[BigInt]] = { + Some(new MyPropImpl) + } + + def apply(prop: MyProp[String]) : SecondProperty = { + new SecondProperty() + } +}
\ No newline at end of file diff --git a/test/files/run/t4461.check b/test/files/run/t4461.check index b05c7b5589..e9c01e769d 100644 --- a/test/files/run/t4461.check +++ b/test/files/run/t4461.check @@ -4,4 +4,8 @@ Include(End,3) Include(End,4) Include(End,5) Include(End,6) -Include(End,7)
\ No newline at end of file +Include(End,7) +Script([1] Include(Index(7),8), [2] Include(Index(8),9), [3] Include(Index(9),10)) +Include(Start,0) +Script([1] Include(Index(0),-2), [2] Include(Index(1),-1)) +Remove(Index(0),-2)
\ No newline at end of file diff --git a/test/files/run/t4461.scala b/test/files/run/t4461.scala index 99da122f6b..adc9201313 100644 --- a/test/files/run/t4461.scala +++ b/test/files/run/t4461.scala @@ -15,5 +15,9 @@ object Test { buf ++= ArrayBuffer(3, 4) // works buf ++= List(5) // works buf ++= collection.immutable.Vector(6, 7) // works + buf.insertAll(7, List(8, 9, 10)) + 0 +=: buf + List(-2, -1) ++=: buf + buf remove 0 } } diff --git a/test/files/run/t4482.check b/test/files/run/t4482.check new file mode 100644 index 0000000000..0cfbf08886 --- /dev/null +++ b/test/files/run/t4482.check @@ -0,0 +1 @@ +2 diff --git a/test/files/run/t4482.scala b/test/files/run/t4482.scala new file mode 100644 index 0000000000..392861c22e --- /dev/null +++ b/test/files/run/t4482.scala @@ -0,0 +1,15 @@ +trait Foo { def i: Int } +trait Bar + +case class Spam(i: Int) extends Foo with Bar + +object Test { + def matchParent(p:Any) = p match { + case f:Foo if f.i == 1 => 1 + case _:Bar => 2 + case _:Foo => 3 + } + def main(args: Array[String]): Unit = { + println(matchParent(Spam(3))) + } +} diff --git a/test/files/run/t4536.check b/test/files/run/t4536.check new file mode 100644 index 0000000000..0c5a72ada7 --- /dev/null +++ b/test/files/run/t4536.check @@ -0,0 +1,8 @@ +cls: bar +obj: foo +obj: bar +cls: bar +obj: bar +trait: pili +trait: mili +trait: foo
\ No newline at end of file diff --git a/test/files/run/t4536.scala b/test/files/run/t4536.scala new file mode 100644 index 0000000000..acd91deb7f --- /dev/null +++ b/test/files/run/t4536.scala @@ -0,0 +1,46 @@ + + + + + + +object dynamicObject extends Dynamic { + def applyDynamic(m: String)() = println("obj: " + m); + this.foo() +} + + +class dynamicClass extends Dynamic { + def applyDynamic(m: String)() = println("cls: " + m); + this.bar() + dynamicObject.bar() +} + + +abstract class dynamicAbstractClass extends Dynamic { + def applyDynamic(m: String)(args: Any*): Unit + this.pili(1, new dynamicClass, "hello"); +} + + +trait dynamicTrait extends Dynamic { + def applyDynamic(m: String)(args: Any*) = println("trait: " + m); + def two = 2 + this.mili(1,2,3) + two +} + + +object dynamicMixin extends dynamicAbstractClass with dynamicTrait { + this.foo(None) +} + + +object Test { + + def main(args: Array[String]) { + val cls = new dynamicClass + dynamicMixin + } + +} diff --git a/test/files/run/t4710.check b/test/files/run/t4710.check index aa2f08d452..7c2b10b098 100644 --- a/test/files/run/t4710.check +++ b/test/files/run/t4710.check @@ -2,6 +2,7 @@ Type in expressions to have them evaluated. Type :help for more information. scala> def method : String = { implicit def f(s: Symbol) = "" ; 'symbol } +warning: there were 1 feature warnings; re-run with -feature for details method: String scala> diff --git a/test/files/run/t4929.check b/test/files/run/t4929.check new file mode 100644 index 0000000000..0f0c913d55 --- /dev/null +++ b/test/files/run/t4929.check @@ -0,0 +1 @@ +success
\ No newline at end of file diff --git a/test/files/run/t4929.scala b/test/files/run/t4929.scala new file mode 100644 index 0000000000..3208cd1b09 --- /dev/null +++ b/test/files/run/t4929.scala @@ -0,0 +1,42 @@ +import scala.util.parsing.json._ +import java.util.concurrent._ +import collection.JavaConversions._ + +object Test extends App { + + val LIMIT = 2000 + val THREAD_COUNT = 20 + val count = new java.util.concurrent.atomic.AtomicInteger(0) + + val begin = new CountDownLatch(THREAD_COUNT) + val finish = new CountDownLatch(THREAD_COUNT) + + val errors = new ConcurrentLinkedQueue[Throwable] + + (1 to THREAD_COUNT) foreach { i => + val thread = new Thread { + override def run() { + begin.await(1, TimeUnit.SECONDS) + try { + while (count.getAndIncrement() < LIMIT && errors.isEmpty) { + JSON.parseFull("""{"foo": [1,2,3,4]}""") + } + } catch { + case t: Throwable => errors.add(t) + } + + finish.await(10, TimeUnit.SECONDS) + } + } + + thread.setDaemon(true) + thread.start() + + } + + + errors foreach { throw(_) } + + println("success") + +} diff --git a/test/files/run/t5009.check b/test/files/run/t5009.check new file mode 100644 index 0000000000..cc9df54b34 --- /dev/null +++ b/test/files/run/t5009.check @@ -0,0 +1,4 @@ +C(1,true) +10 +C(7283,20) +100 diff --git a/test/files/run/t5009.scala b/test/files/run/t5009.scala new file mode 100644 index 0000000000..b4fe1bc894 --- /dev/null +++ b/test/files/run/t5009.scala @@ -0,0 +1,17 @@ +object Test extends App { + + case class C[T, U <: String, O >: Object](x: Int, y: T)(z: U, b: Boolean)(s: O, val l: Int) + + val c = C(1, true)("dlkfj", true)("dlkfjlk", 10) + println(c) + println(c.l) + + val f1a = c.copy(y = 20, x = 7283) + + val f1b = c.copy[Int, String, Object](y = 20, x = 7283) + val f2b = f1b("lkdjen", false) + val res = f2b(new Object, 100) + println(res) + println(res.l) + +} diff --git a/test/files/run/t5018.scala b/test/files/run/t5018.scala new file mode 100644 index 0000000000..bb67a252e5 --- /dev/null +++ b/test/files/run/t5018.scala @@ -0,0 +1,37 @@ + + + +import java.io._ +import collection._ + + + +object Test { + + def serializeDeserialize[T <: AnyRef](obj: T) = { + val buffer = new ByteArrayOutputStream + val out = new ObjectOutputStream(buffer) + out.writeObject(obj) + val in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray)) + in.readObject.asInstanceOf[T] + } + + def main(args: Array[String]) { + val values = mutable.Map(1 -> 1).values + assert(serializeDeserialize(values).toList == values.toList) + + val keyset = mutable.Map(1 -> 1).keySet + assert(serializeDeserialize(keyset) == keyset) + + val imkeyset = immutable.Map(1 -> 1).keySet + assert(serializeDeserialize(imkeyset) == imkeyset) + + val defaultmap = immutable.Map(1 -> 1).withDefaultValue(1) + assert(serializeDeserialize(defaultmap) == defaultmap) + + val minusmap = mutable.Map(1 -> 1).withDefault(x => -x) + assert(serializeDeserialize(minusmap) == minusmap) + } + +} + diff --git a/test/files/run/t5037.check b/test/files/run/t5037.check new file mode 100644 index 0000000000..da29283aaa --- /dev/null +++ b/test/files/run/t5037.check @@ -0,0 +1,2 @@ +true +false diff --git a/test/files/run/t5037.scala b/test/files/run/t5037.scala new file mode 100644 index 0000000000..7b1fce7a82 --- /dev/null +++ b/test/files/run/t5037.scala @@ -0,0 +1,18 @@ +object Test { + def main(args: Array[String]) { + val t = new Test + t.inner.foo() + } +} + +class Test { + class Inner { + def foo() { + println(bar) + bar = false + println(bar) + } + } + val inner = new Inner + private[this] final var bar = true +} diff --git a/test/files/run/t5040.check b/test/files/run/t5040.check new file mode 100644 index 0000000000..3f7b5908a9 --- /dev/null +++ b/test/files/run/t5040.check @@ -0,0 +1 @@ +applyDynamic diff --git a/test/files/run/t5040.scala b/test/files/run/t5040.scala new file mode 100644 index 0000000000..6cd2c22234 --- /dev/null +++ b/test/files/run/t5040.scala @@ -0,0 +1,11 @@ +abstract class Prova2 extends Dynamic { + def applyDynamic(m: String)(): Unit + private def privateMethod() = println("private method") +} + +object Test extends App { + val prova= new Prova2 { + def applyDynamic(m: String)() = println("applyDynamic") + } + prova.privateMethod() +} diff --git a/test/files/run/t5125.check b/test/files/run/t5125.check new file mode 100644 index 0000000000..d8a0565005 --- /dev/null +++ b/test/files/run/t5125.check @@ -0,0 +1,4 @@ +public void O1$.f(java.lang.String[]) +public void O1$.f(scala.collection.Seq) +public void O2$.f(java.lang.String[]) +public void O2$.f(scala.collection.Seq) diff --git a/test/files/run/t5125.scala b/test/files/run/t5125.scala new file mode 100644 index 0000000000..7ec2b929d9 --- /dev/null +++ b/test/files/run/t5125.scala @@ -0,0 +1,24 @@ +object O1 { + def instance = this + @scala.annotation.varargs + def f(values:String*) = println("Calling O1.f(): " + values) +} + +object O2 { + def instance = this + @scala.annotation.varargs + def f(values:String*) = println("Calling O2.f(): " + values) + // uncommenting g() results in errors in A.java + def g(): String => Int = s => s.hashCode +} + +object Test extends App { + def check(c: Class[_]) { + val methodName = "f" + val methods = c.getDeclaredMethods.filter(_.getName == methodName) + println(methods.map(_.toString).sorted.mkString("\n")) + } + + check(O1.getClass) + check(O2.getClass) +}
\ No newline at end of file diff --git a/test/files/run/t5125b.check b/test/files/run/t5125b.check new file mode 100644 index 0000000000..ddbf908f04 --- /dev/null +++ b/test/files/run/t5125b.check @@ -0,0 +1,7 @@ +public void C1.f(java.lang.String[]) +public void C1.f(scala.collection.Seq) +public void C2.f(java.lang.String[]) +public void C2.f(scala.collection.Seq) +public void C2$C3.f(java.lang.String[]) +public void C2$C3.f(scala.collection.Seq) +public void C4.f(scala.collection.Seq) diff --git a/test/files/run/t5125b.scala b/test/files/run/t5125b.scala new file mode 100644 index 0000000000..29c08fee4c --- /dev/null +++ b/test/files/run/t5125b.scala @@ -0,0 +1,37 @@ +class C1 { + @scala.annotation.varargs + def f(values:String*) = println("Calling C1.f(): " + values) +} + +class C2 { + @scala.annotation.varargs + def f(values:String*) = println("Calling C2.f(): " + values) + def g(): String => Int = s => s.hashCode + + class C3 { + @scala.annotation.varargs + def f(values:String*) = println("Calling C3.f(): " + values) + } +} + +class C4 { + def f(values: String*) = println("Calling C4.f(): " + values) + + locally { + @scala.annotation.varargs + def f(values: String*) = println("Calling C4.<locally>.f(): " + values) + } +} + +object Test extends App { + def check(c: Class[_]) { + val methodName = "f" + val methods = c.getDeclaredMethods.filter(_.getName == methodName) + println(methods.map(_.toString).sorted.mkString("\n")) + } + + check(classOf[C1]) + check(classOf[C2]) + check(classOf[C2#C3]) + check(classOf[C4]) +} diff --git a/test/files/run/t5201.check b/test/files/run/t5201.check new file mode 100644 index 0000000000..27ba77ddaf --- /dev/null +++ b/test/files/run/t5201.check @@ -0,0 +1 @@ +true diff --git a/test/files/run/t5201.scala b/test/files/run/t5201.scala new file mode 100644 index 0000000000..48aa7ba54c --- /dev/null +++ b/test/files/run/t5201.scala @@ -0,0 +1,8 @@ +object Test extends App { + // First make sure specific types are preserved + val tmp: Vector[Int] = Vector(Vector(1,2), Vector(3,4)).view.flatten.force + + // Now make sure we really get a view + val seq = Seq(Seq(1, 2), Seq(3, 4)).view.flatten + Console.println(seq.isInstanceOf[collection.SeqView[_,_]]) +} diff --git a/test/files/run/t5224.scala b/test/files/run/t5224.scala index 93b244e03e..cf65f16457 100644 --- a/test/files/run/t5224.scala +++ b/test/files/run/t5224.scala @@ -1,6 +1,6 @@ import scala.reflect.mirror._ -class Foo(bar: String) extends ClassfileAnnotation +class Foo(bar: String) extends annotation.ClassfileAnnotation object Test extends App { val tree = reify{@Foo(bar = "qwe") class C}.tree diff --git a/test/files/run/t5258a.check b/test/files/run/t5258a.check new file mode 100644 index 0000000000..4e0b2da04c --- /dev/null +++ b/test/files/run/t5258a.check @@ -0,0 +1 @@ +int
\ No newline at end of file diff --git a/test/files/run/t5258a.scala b/test/files/run/t5258a.scala new file mode 100644 index 0000000000..127829c724 --- /dev/null +++ b/test/files/run/t5258a.scala @@ -0,0 +1,7 @@ +import scala.reflect.mirror._ + +object Test extends App { + reify { + println(classOf[Int]) + }.eval +}
\ No newline at end of file diff --git a/test/files/run/t5271_1.check b/test/files/run/t5271_1.check index 7a728e5164..5245173228 100644 --- a/test/files/run/t5271_1.check +++ b/test/files/run/t5271_1.check @@ -9,3 +9,4 @@ };
()
}
+()
diff --git a/test/files/run/t5271_1.scala b/test/files/run/t5271_1.scala index 5baa57c290..20cafa6a08 100644 --- a/test/files/run/t5271_1.scala +++ b/test/files/run/t5271_1.scala @@ -7,4 +7,5 @@ object Test extends App { val toolbox = mkToolBox() println(code.tree) + println(code.eval) } diff --git a/test/files/run/t5271_2.check b/test/files/run/t5271_2.check index d8d6edeffc..0765b3a6a4 100644 --- a/test/files/run/t5271_2.check +++ b/test/files/run/t5271_2.check @@ -10,3 +10,5 @@ val c = C.apply(2, 2);
scala.this.Predef.println(c.foo.$times(c.bar))
}
+4
+()
diff --git a/test/files/run/t5271_2.scala b/test/files/run/t5271_2.scala index 9820ebe692..af6491407c 100644 --- a/test/files/run/t5271_2.scala +++ b/test/files/run/t5271_2.scala @@ -9,4 +9,5 @@ object Test extends App { val toolbox = mkToolBox() println(code.tree) + println(code.eval) } diff --git a/test/files/run/t5271_3.check b/test/files/run/t5271_3.check index 1d4f47c5df..2b920a36a8 100644 --- a/test/files/run/t5271_3.check +++ b/test/files/run/t5271_3.check @@ -17,3 +17,5 @@ val c = C.apply(2, 2);
scala.this.Predef.println(c.foo.$times(c.bar).$eq$eq(C.qwe))
}
+true
+()
diff --git a/test/files/run/t5271_3.scala b/test/files/run/t5271_3.scala index 5fd94f4a2b..646b10a8e5 100644 --- a/test/files/run/t5271_3.scala +++ b/test/files/run/t5271_3.scala @@ -10,4 +10,5 @@ object Test extends App { val toolbox = mkToolBox() println(code.tree) + println(code.eval) } diff --git a/test/files/run/t5272_1.flags b/test/files/run/t5272_1.flags new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/run/t5272_1.flags diff --git a/test/files/run/t5272_2.flags b/test/files/run/t5272_2.flags new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/run/t5272_2.flags diff --git a/test/files/run/t5273_1.flags b/test/files/run/t5273_1.flags new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/run/t5273_1.flags diff --git a/test/files/run/t5273_2a.flags b/test/files/run/t5273_2a.flags new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/run/t5273_2a.flags diff --git a/test/files/run/t5273_2b.flags b/test/files/run/t5273_2b.flags new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/run/t5273_2b.flags diff --git a/test/files/run/t5328.check b/test/files/run/t5328.check new file mode 100644 index 0000000000..77a43968c5 --- /dev/null +++ b/test/files/run/t5328.check @@ -0,0 +1,3 @@ +2 +1,2,8 +1,8,3 diff --git a/test/files/run/t5328.scala b/test/files/run/t5328.scala new file mode 100644 index 0000000000..12adf45b84 --- /dev/null +++ b/test/files/run/t5328.scala @@ -0,0 +1,5 @@ +object Test extends App { + println(Vector(1).view.updated(0,2).toList mkString ",") + println(Seq(1,2,3).view.updated(2,8).toList mkString ",") + println(List(1,2,3).view.updated(1,8).toList mkString ",") +} diff --git a/test/files/run/t5394.scala b/test/files/run/t5394.scala new file mode 100644 index 0000000000..1b39da3ac4 --- /dev/null +++ b/test/files/run/t5394.scala @@ -0,0 +1,4 @@ +object Test extends App { + def f[T](l: List[T]): Int = l match { case x :: xs => f(xs) case Nil => 0 } + f(List.fill(10000)(0)) +}
\ No newline at end of file diff --git a/test/files/run/t5407.check b/test/files/run/t5407.check new file mode 100644 index 0000000000..51993f072d --- /dev/null +++ b/test/files/run/t5407.check @@ -0,0 +1,2 @@ +2 +2 diff --git a/test/files/run/t5407.scala b/test/files/run/t5407.scala new file mode 100644 index 0000000000..35a8ec6a45 --- /dev/null +++ b/test/files/run/t5407.scala @@ -0,0 +1,17 @@ +case class Foo(private val x: Int, y: Option[Int], z: Boolean) + +object Test extends App { + def foo(x: Foo) = x match { + case Foo(x, Some(y), z) => y + case Foo(x, y, z) => 0 + } + val x = Foo(1, Some(2), false) + println(foo(x)) + + + def bar(x: Foo) = x match { + case Foo(x, Some(y), z) => y + case Foo(x, None, z) => 0 + } + println(bar(x)) +}
\ No newline at end of file diff --git a/test/files/run/t5419.scala b/test/files/run/t5419.scala index d65d8f38c8..5f11f5056c 100644 --- a/test/files/run/t5419.scala +++ b/test/files/run/t5419.scala @@ -1,6 +1,6 @@ import scala.reflect.mirror._ -class Foo extends StaticAnnotation +class Foo extends annotation.StaticAnnotation object Test extends App { val tree = reify{(5: @Foo).asInstanceOf[Int]}.tree diff --git a/test/files/run/t5423.scala b/test/files/run/t5423.scala index 645c8c7c1d..ed1faf0429 100644 --- a/test/files/run/t5423.scala +++ b/test/files/run/t5423.scala @@ -1,6 +1,6 @@ import scala.reflect.mirror._ -final class table extends StaticAnnotation +final class table extends annotation.StaticAnnotation @table class A object Test extends App { diff --git a/test/files/run/t5428.check b/test/files/run/t5428.check new file mode 100644 index 0000000000..7b4b1d6558 --- /dev/null +++ b/test/files/run/t5428.check @@ -0,0 +1 @@ +Stack(8, 7, 6, 5, 4, 3)
\ No newline at end of file diff --git a/test/files/run/t5428.scala b/test/files/run/t5428.scala new file mode 100644 index 0000000000..106bb7fc31 --- /dev/null +++ b/test/files/run/t5428.scala @@ -0,0 +1,29 @@ + + + +import collection.mutable.{Stack, StackProxy} + + + +class A extends StackProxy[Int] { + val self = Stack[Int]() +} + + +object Test { + + def main(args: Array[String]) { + val a = new A + + a push 3 + a push 4 + a push 5 + + a.push(6, 7, 8) + + println(a) + + a pop + } + +} diff --git a/test/files/run/t5514.check b/test/files/run/t5514.check new file mode 100644 index 0000000000..c68f7c9029 --- /dev/null +++ b/test/files/run/t5514.check @@ -0,0 +1,19 @@ +constructed reader: 10 +constructed reader: 9 +constructed reader: 8 +constructed reader: 7 +constructed reader: 6 +constructed reader: 5 +constructed reader: 4 +constructed reader: 3 +constructed reader: 2 +constructed reader: 1 +constructed reader: 0 +[0.0] parsed: List(s10, s9, s8, s7, s6, s5, s4, s3, s2, s1) +constructed reader: 10 +constructed reader: 9 +constructed reader: 8 +constructed reader: 7 +constructed reader: 6 +constructed reader: 5 +[0.0] parsed: List(s10, s9, s8, s7, s6)
\ No newline at end of file diff --git a/test/files/run/t5514.scala b/test/files/run/t5514.scala new file mode 100644 index 0000000000..efd5ba6cb9 --- /dev/null +++ b/test/files/run/t5514.scala @@ -0,0 +1,35 @@ + + + +import scala.io.Source +import scala.util.parsing.combinator.Parsers +import scala.util.parsing.input.Reader +import scala.util.parsing.input.Position + + + +class DemoReader(n: Int) extends Reader[String] { + def atEnd = n == 0 + def first = if (n >= 0) "s" + n else throw new IllegalArgumentException("No more input.") + def rest = new DemoReader(n - 1) + def pos = new Position { + def line = 0 + def column = 0 + def lineContents = first + } + println("constructed reader: " + n) +} + + +object Test extends App with Parsers { + type Elem = String + def startsWith(prefix: String) = acceptIf(_ startsWith prefix)("Error: " + _) + + val resrep = startsWith("s").*(new DemoReader(10)) + Console println resrep + + val resrep5 = repN(5, startsWith("s"))(new DemoReader(10)) + Console println resrep5 +} + + diff --git a/test/files/run/t5527.check b/test/files/run/t5527.check index bb13928fd8..1518168c51 100644 --- a/test/files/run/t5527.check +++ b/test/files/run/t5527.check @@ -1,4 +1,4 @@ -[[syntax trees at end of parser]]// Scala source: newSource1 +[[syntax trees at end of parser]] // newSource1 package <empty> { object UselessComments extends scala.AnyRef { def <init>() = { diff --git a/test/files/run/t5543.check b/test/files/run/t5543.check new file mode 100644 index 0000000000..517038f4c7 --- /dev/null +++ b/test/files/run/t5543.check @@ -0,0 +1,3 @@ +Test, 7, 119 +m, 3, 19 +Test, 5, 85 diff --git a/test/files/run/t5543.scala b/test/files/run/t5543.scala new file mode 100644 index 0000000000..651bc7f2b2 --- /dev/null +++ b/test/files/run/t5543.scala @@ -0,0 +1,26 @@ + +object Test extends Function0[Int] { + // this and v resolve to Test.this, Test.v not A.this, A.v + class A(x: Function0[Int] = this)(val a: Int = v, val b: Int = v * x()) extends Function0[Int] { + val v = 3 + override def toString = x.toString +", "+ a +", "+ b + // ordinary instance scope + def m(i: Int = v, y: Function0[Int] = this) = "m, "+ i +", "+ y() + def apply() = 19 + } + object A { + val v = 5 + // should happily coexist with default getters, in a happier world + def init(x: Function0[Int] = Test.this)(a: Int = v, b: Int = v * x()) = x.toString +", "+ a +", "+ b + override def toString = "A" + } + val v = 7 + def apply() = 17 + override def toString = "Test" + def main(args: Array[String]) { + val sut = new A()() + println(sut.toString) + println(sut.m()) + println(A.init()()) + } +} diff --git a/test/files/run/t5544.check b/test/files/run/t5544.check new file mode 100644 index 0000000000..257cc5642c --- /dev/null +++ b/test/files/run/t5544.check @@ -0,0 +1 @@ +foo diff --git a/test/files/run/t5544/Api_1.scala b/test/files/run/t5544/Api_1.scala new file mode 100644 index 0000000000..b4c92864de --- /dev/null +++ b/test/files/run/t5544/Api_1.scala @@ -0,0 +1,8 @@ +import scala.annotation.StaticAnnotation + +class ann(val bar: Any) extends StaticAnnotation + +object Api { + @ann({def foo = "foo!!"}) + def foo = println("foo") +} diff --git a/test/files/run/t5544/Test_2.scala b/test/files/run/t5544/Test_2.scala new file mode 100644 index 0000000000..285f8959e0 --- /dev/null +++ b/test/files/run/t5544/Test_2.scala @@ -0,0 +1,3 @@ +object Test extends App { + Api.foo +} diff --git a/test/files/run/t5552.check b/test/files/run/t5552.check new file mode 100644 index 0000000000..a19a60840e --- /dev/null +++ b/test/files/run/t5552.check @@ -0,0 +1,2 @@ +(3,3) +(3.0,3.0) diff --git a/test/files/run/t5552.scala b/test/files/run/t5552.scala new file mode 100644 index 0000000000..afb8a1f0be --- /dev/null +++ b/test/files/run/t5552.scala @@ -0,0 +1,10 @@ +class C[@specialized(Int) A](a:A) { + lazy val b = (a, a) + def c = b +} +object Test { + def main(args:Array[String]) { + println(new C(3).c) + println(new C(3.0).c) + } +} diff --git a/test/files/run/t5577.check b/test/files/run/t5577.check new file mode 100644 index 0000000000..3eca387955 --- /dev/null +++ b/test/files/run/t5577.check @@ -0,0 +1,11 @@ +Received a size hint: 10 +0 +1 +2 +3 +4 +5 +6 +7 +8 +9
\ No newline at end of file diff --git a/test/files/run/t5577.scala b/test/files/run/t5577.scala new file mode 100644 index 0000000000..b5d6d8c5b6 --- /dev/null +++ b/test/files/run/t5577.scala @@ -0,0 +1,27 @@ + + + +import collection._ + + + +object Test { + + class AlarmingBuffer[T] extends mutable.ArrayBuffer[T] { + override def sizeHint(x: Int) { + println("Received a size hint: " + x) + super.sizeHint(x) + } + } + + def main(args: Array[String]) { + val iteratorBuilder = (new AlarmingBuffer[Int]) mapResult { + res => res.iterator + } + + iteratorBuilder.sizeHint(10) + iteratorBuilder ++= (0 until 10) + iteratorBuilder.result.foreach(println) + } + +} diff --git a/test/files/run/t5590.check b/test/files/run/t5590.check new file mode 100644 index 0000000000..ad4a2eee64 --- /dev/null +++ b/test/files/run/t5590.check @@ -0,0 +1,4 @@ +Map(a -> a, b -> b, c -> c) +Map(a -> a, b -> b, c -> c) +Set(a, b, c, d, e) +Set(a, b, c, d, e)
\ No newline at end of file diff --git a/test/files/run/t5590.scala b/test/files/run/t5590.scala new file mode 100644 index 0000000000..9c806e0b7d --- /dev/null +++ b/test/files/run/t5590.scala @@ -0,0 +1,31 @@ + + + +import java.io._ +import collection._ + + + +object Test { + + def check(obj: AnyRef) { + println(obj) + + val bos = new ByteArrayOutputStream() + val out = new ObjectOutputStream(bos) + out.writeObject(obj) + val arr = bos.toByteArray() + val in = new ObjectInputStream(new ByteArrayInputStream(arr)) + val deser = in.readObject() + + println(deser) + } + + def main(args: Array[String]) { + val lhm = mutable.LinkedHashMap("a" -> "a", "b" -> "b", "c" -> "c") + val lhs = mutable.LinkedHashSet("a", "b", "c", "d", "e") + check(lhm) + check(lhs) + } + +} diff --git a/test/files/run/t5608.check b/test/files/run/t5608.check new file mode 100644 index 0000000000..ba70d21701 --- /dev/null +++ b/test/files/run/t5608.check @@ -0,0 +1 @@ +A@6 diff --git a/test/files/run/t5608.scala b/test/files/run/t5608.scala new file mode 100644 index 0000000000..19b3681932 --- /dev/null +++ b/test/files/run/t5608.scala @@ -0,0 +1,12 @@ +object Test { + def main(args:Array[String]) { + val ns = Array(3L, 3L, 3L) + val a1: A = new A(ns(0)) + val a2: A = new A(ns(0)) + println(a1 + a2) + } +} + +class A(val u: Long) extends AnyVal { + def +(other: A) = new A(other.u + u) +} diff --git a/test/files/run/t5610.check b/test/files/run/t5610.check new file mode 100644 index 0000000000..023f18d8f1 --- /dev/null +++ b/test/files/run/t5610.check @@ -0,0 +1,6 @@ +some string +some string +some string +some string +List(2, 3) +List(5, 6) diff --git a/test/files/run/t5610.scala b/test/files/run/t5610.scala new file mode 100644 index 0000000000..f62b2df6b4 --- /dev/null +++ b/test/files/run/t5610.scala @@ -0,0 +1,30 @@ +object Test { + def main(args: Array[String]): Unit = { + var test: String = null + val fun1: Int => () => Unit = foo(test) _ + val fun2: Int => () => Unit = foo(test)(_) + val fun3: Int => () => Unit = { + lazy val eta1: String = test + (dummy: Int) => foo(eta1)(dummy) + } + val fun4: Int => () => Unit = { + val eta1: () => String = () => test + (dummy: Int) => foo(eta1())(dummy) + } + test = "some string" + fun1(1)() + fun2(1)() + fun3(1)() + fun4(1)() + + val f: (String, Int*) => Unit = m(2, 3) + f("", 5, 6) + } + + def foo(s: => String)(dummy: Int) = () => println(s) + + def m(a: Int*)(z: String, b: Int*) { + println(a.toList) + println(b.toList) + } +} diff --git a/test/files/run/t5612.check b/test/files/run/t5612.check new file mode 100644 index 0000000000..9d19cca292 --- /dev/null +++ b/test/files/run/t5612.check @@ -0,0 +1,4 @@ +START for List(Two, Two, One, Three) +TWO +TWO +ONE diff --git a/test/files/run/t5612.scala b/test/files/run/t5612.scala new file mode 100644 index 0000000000..48b3093548 --- /dev/null +++ b/test/files/run/t5612.scala @@ -0,0 +1,28 @@ +object L extends Enumeration { + val One, Two, Three = Value +} + +class Foo { + def foo(xs: List[L.Value]) { + import scala.util.control.Breaks.{break, breakable} + println("START for " + xs) + breakable { + for (x <- xs) { + x match { + case L.One => println("ONE"); return + case L.Two => println("TWO") + case L.Three => println("THREE"); break + } + } + } + println("FINISH") + } +} + +object Test { + def main(args: Array[String]) { + val f = new Foo() + val l = List(L.Two, L.Two, L.One, L.Three) + f.foo(l) + } +} diff --git a/test/files/run/t5629.check b/test/files/run/t5629.check new file mode 100644 index 0000000000..6a2d630f4e --- /dev/null +++ b/test/files/run/t5629.check @@ -0,0 +1,2 @@ +int child got: 33 +any child got: 33 diff --git a/test/files/run/t5629.scala b/test/files/run/t5629.scala new file mode 100644 index 0000000000..69feddd3a5 --- /dev/null +++ b/test/files/run/t5629.scala @@ -0,0 +1,36 @@ + + + +import scala.{specialized => spec} + + + +trait GrandParent[@spec(Int) -A] { + def foo(a: A): Unit + def bar[B <: A](b: B): Unit = println("grandparent got: %s" format b) +} + + +trait Parent[@spec(Int) -A] extends GrandParent[A] { + def foo(a: A) = bar(a) +} + + +class IntChild extends Parent[Int] { + override def bar[B <: Int](b: B): Unit = println("int child got: %s" format b) +} + + +class AnyChild extends Parent[Any] { + override def bar[B <: Any](b: B): Unit = println("any child got: %s" format b) +} + + +object Test { + + def main(args: Array[String]) { + new IntChild().foo(33) + new AnyChild().foo(33) + } + +} diff --git a/test/files/run/t5629b.check b/test/files/run/t5629b.check new file mode 100644 index 0000000000..1bc0248c3d --- /dev/null +++ b/test/files/run/t5629b.check @@ -0,0 +1,10 @@ +=== pf(1): +MySmartPF.apply entered... +newPF.applyOrElse entered... +default +scala.MatchError: () (of class scala.runtime.BoxedUnit) +=== pf(42): +MySmartPF.apply entered... +newPF.applyOrElse entered... +ok +=== done diff --git a/test/files/run/t5629b.scala b/test/files/run/t5629b.scala new file mode 100644 index 0000000000..6c908081b9 --- /dev/null +++ b/test/files/run/t5629b.scala @@ -0,0 +1,41 @@ + + + + + +object Test extends App { + + trait MyPF[@specialized(Int) -A] extends (A => Unit) { + def isDefinedAt(x: A): Boolean + def applyOrElse[A1 <: A](x: A1, default: A1 => Unit): Unit = { + println("MyPF.applyOrElse entered...") + if (isDefinedAt(x)) apply(x) else default(x) + } + } + + trait MySmartPF[@specialized(Int) -A] extends MyPF[A] { + def apply(x: A): Unit = { + println("MySmartPF.apply entered...") + applyOrElse(x, { _: Any => throw new MatchError }) + } + } + + type T = Int + //type T = Any + + def newPF(test: T): MyPF[T] = new MySmartPF[T] { + def isDefinedAt(x: T): Boolean = x != test + override def applyOrElse[A1 <: T](x: A1, default: A1 => Unit): Unit = { + println("newPF.applyOrElse entered...") + if (x != test) { println("ok"); () } else { println("default"); default(x) } + } + } + + val pf = newPF(1) + println("=== pf(1):") + try { pf(1) } catch { case x => println(x) } + println("=== pf(42):") + pf(42) + println("=== done") + +} diff --git a/test/files/run/t5655.check b/test/files/run/t5655.check new file mode 100644 index 0000000000..43ebd50e7a --- /dev/null +++ b/test/files/run/t5655.check @@ -0,0 +1,30 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> + +scala> object x { def x={} } +defined module x + +scala> import x._ +import x._ + +scala> x +<console>:12: error: reference to x is ambiguous; +it is imported twice in the same scope by +import x._ +and import x + x + ^ + +scala> x +<console>:12: error: reference to x is ambiguous; +it is imported twice in the same scope by +import x._ +and import x + x + ^ + +scala> + +scala> diff --git a/test/files/run/t5655.scala b/test/files/run/t5655.scala new file mode 100644 index 0000000000..b15feb788e --- /dev/null +++ b/test/files/run/t5655.scala @@ -0,0 +1,10 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + def code = """ +object x { def x={} } +import x._ +x +x + """ +} diff --git a/test/files/run/t5656.check b/test/files/run/t5656.check new file mode 100644 index 0000000000..9543ee799e --- /dev/null +++ b/test/files/run/t5656.check @@ -0,0 +1 @@ +List(1, 2, 3)_List(a, b, c)
\ No newline at end of file diff --git a/test/files/run/t5656.scala b/test/files/run/t5656.scala new file mode 100644 index 0000000000..f5ea147a4e --- /dev/null +++ b/test/files/run/t5656.scala @@ -0,0 +1,11 @@ + + + + +object Test { + + def main(args: Array[String]) { + println(Seq(List('1', '2', '3'), List('a', 'b', 'c')).view.addString(new StringBuilder, "_")) + } + +} diff --git a/test/files/run/t5676.check b/test/files/run/t5676.check new file mode 100644 index 0000000000..3b562d3046 --- /dev/null +++ b/test/files/run/t5676.check @@ -0,0 +1,3 @@ +ok +false +true diff --git a/test/files/pos/annotDepMethType.flags b/test/files/run/t5676.flags index e1b37447c9..e1b37447c9 100644 --- a/test/files/pos/annotDepMethType.flags +++ b/test/files/run/t5676.flags diff --git a/test/files/run/t5676.scala b/test/files/run/t5676.scala new file mode 100644 index 0000000000..b643c300ce --- /dev/null +++ b/test/files/run/t5676.scala @@ -0,0 +1,24 @@ +import java.lang.reflect.Modifier + +class Bar[T] + +class Foo[T] { + object A extends Bar[T] +} + +class Baz[S] extends Foo[S] { + override object A extends Bar[S] { + def foo(): String = "ok" + } +} + +object Test { + + def main(a: Array[String]) { + val b = new Baz[Any] + println(b.A.foo()) + println(Modifier.isFinal(classOf[Baz[Any]].getModifiers())) + println(Modifier.isFinal(Test.getClass.getModifiers())) + } + +} diff --git a/test/files/run/t5680.check b/test/files/run/t5680.check new file mode 100644 index 0000000000..9fec3b6505 --- /dev/null +++ b/test/files/run/t5680.check @@ -0,0 +1,3 @@ +[Lscala.runtime.BoxedUnit
+()
+()
diff --git a/test/files/run/t5680.scala b/test/files/run/t5680.scala new file mode 100644 index 0000000000..f61cbd6e20 --- /dev/null +++ b/test/files/run/t5680.scala @@ -0,0 +1,7 @@ +object Test extends App { + val x = Array[Unit]((), ()) + println(x.toString.substring(0, x.toString.indexOf(";"))) + println(x(0)) + x(1) = () + println(x(1)) +}
\ No newline at end of file diff --git a/test/files/run/t5688.check b/test/files/run/t5688.check new file mode 100644 index 0000000000..2c84f9e2ef --- /dev/null +++ b/test/files/run/t5688.check @@ -0,0 +1 @@ +Vector(ta, tb, tab) diff --git a/test/files/run/t5688.scala b/test/files/run/t5688.scala new file mode 100644 index 0000000000..f99bfb47d3 --- /dev/null +++ b/test/files/run/t5688.scala @@ -0,0 +1,23 @@ +object Test extends App { + trait T + + trait TA + trait TB + + class A extends T with TA + class B extends T with TB + class AB extends T with TA with TB + // Matching on _: TA with TB + + val li: Vector[T] = Vector(new A, new B, new AB) + + val matched = (for (l <- li) yield { + l match { + case _: TA with TB => "tab" + case _: TA => "ta" + case _: TB => "tb" + } + }) + + println(matched) +}
\ No newline at end of file diff --git a/test/files/run/t5704.check b/test/files/run/t5704.check new file mode 100644 index 0000000000..7b56bf2bfd --- /dev/null +++ b/test/files/run/t5704.check @@ -0,0 +1 @@ +String
\ No newline at end of file diff --git a/test/files/run/t5704.flags b/test/files/run/t5704.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/files/run/t5704.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/t5704.scala b/test/files/run/t5704.scala new file mode 100644 index 0000000000..8fd721d4e7 --- /dev/null +++ b/test/files/run/t5704.scala @@ -0,0 +1,16 @@ +import scala.reflect.mirror._ + +object Test extends App { + class MyQuerycollection{ + def findUserByName( name:String ) = { + val tree = reify{ "test" == name }.tree + val toolbox = mkToolBox() + toolbox.typeCheck(tree) match{ + case Apply(Select(lhs,op),rhs::Nil) => + println(rhs.tpe) + } + } + } + val qc = new MyQuerycollection + qc.findUserByName("some value") +} diff --git a/test/files/run/t5713.check b/test/files/run/t5713.check new file mode 100644 index 0000000000..d3e9348123 --- /dev/null +++ b/test/files/run/t5713.check @@ -0,0 +1 @@ +err
diff --git a/test/files/run/t5713.flags b/test/files/run/t5713.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/files/run/t5713.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/t5713/Impls_Macros_1.scala b/test/files/run/t5713/Impls_Macros_1.scala new file mode 100644 index 0000000000..b499bc7e4e --- /dev/null +++ b/test/files/run/t5713/Impls_Macros_1.scala @@ -0,0 +1,27 @@ +package m + +import language.experimental.macros +import scala.reflect.makro.Context + +object Level extends Enumeration { + val Error = Value(5) +} + +object Logger { + def error(message: String): Unit = macro LoggerMacros.error +} + +private object LoggerMacros { + + type LoggerContext = Context { type PrefixType = Logger.type } + + def error(c: LoggerContext)(message: c.Expr[String]): c.Expr[Unit] = + log(c)(c.reify(Level.Error), message) + + private def log(c: LoggerContext)(level: c.Expr[Level.Value], message: c.Expr[String]): c.Expr[Unit] = + if (level.eval.id < 4) // TODO Remove hack! + c.reify(()) + else { + c.reify(println(message.eval)) + } +}
\ No newline at end of file diff --git a/test/files/run/t5713/Test_2.scala b/test/files/run/t5713/Test_2.scala new file mode 100644 index 0000000000..24f9e79b11 --- /dev/null +++ b/test/files/run/t5713/Test_2.scala @@ -0,0 +1,5 @@ +import m._ + +object Test extends App { + Logger.error("err") +}
\ No newline at end of file diff --git a/test/files/run/t5804.check b/test/files/run/t5804.check new file mode 100644 index 0000000000..3ccc1c24d3 --- /dev/null +++ b/test/files/run/t5804.check @@ -0,0 +1,4 @@ +128 +16 +128 +32
\ No newline at end of file diff --git a/test/files/run/t5804.scala b/test/files/run/t5804.scala new file mode 100644 index 0000000000..b96a736035 --- /dev/null +++ b/test/files/run/t5804.scala @@ -0,0 +1,32 @@ + + +import collection.mutable._ + + +object Test { + + def main(args: Array[String]) { + class CustomHashMap extends HashMap[Int, Int] { + override def initialSize = 65 + + println(table.length) + } + + new CustomHashMap + new HashMap { + println(table.length) + } + + class CustomHashSet extends HashSet[Int] { + override def initialSize = 96 + + println(table.length) + } + + new CustomHashSet + new HashSet { + println(table.length) + } + } + +} diff --git a/test/files/run/t5843.check b/test/files/run/t5843.check new file mode 100644 index 0000000000..2bf97f4cdb --- /dev/null +++ b/test/files/run/t5843.check @@ -0,0 +1,9 @@ + foo="1" + bar="2" foo="1" +null + bar="2" + foo="1" + bar="2" + foo="1" + bar="2" foo="1" + bar="2" foo="1" diff --git a/test/files/run/t5843.scala b/test/files/run/t5843.scala new file mode 100644 index 0000000000..43d588c7b7 --- /dev/null +++ b/test/files/run/t5843.scala @@ -0,0 +1,15 @@ +object Test extends App { + val foo = scala.xml.Attribute(null, "foo", "1", scala.xml.Null) + val bar = scala.xml.Attribute(null, "bar", "2", foo) + println(foo) + println(bar) + println(scala.xml.TopScope.getURI(foo.pre)) + println(bar remove "foo") + println(bar remove "bar") + println(bar remove (null, scala.xml.TopScope, "foo")) + println(bar remove (null, scala.xml.TopScope, "bar")) + + val ns = scala.xml.NamespaceBinding(null, "uri", scala.xml.TopScope) + println(bar remove (null, ns, "foo")) + println(bar remove (null, ns, "bar")) +} diff --git a/test/files/run/toolbox_console_reporter.scala b/test/files/run/toolbox_console_reporter.scala index fd244b40ec..1da9a6bc16 100644 --- a/test/files/run/toolbox_console_reporter.scala +++ b/test/files/run/toolbox_console_reporter.scala @@ -1,10 +1,10 @@ import scala.reflect.mirror._ object Test extends App { - // todo. cannot test this unfortunately, because ConsoleReporter grabs Console.out too early + // todo. cannot test this unfortunately, because ConsoleFrontEnd grabs Console.out too early // todo. and isn't affected by Console.setOut employed by partest to intercept output - //val toolbox = mkToolBox(reporter = mkConsoleReporter(), options = "-deprecation") + //val toolbox = mkToolBox(frontEnd = mkConsoleFrontEnd(), options = "-deprecation") //toolbox.runExpr(reify{ // object Utils { // @deprecated("test", "2.10.0") diff --git a/test/files/run/toolbox_default_reporter_is_silent.scala b/test/files/run/toolbox_default_reporter_is_silent.scala index 78606e2abc..6908c001a3 100644 --- a/test/files/run/toolbox_default_reporter_is_silent.scala +++ b/test/files/run/toolbox_default_reporter_is_silent.scala @@ -9,5 +9,5 @@ object Test extends App { } Utils.foo - }) + }.tree) } diff --git a/test/files/run/toolbox_silent_reporter.scala b/test/files/run/toolbox_silent_reporter.scala index 7e9259946b..6f5687ba4f 100644 --- a/test/files/run/toolbox_silent_reporter.scala +++ b/test/files/run/toolbox_silent_reporter.scala @@ -9,8 +9,8 @@ object Test extends App { } Utils.foo - }) + }.tree) println("============compiler messages============") - toolbox.reporter.infos.foreach(println(_)) + toolbox.frontEnd.infos.foreach(println(_)) println("=========================================") }
\ No newline at end of file diff --git a/test/files/run/toolbox_typecheck_macrosdisabled.check b/test/files/run/toolbox_typecheck_macrosdisabled.check index cf2420bc17..c4af175812 100644 --- a/test/files/run/toolbox_typecheck_macrosdisabled.check +++ b/test/files/run/toolbox_typecheck_macrosdisabled.check @@ -1,5 +1,5 @@ {
val $mr: mr.type = mr;
- $mr.Expr.apply[Int(2)]($mr.Literal.apply($mr.Constant.apply(2)))($mr.ConcreteTypeTag.apply[Int(2)]($mr.ConstantType.apply($mr.Constant.apply(2))))
+ $mr.Expr.apply[Int(2)]($mr.Literal.apply($mr.Constant.apply(2)))($mr.ConcreteTypeTag.apply[Int(2)]($mr.ConstantType.apply($mr.Constant.apply(2)), classOf[scala.Int]))
}
mr.reify[Int](2)
diff --git a/test/files/run/toolbox_typecheck_macrosdisabled.scala b/test/files/run/toolbox_typecheck_macrosdisabled.scala index 7d2707d5e1..afbbce1736 100644 --- a/test/files/run/toolbox_typecheck_macrosdisabled.scala +++ b/test/files/run/toolbox_typecheck_macrosdisabled.scala @@ -5,7 +5,7 @@ object Test extends App { val mrPkg = staticModule("scala.reflect.package") val mrSym = selectTerm(mrPkg, "mirror") val NullaryMethodType(mrTpe) = mrSym.typeSignature - val mr = newFreeTerm("mr", mrTpe, scala.reflect.mirror, null) + val mr = newFreeTerm("mr", mrTpe, scala.reflect.mirror) val tree1 = Apply(Select(Ident(mr), newTermName("reify")), List(Literal(Constant(2)))) val ttree1 = toolbox.typeCheck(tree1, withMacrosDisabled = false) diff --git a/test/files/run/toolbox_typecheck_macrosdisabled2.check b/test/files/run/toolbox_typecheck_macrosdisabled2.check new file mode 100644 index 0000000000..271139b031 --- /dev/null +++ b/test/files/run/toolbox_typecheck_macrosdisabled2.check @@ -0,0 +1,5 @@ +{
+ val $mr: mr.type = mr;
+ $mr.Expr.apply[Array[Int]]($mr.Apply.apply($mr.Select.apply($mr.Select.apply($mr.Ident($mr.staticModule("scala")), $mr.newTermName("Array")), $mr.newTermName("apply")), scala.collection.immutable.List.apply[$mr.Literal]($mr.Literal.apply($mr.Constant.apply(2)))))($mr.ConcreteTypeTag.apply[Array[Int]]($mr.TypeRef.apply($mr.thisModuleType("scala"), $mr.staticClass("scala.Array"), scala.collection.immutable.List.apply[$mr.Type]($mr.staticClass("scala.Int").asTypeConstructor)), ScalaRunTime.this.arrayClass(classOf[scala.Int])))
+}
+mr.reify[Array[Int]](scala.Array.apply(2))
diff --git a/test/files/run/toolbox_typecheck_macrosdisabled2.scala b/test/files/run/toolbox_typecheck_macrosdisabled2.scala new file mode 100644 index 0000000000..b4c76d0600 --- /dev/null +++ b/test/files/run/toolbox_typecheck_macrosdisabled2.scala @@ -0,0 +1,17 @@ +import scala.reflect.mirror._ + +object Test extends App { + val toolbox = mkToolBox() + val mrPkg = staticModule("scala.reflect.package") + val mrSym = selectTerm(mrPkg, "mirror") + val NullaryMethodType(mrTpe) = mrSym.typeSignature + val mr = newFreeTerm("mr", mrTpe, scala.reflect.mirror) + + val tree1 = Apply(Select(Ident(mr), newTermName("reify")), List(Apply(Select(Ident(newTermName("scala")), newTermName("Array")), List(Literal(Constant(2)))))) + val ttree1 = toolbox.typeCheck(tree1, withMacrosDisabled = false) + println(ttree1) + + val tree2 = Apply(Select(Ident(mr), newTermName("reify")), List(Apply(Select(Ident(newTermName("scala")), newTermName("Array")), List(Literal(Constant(2)))))) + val ttree2 = toolbox.typeCheck(tree2, withMacrosDisabled = true) + println(ttree2) +} diff --git a/test/files/run/treePrint.check.temporarily.disabled b/test/files/run/treePrint.check index 3360815ac1..3360815ac1 100644 --- a/test/files/run/treePrint.check.temporarily.disabled +++ b/test/files/run/treePrint.check diff --git a/test/files/run/treePrint.scala.temporarily.disabled b/test/files/run/treePrint.scala index e0332a705f..4a80e2824d 100644 --- a/test/files/run/treePrint.scala.temporarily.disabled +++ b/test/files/run/treePrint.scala @@ -4,7 +4,7 @@ object Test { import scala.tools.nsc._ import interpreter._ import java.io.{ OutputStream, BufferedReader, StringReader, PrintWriter, Writer, OutputStreamWriter} - + val code = """ def foo = { var q: Boolean = false @@ -22,11 +22,11 @@ object Test { else 20 } else 30 - + (x == 5) || !q || true } - """ - + """ + class NullOutputStream extends OutputStream { def write(b: Int) { } } def main(args: Array[String]) { @@ -35,7 +35,8 @@ object Test { settings.Ycompacttrees.value = true val intp = new IMain(settings, new PrintWriter(new NullOutputStream)) - val power = new Power(intp, new ReplVals { }) + val vals = new ReplVals { } + val power = new Power(intp, vals) intp.interpret("""def initialize = "Have to interpret something or we get errors." """) power trees code foreach println } diff --git a/test/files/run/triemap-hash.scala b/test/files/run/triemap-hash.scala new file mode 100644 index 0000000000..7f19997da0 --- /dev/null +++ b/test/files/run/triemap-hash.scala @@ -0,0 +1,46 @@ + + + +import util.hashing.Hashing + + + +object Test { + + def main(args: Array[String]) { + hashing() + equality() + } + + def hashing() { + import collection._ + + val tm = new concurrent.TrieMap[String, String](Hashing.fromFunction(x => x.length + x(0).toInt), Equiv.universal) + tm.put("a", "b") + tm.put("c", "d") + + assert(tm("a") == "b") + assert(tm("c") == "d") + + for (i <- 0 until 1000) tm(i.toString) = i.toString + for (i <- 0 until 1000) assert(tm(i.toString) == i.toString) + } + + def equality() { + import collection._ + + val tm = new concurrent.TrieMap[String, String](Hashing.fromFunction(x => x(0).toInt), Equiv.fromFunction(_(0) == _(0))) + tm.put("a", "b") + tm.put("a1", "d") + tm.put("b", "c") + + assert(tm("a") == "d", tm) + assert(tm("b") == "c", tm) + + for (i <- 0 until 1000) tm(i.toString) = i.toString + assert(tm.size == 12, tm) + assert(tm("0") == "0", tm) + for (i <- 1 to 9) assert(tm(i.toString) == i.toString + "99", tm) + } + +} diff --git a/test/files/run/tuple-zipped.scala b/test/files/run/tuple-zipped.scala index a9851346bc..b197183844 100644 --- a/test/files/run/tuple-zipped.scala +++ b/test/files/run/tuple-zipped.scala @@ -15,14 +15,14 @@ object Test { def main(args: Array[String]): Unit = { for (cc1 <- xss1 ; cc2 <- xss2) { - val sum1 = (cc1, cc2).zip map { case (x, y) => x + y } sum + val sum1 = (cc1, cc2).zipped map { case (x, y) => x + y } sum val sum2 = (cc1, cc2).zipped map (_ + _) sum assert(sum1 == sum2) } for (cc1 <- xss1 ; cc2 <- xss2 ; cc3 <- xss3) { - val sum1 = (cc1, cc2, cc3).zip map { case (x, y, z) => x + y + z } sum + val sum1 = (cc1, cc2, cc3).zipped map { case (x, y, z) => x + y + z } sum val sum2 = (cc1, cc2, cc3).zipped map (_ + _ + _) sum assert(sum1 == sum2) diff --git a/test/files/run/tuples-msil.check b/test/files/run/tuples-msil.check deleted file mode 100644 index e56a796667..0000000000 --- a/test/files/run/tuples-msil.check +++ /dev/null @@ -1,2 +0,0 @@ -(1,abc,True) -OK diff --git a/test/files/run/typetags_core.check b/test/files/run/typetags_core.check index 62fcb481ae..f124aa6a35 100644 --- a/test/files/run/typetags_core.check +++ b/test/files/run/typetags_core.check @@ -1,30 +1,32 @@ -true
-ConcreteTypeTag[Byte]
-true
-ConcreteTypeTag[Short]
-true
-ConcreteTypeTag[Char]
-true
-ConcreteTypeTag[Int]
-true
-ConcreteTypeTag[Long]
-true
-ConcreteTypeTag[Float]
-true
-ConcreteTypeTag[Double]
-true
-ConcreteTypeTag[Boolean]
-true
-ConcreteTypeTag[Unit]
-true
-ConcreteTypeTag[Any]
-true
-ConcreteTypeTag[Object]
-true
-ConcreteTypeTag[AnyVal]
-true
-ConcreteTypeTag[AnyRef]
-true
-ConcreteTypeTag[Null]
-true
-ConcreteTypeTag[Nothing]
+true +ConcreteTypeTag[Byte] +true +ConcreteTypeTag[Short] +true +ConcreteTypeTag[Char] +true +ConcreteTypeTag[Int] +true +ConcreteTypeTag[Long] +true +ConcreteTypeTag[Float] +true +ConcreteTypeTag[Double] +true +ConcreteTypeTag[Boolean] +true +ConcreteTypeTag[Unit] +true +ConcreteTypeTag[Any] +true +ConcreteTypeTag[Object] +true +ConcreteTypeTag[AnyVal] +true +ConcreteTypeTag[AnyRef] +true +ConcreteTypeTag[Null] +true +ConcreteTypeTag[Nothing] +true +ConcreteTypeTag[String] diff --git a/test/files/run/typetags_core.scala b/test/files/run/typetags_core.scala index 883c54b9a8..7d6be16379 100644 --- a/test/files/run/typetags_core.scala +++ b/test/files/run/typetags_core.scala @@ -29,4 +29,6 @@ object Test extends App { println(implicitly[TypeTag[Null]]) println(implicitly[TypeTag[Nothing]] eq TypeTag.Nothing) println(implicitly[TypeTag[Nothing]]) + println(implicitly[TypeTag[String]] eq TypeTag.String) + println(implicitly[TypeTag[String]]) }
\ No newline at end of file diff --git a/test/files/run/typetags_multi.check b/test/files/run/typetags_multi.check new file mode 100644 index 0000000000..613106985c --- /dev/null +++ b/test/files/run/typetags_multi.check @@ -0,0 +1,5 @@ +ConcreteTypeTag[Int]
+ConcreteTypeTag[Array[Int]]
+ConcreteTypeTag[Array[Array[Int]]]
+ConcreteTypeTag[Array[Array[Array[Int]]]]
+ConcreteTypeTag[Array[Array[Array[Array[Int]]]]]
diff --git a/test/files/run/typetags_multi.scala b/test/files/run/typetags_multi.scala new file mode 100644 index 0000000000..868edc2b2a --- /dev/null +++ b/test/files/run/typetags_multi.scala @@ -0,0 +1,7 @@ +object Test extends App { + println(typeTag[Int]) + println(typeTag[Array[Int]]) + println(typeTag[Array[Array[Int]]]) + println(typeTag[Array[Array[Array[Int]]]]) + println(typeTag[Array[Array[Array[Array[Int]]]]]) +}
\ No newline at end of file diff --git a/test/files/run/virtpatmat_alts.flags b/test/files/run/virtpatmat_alts.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/run/virtpatmat_alts.flags +++ b/test/files/run/virtpatmat_alts.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/run/virtpatmat_apply.flags b/test/files/run/virtpatmat_apply.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/run/virtpatmat_apply.flags +++ b/test/files/run/virtpatmat_apply.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/run/virtpatmat_casting.flags b/test/files/run/virtpatmat_casting.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/run/virtpatmat_casting.flags +++ b/test/files/run/virtpatmat_casting.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/run/virtpatmat_extends_product.flags b/test/files/run/virtpatmat_extends_product.flags index ac6b805bd0..8b13789179 100644 --- a/test/files/run/virtpatmat_extends_product.flags +++ b/test/files/run/virtpatmat_extends_product.flags @@ -1 +1 @@ --Yvirtpatmat + diff --git a/test/files/run/virtpatmat_literal.flags b/test/files/run/virtpatmat_literal.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/run/virtpatmat_literal.flags +++ b/test/files/run/virtpatmat_literal.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/run/virtpatmat_nested_lists.flags b/test/files/run/virtpatmat_nested_lists.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/run/virtpatmat_nested_lists.flags +++ b/test/files/run/virtpatmat_nested_lists.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/run/virtpatmat_npe.flags b/test/files/run/virtpatmat_npe.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/run/virtpatmat_npe.flags +++ b/test/files/run/virtpatmat_npe.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/run/virtpatmat_opt_sharing.flags b/test/files/run/virtpatmat_opt_sharing.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/run/virtpatmat_opt_sharing.flags +++ b/test/files/run/virtpatmat_opt_sharing.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/run/virtpatmat_partial.flags b/test/files/run/virtpatmat_partial.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/run/virtpatmat_partial.flags +++ b/test/files/run/virtpatmat_partial.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/run/virtpatmat_partial_backquoted.check b/test/files/run/virtpatmat_partial_backquoted.check new file mode 100644 index 0000000000..8ab8f29677 --- /dev/null +++ b/test/files/run/virtpatmat_partial_backquoted.check @@ -0,0 +1 @@ +Set(You got me!) diff --git a/test/files/run/virtpatmat_partial_backquoted.scala b/test/files/run/virtpatmat_partial_backquoted.scala new file mode 100644 index 0000000000..6d92229d6b --- /dev/null +++ b/test/files/run/virtpatmat_partial_backquoted.scala @@ -0,0 +1,12 @@ +object Test extends App { + class Region { override def toString = "You got me!" } + class SymbolType + case class SymbolInfo(tp: SymbolType, regions: List[Region], x: Any) + + def findRegionsWithSymbolType(rawSymbolInfos: Seq[SymbolInfo], symbolType: SymbolType): Set[Region] = + rawSymbolInfos.collect { case SymbolInfo(`symbolType`, regions, _) => regions }.flatten.toSet + + val stp = new SymbolType + val stp2 = new SymbolType + println(findRegionsWithSymbolType(List(SymbolInfo(stp2, List(), null), SymbolInfo(stp, List(new Region), null)), stp)) +}
\ No newline at end of file diff --git a/test/files/run/virtpatmat_staging.flags b/test/files/run/virtpatmat_staging.flags index 9769db9257..48fd867160 100644 --- a/test/files/run/virtpatmat_staging.flags +++ b/test/files/run/virtpatmat_staging.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental +-Xexperimental diff --git a/test/files/run/virtpatmat_stringinterp.check b/test/files/run/virtpatmat_stringinterp.check new file mode 100644 index 0000000000..7927f4f2d9 --- /dev/null +++ b/test/files/run/virtpatmat_stringinterp.check @@ -0,0 +1 @@ +Node(1) diff --git a/test/files/run/virtpatmat_stringinterp.flags b/test/files/run/virtpatmat_stringinterp.flags new file mode 100644 index 0000000000..e1b37447c9 --- /dev/null +++ b/test/files/run/virtpatmat_stringinterp.flags @@ -0,0 +1 @@ +-Xexperimental
\ No newline at end of file diff --git a/test/files/run/virtpatmat_stringinterp.scala b/test/files/run/virtpatmat_stringinterp.scala new file mode 100644 index 0000000000..213712f17a --- /dev/null +++ b/test/files/run/virtpatmat_stringinterp.scala @@ -0,0 +1,13 @@ +object Test extends App { + case class Node(x: Int) + + implicit def sc2xml(sc: StringContext): XMLContext = new XMLContext(sc) + class XMLContext(sc: StringContext) { + object xml { + def unapplySeq(xml: Node): Option[Seq[Node]] = Some(List(Node(1))) + } + } + + val x: Node = Node(0) + x match { case xml"""<foo arg=$a/>""" => println(a) } +}
\ No newline at end of file diff --git a/test/files/run/virtpatmat_switch.flags b/test/files/run/virtpatmat_switch.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/run/virtpatmat_switch.flags +++ b/test/files/run/virtpatmat_switch.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/run/virtpatmat_tailcalls_verifyerror.flags b/test/files/run/virtpatmat_tailcalls_verifyerror.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/run/virtpatmat_tailcalls_verifyerror.flags +++ b/test/files/run/virtpatmat_tailcalls_verifyerror.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/run/virtpatmat_try.flags b/test/files/run/virtpatmat_try.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/run/virtpatmat_try.flags +++ b/test/files/run/virtpatmat_try.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/run/virtpatmat_typed.flags b/test/files/run/virtpatmat_typed.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/run/virtpatmat_typed.flags +++ b/test/files/run/virtpatmat_typed.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/run/virtpatmat_unapply.flags b/test/files/run/virtpatmat_unapply.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/run/virtpatmat_unapply.flags +++ b/test/files/run/virtpatmat_unapply.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/run/virtpatmat_unapplyprod.flags b/test/files/run/virtpatmat_unapplyprod.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/run/virtpatmat_unapplyprod.flags +++ b/test/files/run/virtpatmat_unapplyprod.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/run/virtpatmat_unapplyseq.flags b/test/files/run/virtpatmat_unapplyseq.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/run/virtpatmat_unapplyseq.flags +++ b/test/files/run/virtpatmat_unapplyseq.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/run/virtpatmat_valdef.check b/test/files/run/virtpatmat_valdef.check new file mode 100644 index 0000000000..1a45335bd2 --- /dev/null +++ b/test/files/run/virtpatmat_valdef.check @@ -0,0 +1 @@ +meh(true,null) diff --git a/test/files/run/virtpatmat_valdef.scala b/test/files/run/virtpatmat_valdef.scala new file mode 100644 index 0000000000..f1a9b46cdd --- /dev/null +++ b/test/files/run/virtpatmat_valdef.scala @@ -0,0 +1,6 @@ +object Test extends App { + // patterns in valdefs... + // TODO: irrefutability should indicate we don't actually need to test, just deconstruct + val (modified, result) : (Boolean, String) = (true, null) + println("meh"+ (modified, result)) +}
\ No newline at end of file diff --git a/test/files/run/xml-loop-bug.scala b/test/files/run/xml-loop-bug.scala index 378ae9bc2b..67637674b2 100644 --- a/test/files/run/xml-loop-bug.scala +++ b/test/files/run/xml-loop-bug.scala @@ -1,6 +1,8 @@ object Test { def main(args: Array[String]): Unit = { - scala.tools.nsc.io.NullPrintStream.setOutAndErr() + val sink = new java.io.PrintStream(new java.io.ByteArrayOutputStream()) + Console setOut sink + Console setErr sink scala.xml.parsing.ConstructingParser.fromSource(scala.io.Source.fromString("<!DOCTYPE xmeml SYSTEM> <xmeml> <sequence> </sequence> </xmeml> "), true).document.docElem } } diff --git a/test/files/scalacheck/array-new.scala b/test/files/scalacheck/array-new.scala new file mode 100644 index 0000000000..18d577ca6d --- /dev/null +++ b/test/files/scalacheck/array-new.scala @@ -0,0 +1,36 @@ +import org.scalacheck._ +import Prop._ +import Gen._ +import Arbitrary._ +import util._ +import Buildable._ +import scala.collection.mutable.ArraySeq + +object Test extends Properties("Array") { + /** At this moment the authentic scalacheck Array Builder/Arb bits are commented out. + */ + implicit def arbArray[T](implicit a: Arbitrary[T], m: ArrayTag[T]): Arbitrary[Array[T]] = + Arbitrary(containerOf[List,T](arbitrary[T]) map (_.toArray)) + + val arrGen: Gen[Array[_]] = oneOf( + arbitrary[Array[Int]], + arbitrary[Array[Array[Int]]], + arbitrary[Array[List[String]]], + arbitrary[Array[String]], + arbitrary[Array[Boolean]], + arbitrary[Array[AnyVal]] + ) + + // inspired by #1857 and #2352 + property("eq/ne") = forAll(arrGen, arrGen) { (c1, c2) => + (c1 eq c2) || (c1 ne c2) + } + + // inspired by #2299 + def smallInt = choose(1, 10) + property("ofDim") = forAll(smallInt, smallInt, smallInt) { (i1, i2, i3) => + val arr = Array.ofDim[String](i1, i2, i3) + val flattened = arr flatMap (x => x) flatMap (x => x) + flattened.length == i1 * i2 * i3 + } +} diff --git a/test/files/scalacheck/array.scala b/test/files/scalacheck/array-old.scala index f262bc6320..f262bc6320 100644 --- a/test/files/scalacheck/array.scala +++ b/test/files/scalacheck/array-old.scala diff --git a/test/files/specialized/SI-5005.check b/test/files/specialized/SI-5005.check index 9fc63a2b1d..81e8342dad 100644 --- a/test/files/specialized/SI-5005.check +++ b/test/files/specialized/SI-5005.check @@ -1,4 +1,4 @@ -[[syntax trees at end of specialize]]// Scala source: newSource1 +[[syntax trees at end of specialize]] // newSource1 package <empty> { class C2[@specialized(scala.Boolean) U >: Nothing <: Any] extends Object { def <init>(): C2[U] = { diff --git a/test/files/specialized/spec-matrix.check b/test/files/specialized/spec-matrix-new.check index 5ec3e84597..5ec3e84597 100644 --- a/test/files/specialized/spec-matrix.check +++ b/test/files/specialized/spec-matrix-new.check diff --git a/test/files/specialized/spec-matrix-new.scala b/test/files/specialized/spec-matrix-new.scala new file mode 100644 index 0000000000..65b46e8d48 --- /dev/null +++ b/test/files/specialized/spec-matrix-new.scala @@ -0,0 +1,80 @@ +/** Test matrix multiplication with specialization. + */ + +class Matrix[@specialized A: ArrayTag](val rows: Int, val cols: Int) { + private val arr: Array[Array[A]] = Array.ofDim[A](rows, cols) + + def apply(i: Int, j: Int): A = { + if (i < 0 || i >= rows || j < 0 || j >= cols) + throw new NoSuchElementException("Indexes out of bounds: " + (i, j)) + + arr(i)(j) + } + + def update(i: Int, j: Int, e: A) { + arr(i)(j) = e + } + + def rowsIterator: Iterator[Array[A]] = new Iterator[Array[A]] { + var idx = 0; + def hasNext = idx < rows + def next = { + idx += 1 + arr(idx - 1) + } + } +} + +object Test { + def main(args: Array[String]) { + val m = randomMatrix(200, 100) + val n = randomMatrix(100, 200) + + val p = mult(m, n) + println(p(0, 0)) + println("Boxed doubles: " + runtime.BoxesRunTime.doubleBoxCount) +// println("Boxed integers: " + runtime.BoxesRunTime.integerBoxCount) + } + + def randomMatrix(n: Int, m: Int) = { + val r = new util.Random(10) + val x = new Matrix[Double](n, m) + for (i <- 0 until n; j <- 0 until m) + x(i, j) = (r.nextInt % 1000).toDouble + x + } + + def printMatrix[Double](m: Matrix[Double]) { + for (i <- 0 until m.rows) { + for (j <- 0 until m.cols) + print("%5.3f ".format(m(i, j))) + println + } + } + + def multTag[@specialized(Int) T](m: Matrix[T], n: Matrix[T])(implicit at: ArrayTag[T], num: Numeric[T]) { + val p = new Matrix[T](m.rows, n.cols) + import num._ + + for (i <- 0 until m.rows) + for (j <- 0 until n.cols) { + var sum = num.zero + for (k <- 0 until n.rows) + sum += m(i, k) * n(k, j) + p(i, j) = sum + } + } + + def mult(m: Matrix[Double], n: Matrix[Double]) = { + val p = new Matrix[Double](m.rows, n.cols) + + for (i <- 0 until m.rows) + for (j <- 0 until n.cols) { + var sum = 0.0 + for (k <- 0 until n.rows) + sum += m(i, k) * n(k, j) + p(i, j) = sum + } + p + } +} diff --git a/test/files/specialized/spec-matrix-old.check b/test/files/specialized/spec-matrix-old.check new file mode 100644 index 0000000000..5ec3e84597 --- /dev/null +++ b/test/files/specialized/spec-matrix-old.check @@ -0,0 +1,2 @@ +251437.0 +Boxed doubles: 1 diff --git a/test/files/specialized/spec-matrix.scala b/test/files/specialized/spec-matrix-old.scala index 98735c8c03..98735c8c03 100644 --- a/test/files/specialized/spec-matrix.scala +++ b/test/files/specialized/spec-matrix-old.scala diff --git a/test/files/specialized/spec-patmatch.check b/test/files/specialized/spec-patmatch.check index 33306ab5d9..a2746c0f48 100644 --- a/test/files/specialized/spec-patmatch.check +++ b/test/files/specialized/spec-patmatch.check @@ -17,4 +17,4 @@ long double float default -2
\ No newline at end of file +10 diff --git a/test/files/speclib/instrumented.jar.desired.sha1 b/test/files/speclib/instrumented.jar.desired.sha1 index 2d4cd04a92..a7da67429e 100644 --- a/test/files/speclib/instrumented.jar.desired.sha1 +++ b/test/files/speclib/instrumented.jar.desired.sha1 @@ -1 +1 @@ -d83c6bf3765ab1378943020a8d9cda8851604ffa ?instrumented.jar +15f200d9f0f25f9fd871bad2ebb4ba5cfc671db4 ?instrumented.jar |