summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/files/continuations-run/t5472.check1
-rw-r--r--test/files/continuations-run/t5472.scala90
-rw-r--r--test/pending/pos/t5399.scala15
-rw-r--r--test/pending/pos/t5399a.scala19
-rw-r--r--test/pending/pos/t5685.scala23
-rw-r--r--test/pending/pos/t5685b.scala23
6 files changed, 160 insertions, 11 deletions
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/pending/pos/t5399.scala b/test/pending/pos/t5399.scala
index d8c1d5e51c..89caba39c1 100644
--- a/test/pending/pos/t5399.scala
+++ b/test/pending/pos/t5399.scala
@@ -1,15 +1,8 @@
class Test {
- type AnyCyclic = Execute[Task]#CyclicException[_]
+ class A[T]
+ class B[T](val a: A[T])
- trait Task[T]
+ case class CaseClass[T](x: 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!"
- }
+ def break(existB: B[_]) = CaseClass(existB.a) match { case CaseClass(_) => }
}
-
diff --git a/test/pending/pos/t5399a.scala b/test/pending/pos/t5399a.scala
new file mode 100644
index 0000000000..4ebd85ad03
--- /dev/null
+++ b/test/pending/pos/t5399a.scala
@@ -0,0 +1,19 @@
+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) => ()
+ }
+ }
+}
diff --git a/test/pending/pos/t5685.scala b/test/pending/pos/t5685.scala
new file mode 100644
index 0000000000..9ac42a174e
--- /dev/null
+++ b/test/pending/pos/t5685.scala
@@ -0,0 +1,23 @@
+trait X[A] {
+ def x: A
+}
+
+trait XPrint[A] extends X[A] {
+ abstract override def x: A = {
+ val a = super.x
+ println(a)
+ a
+ }
+}
+
+trait F[A, B] { outer =>
+ def apply(xv: X[A]): X[B]
+
+ def andThen[C](f: F[B, C]): F[A, C] = new F[A, C] {
+ def apply(xv: X[A]): X[C] = f(new XX(xv) with XPrint[B])
+ }
+
+ class XX(xv: X[A]) extends X[B] {
+ def x = outer(xv).x
+ }
+}
diff --git a/test/pending/pos/t5685b.scala b/test/pending/pos/t5685b.scala
new file mode 100644
index 0000000000..18ff803f89
--- /dev/null
+++ b/test/pending/pos/t5685b.scala
@@ -0,0 +1,23 @@
+trait X[+A] {
+ def x: A
+}
+
+trait XPrint[+A] extends X[A] {
+ abstract override def x: A = {
+ val a = super.x
+ println(a)
+ a
+ }
+}
+
+trait F[-A, +B] { outer =>
+ def apply(xv: X[A]): X[B]
+
+ def andThen[C](f: F[B, C]): F[A, C] = new F[A, C] {
+ def apply(xv: X[A]): X[C] = f(new XX(xv) with XPrint[B])
+ }
+
+ class XX(xv: X[A]) extends X[B] {
+ def x = outer(xv).x
+ }
+}