summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDen Shabalin <den.shabalin@gmail.com>2013-11-13 15:33:33 +0100
committerDen Shabalin <den.shabalin@gmail.com>2013-11-20 16:06:30 +0100
commitb004c3ddb38f8e690a0895a51ad0c83ff57a01e7 (patch)
tree0c31f83d2e039db4c2ead7a3280aaabc78671333
parentc243435f113615b2f7407fbd683c93ec16c73749 (diff)
downloadscala-b004c3ddb38f8e690a0895a51ad0c83ff57a01e7.tar.gz
scala-b004c3ddb38f8e690a0895a51ad0c83ff57a01e7.tar.bz2
scala-b004c3ddb38f8e690a0895a51ad0c83ff57a01e7.zip
deprecate Pair and Triple
-rw-r--r--docs/examples/fors.scala2
-rw-r--r--docs/examples/iterators.scala4
-rw-r--r--docs/examples/jolib/Ref.scala8
-rw-r--r--docs/examples/jolib/parallelOr.scala22
-rw-r--r--docs/examples/monads/callccInterpreter.scala18
-rw-r--r--docs/examples/monads/directInterpreter.scala14
-rw-r--r--docs/examples/monads/errorInterpreter.scala10
-rw-r--r--docs/examples/monads/simpleInterpreter.scala14
-rw-r--r--docs/examples/monads/stateInterpreter.scala24
-rw-r--r--docs/examples/patterns.scala8
-rw-r--r--docs/examples/pilib/elasticBuffer.scala8
-rw-r--r--docs/examples/pilib/handover.scala38
-rw-r--r--docs/examples/pilib/piNat.scala16
-rw-r--r--docs/examples/typeinf.scala50
-rw-r--r--src/actors/scala/actors/Future.scala14
-rw-r--r--src/actors/scala/actors/remote/NetKernel.scala8
-rw-r--r--src/actors/scala/actors/remote/Proxy.scala4
-rw-r--r--src/actors/scala/actors/remote/RemoteActor.scala4
-rw-r--r--src/actors/scala/actors/remote/TcpService.scala8
-rw-r--r--src/compiler/scala/tools/ant/ScalaTool.scala4
-rw-r--r--src/compiler/scala/tools/ant/sabbus/Compilers.scala2
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala2
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala2
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala8
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala4
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/BCodeSkelBuilder.scala2
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/BCodeTypes.scala4
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala20
-rw-r--r--src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala6
-rw-r--r--src/compiler/scala/tools/nsc/plugins/Plugin.scala2
-rw-r--r--src/library/scala/Predef.scala6
-rw-r--r--src/repl/scala/tools/nsc/interpreter/JavapClass.scala2
-rw-r--r--src/scaladoc/scala/tools/ant/Scaladoc.scala6
-rw-r--r--src/scalap/scala/tools/scalap/Arguments.scala6
-rw-r--r--test/disabled/run/lisp.scala16
-rw-r--r--test/files/jvm/typerep.scala2
-rw-r--r--test/files/neg/patmatexhaust.scala4
-rw-r--r--test/files/neg/t414.scala2
-rw-r--r--test/files/neg/t5702-neg-bad-and-wild.check2
-rw-r--r--test/files/neg/t5702-neg-bad-and-wild.scala2
-rw-r--r--test/files/neg/t997.scala2
-rw-r--r--test/files/neg/wellkinded_wrongarity.check4
-rw-r--r--test/files/neg/wellkinded_wrongarity.scala2
-rw-r--r--test/files/pos/bounds.scala6
-rw-r--r--test/files/pos/patmat.scala4
-rw-r--r--test/files/pos/spec-doubledef-new.scala6
-rw-r--r--test/files/pos/spec-doubledef-old.scala6
-rw-r--r--test/files/pos/t0064.scala2
-rw-r--r--test/files/pos/t247.scala4
-rw-r--r--test/files/pos/t443.scala8
-rw-r--r--test/files/pos/t4579.scala12
-rw-r--r--test/files/pos/t5120.scala4
-rw-r--r--test/files/pos/tcpoly_bounds1.scala4
-rw-r--r--test/files/pos/typealiases.scala2
-rw-r--r--test/files/pos/unapplyNeedsMemberType.scala2
-rw-r--r--test/files/pos/valdefs.scala2
-rw-r--r--test/files/positions/ExcludedPrefix1.scala2
-rw-r--r--test/files/positions/Overlap4.scala2
-rw-r--r--test/files/positions/Scaladoc7.scala2
-rw-r--r--test/files/presentation/callcc-interpreter.check8
-rw-r--r--test/files/presentation/callcc-interpreter/src/CallccInterpreter.scala32
-rw-r--r--test/files/run/Course-2002-05.scala16
-rw-r--r--test/files/run/Course-2002-06.scala2
-rw-r--r--test/files/run/Course-2002-07.scala140
-rw-r--r--test/files/run/Course-2002-08.scala28
-rw-r--r--test/files/run/Course-2002-09.scala40
-rw-r--r--test/files/run/Course-2002-13.scala16
-rw-r--r--test/files/run/bugs.scala2
-rw-r--r--test/files/run/map_test.scala2
-rw-r--r--test/files/run/patmatnew.scala28
-rw-r--r--test/files/run/t3888.scala2
-rw-r--r--test/files/run/tailcalls.scala2
-rw-r--r--test/files/run/tcpoly_parseridioms.check4
-rw-r--r--test/files/run/tcpoly_parseridioms.scala8
-rw-r--r--test/files/run/withIndex.scala2
-rw-r--r--test/pending/run/reify_callccinterpreter.scala12
-rw-r--r--test/pending/run/reify_simpleinterpreter.scala10
-rw-r--r--test/pending/shootout/fasta.scala64
-rw-r--r--test/pending/shootout/revcomp.scala-2.scala18
-rw-r--r--test/pending/shootout/revcomp.scala-3.scala40
80 files changed, 468 insertions, 462 deletions
diff --git a/docs/examples/fors.scala b/docs/examples/fors.scala
index b937e53fcd..29616b61b1 100644
--- a/docs/examples/fors.scala
+++ b/docs/examples/fors.scala
@@ -83,7 +83,7 @@ object fors {
if b1 != b2;
Elem(_, "author", _, _, Text(a1)) <- b1.toList;
Elem(_, "author", _, _, Text(a2)) <- b2.toList;
- if a1 == a2) yield Pair(a1, a2))
+ if a1 == a2) yield (a1, a2))
def removeDuplicates[a](xs: List[a]): List[a] =
if (xs.isEmpty)
diff --git a/docs/examples/iterators.scala b/docs/examples/iterators.scala
index e2e5e050a0..9ddb141d61 100644
--- a/docs/examples/iterators.scala
+++ b/docs/examples/iterators.scala
@@ -15,8 +15,8 @@ object iterators {
def findGreater(xs: Array[Double], limit: Double) =
xs.iterator
.zip(Iterator.from(0))
- .filter{case Pair(x, i) => x > limit }
- .map{case Pair(x, i) => i}
+ .filter{case (x, i) => x > limit }
+ .map{case (x, i) => i}
def main(args: Array[String]) {
val ar = Array/*[Double]*/(6, 2, 8, 5, 1)
diff --git a/docs/examples/jolib/Ref.scala b/docs/examples/jolib/Ref.scala
index 32952b4351..099a3c2df2 100644
--- a/docs/examples/jolib/Ref.scala
+++ b/docs/examples/jolib/Ref.scala
@@ -12,20 +12,20 @@ import concurrent.SyncVar;
import concurrent.jolib._;
class Ref[a](init: a) extends Join {
-
+
object get extends Synchr[a](this) { case class C() extends SyncVar[a]; }
object set extends Synchr[unit](this) { case class C(x: a) extends SyncVar[unit]; }
object state extends Asynchr(this) { case class C(x: a); }
rules (
- Pair(List(get, state), { case List(g @ get.C(), state.C(x) ) =>
+ (List(get, state), { case List(g @ get.C(), state.C(x) ) =>
{ g.set(x); state(state.C(x)) } }),
- Pair(List(set, state), { case List(s @ set.C(x), state.C(y) ) =>
+ (List(set, state), { case List(s @ set.C(x), state.C(y) ) =>
{ s.set(()); state(state.C(x)) } })
);
state(state.C(init));
-
+
def Get: a = get(get.C());
def Set(x: a): unit = set(set.C(x));
}
diff --git a/docs/examples/jolib/parallelOr.scala b/docs/examples/jolib/parallelOr.scala
index fb8288c5b2..a0305c56bf 100644
--- a/docs/examples/jolib/parallelOr.scala
+++ b/docs/examples/jolib/parallelOr.scala
@@ -13,27 +13,27 @@ import concurrent.SyncVar;
/** Implementation in the join-calculus of a parallel OR. */
object or extends Join {
-
+
object res extends Synchr[boolean](this) { case class C() extends SyncVar[boolean] };
object res1 extends Asynchr(this) { case class C(b: boolean); }
object res2 extends Asynchr(this) { case class C(b: boolean); }
object res1False extends Synchr[boolean](this) { case class C() extends SyncVar[boolean] };
object res2False extends Synchr[boolean](this) { case class C() extends SyncVar[boolean] };
-
+
rules(
- Pair(List(res, res1), { case List(r @ res.C(), res1.C(b)) =>
+ (List(res, res1), { case List(r @ res.C(), res1.C(b)) =>
if (b) r.set(b) else r.set(res1False(res1False.C())) }),
-
- Pair(List(res, res2), { case List(r @ res.C(), res2.C(b)) =>
+
+ (List(res, res2), { case List(r @ res.C(), res2.C(b)) =>
if (b) r.set(b) else r.set(res2False(res2False.C())) }),
-
- Pair(List(res1False, res2), { case List(r @ res1False.C(), res2.C(b)) =>
+
+ (List(res1False, res2), { case List(r @ res1False.C(), res2.C(b)) =>
r.set(b) }),
-
- Pair(List(res2False, res1), { case List(r @ res2False.C(), res1.C(b)) =>
+
+ (List(res2False, res1), { case List(r @ res2False.C(), res1.C(b)) =>
r.set(b) })
);
-
+
def apply(b1: => boolean, b2: => boolean): boolean = {
concurrent.ops.spawn(res1(res1.C(b1)));
concurrent.ops.spawn(res2(res2.C(b2)));
@@ -42,7 +42,7 @@ object or extends Join {
}
*/
object parallelOr {
-
+
def main(args: Array[String]): unit = {
def loop: boolean = { while (true) {}; true };
/*
diff --git a/docs/examples/monads/callccInterpreter.scala b/docs/examples/monads/callccInterpreter.scala
index 5b556bd8fa..b5008c4c1b 100644
--- a/docs/examples/monads/callccInterpreter.scala
+++ b/docs/examples/monads/callccInterpreter.scala
@@ -14,7 +14,7 @@ object callccInterpreter {
def showM(m: M[Value]): String = (m in id).toString();
- def callCC[A](h: (A => M[A]) => M[A]) =
+ def callCC[A](h: (A => M[A]) => M[A]) =
M[A](c => h(a => M[A](d => c(a))) in c);
type Name = String;
@@ -30,7 +30,7 @@ object callccInterpreter {
trait Value;
case object Wrong extends Value {
override def toString() = "wrong"
- }
+ }
case class Num(n: Int) extends Value {
override def toString() = n.toString();
}
@@ -38,15 +38,15 @@ object callccInterpreter {
override def toString() = "<function>"
}
- type Environment = List[Pair[Name, Value]];
+ type Environment = List[Tuple2[Name, Value]];
def lookup(x: Name, e: Environment): M[Value] = e match {
case List() => unitM(Wrong)
- case Pair(y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
+ case (y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
}
- def add(a: Value, b: Value): M[Value] = Pair(a, b) match {
- case Pair(Num(m), Num(n)) => unitM(Num(m + n))
+ def add(a: Value, b: Value): M[Value] = (a, b) match {
+ case (Num(m), Num(n)) => unitM(Num(m + n))
case _ => unitM(Wrong)
}
@@ -62,15 +62,15 @@ object callccInterpreter {
b <- interp(r, e);
c <- add(a, b))
yield c
- case Lam(x, t) => unitM(Fun(a => interp(t, Pair(x, a) :: e)))
+ case Lam(x, t) => unitM(Fun(a => interp(t, (x, a) :: e)))
case App(f, t) => for (a <- interp(f, e);
b <- interp(t, e);
c <- apply(a, b))
yield c
- case Ccc(x, t) => callCC(k => interp(t, Pair(x, Fun(k)) :: e))
+ case Ccc(x, t) => callCC(k => interp(t, (x, Fun(k)) :: e))
}
- def test(t: Term): String =
+ def test(t: Term): String =
showM(interp(t, List()));
val term0 = App(Lam("x", Add(Var("x"), Var("x"))), Add(Con(10), Con(11)));
diff --git a/docs/examples/monads/directInterpreter.scala b/docs/examples/monads/directInterpreter.scala
index 06fffba8e2..d8ca8ccfa7 100644
--- a/docs/examples/monads/directInterpreter.scala
+++ b/docs/examples/monads/directInterpreter.scala
@@ -20,15 +20,15 @@ object directInterpreter {
case Fun(f) => "<function>"
}
- type Environment = List[Pair[Name, Value]];
+ type Environment = List[Tuple2[Name, Value]];
def lookup(x: Name, e: Environment): Value = e match {
case List() => Wrong
- case Pair(y, b) :: e1 => if (x == y) b else lookup(x, e1)
+ case (y, b) :: e1 => if (x == y) b else lookup(x, e1)
}
- def add(a: Value, b: Value): Value = Pair(a, b) match {
- case Pair(Num(m), Num(n)) => Num(m + n)
+ def add(a: Value, b: Value): Value = (a, b) match {
+ case (Num(m), Num(n)) => Num(m + n)
case _ => Wrong
}
@@ -41,15 +41,15 @@ object directInterpreter {
case Var(x) => lookup(x, e)
case Con(n) => Num(n)
case Add(l, r) => add(interp(l, e), interp(r, e))
- case Lam(x, t) => Fun(a => interp(t, Pair(x, a) :: e))
+ case Lam(x, t) => Fun(a => interp(t, (x, a) :: e))
case App(f, t) => apply(interp(f, e), interp(t, e))
}
- def test(t: Term): String =
+ def test(t: Term): String =
showval(interp(t, List()));
val term0 = App(Lam("x", Add(Var("x"), Var("x"))), Add(Con(10), Con(11)));
- def main(args: Array[String]) =
+ def main(args: Array[String]) =
System.out.println(test(term0));
}
diff --git a/docs/examples/monads/errorInterpreter.scala b/docs/examples/monads/errorInterpreter.scala
index d3cc45627d..c15e1041e2 100644
--- a/docs/examples/monads/errorInterpreter.scala
+++ b/docs/examples/monads/errorInterpreter.scala
@@ -41,15 +41,15 @@ object errorInterpreter {
override def toString() = "<function>"
}
- type Environment = List[Pair[Name, Value]]
+ type Environment = List[Tuple2[Name, Value]]
def lookup(x: Name, e: Environment): M[Value] = e match {
case List() => errorM("unbound variable: " + x);
- case Pair(y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
+ case (y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
}
- def add(a: Value, b: Value): M[Value] = Pair(a, b) match {
- case Pair(Num(m), Num(n)) => unitM(Num(m + n))
+ def add(a: Value, b: Value): M[Value] = (a, b) match {
+ case (Num(m), Num(n)) => unitM(Num(m + n))
case _ => errorM("should be numbers: " + a + "," + b)
}
@@ -65,7 +65,7 @@ object errorInterpreter {
b <- interp(r, e);
c <- add(a, b))
yield c
- case Lam(x, t) => unitM(Fun(a => interp(t, Pair(x, a) :: e)))
+ case Lam(x, t) => unitM(Fun(a => interp(t, (x, a) :: e)))
case App(f, t) => for (a <- interp(f, e);
b <- interp(t, e);
c <- apply(a, b))
diff --git a/docs/examples/monads/simpleInterpreter.scala b/docs/examples/monads/simpleInterpreter.scala
index cde3a92dbb..64636749ff 100644
--- a/docs/examples/monads/simpleInterpreter.scala
+++ b/docs/examples/monads/simpleInterpreter.scala
@@ -22,7 +22,7 @@ object simpleInterpreter {
trait Value;
case object Wrong extends Value {
override def toString() = "wrong"
- }
+ }
case class Num(n: Int) extends Value {
override def toString() = n.toString();
}
@@ -30,15 +30,15 @@ object simpleInterpreter {
override def toString() = "<function>"
}
- type Environment = List[Pair[Name, Value]];
+ type Environment = List[Tuple2[Name, Value]];
def lookup(x: Name, e: Environment): M[Value] = e match {
case List() => unitM(Wrong)
- case Pair(y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
+ case (y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
}
- def add(a: Value, b: Value): M[Value] = Pair(a, b) match {
- case Pair(Num(m), Num(n)) => unitM(Num(m + n))
+ def add(a: Value, b: Value): M[Value] = (a, b) match {
+ case (Num(m), Num(n)) => unitM(Num(m + n))
case _ => unitM(Wrong)
}
@@ -54,14 +54,14 @@ object simpleInterpreter {
b <- interp(r, e);
c <- add(a, b))
yield c
- case Lam(x, t) => unitM(Fun(a => interp(t, Pair(x, a) :: e)))
+ case Lam(x, t) => unitM(Fun(a => interp(t, (x, a) :: e)))
case App(f, t) => for (a <- interp(f, e);
b <- interp(t, e);
c <- apply(a, b))
yield c
}
- def test(t: Term): String =
+ def test(t: Term): String =
showM(interp(t, List()));
val term0 = App(Lam("x", Add(Var("x"), Var("x"))), Add(Con(10), Con(11)));
diff --git a/docs/examples/monads/stateInterpreter.scala b/docs/examples/monads/stateInterpreter.scala
index 97f3335dab..e13e9049da 100644
--- a/docs/examples/monads/stateInterpreter.scala
+++ b/docs/examples/monads/stateInterpreter.scala
@@ -4,20 +4,20 @@ object stateInterpreter {
type State = Int;
- val tickS = new M(s => Pair((), s + 1));
+ val tickS = new M(s => ((), s + 1));
- case class M[A](in: State => Pair[A, State]) {
- def bind[B](k: A => M[B]) = M[B]{ s0 =>
- val Pair(a, s1) = this in s0; k(a) in s1
+ case class M[A](in: State => Tuple2[A, State]) {
+ def bind[B](k: A => M[B]) = M[B]{ s0 =>
+ val (a, s1) = this in s0; k(a) in s1
}
def map[B](f: A => B): M[B] = bind(x => unitM(f(x)));
def flatMap[B](f: A => M[B]): M[B] = bind(f);
}
- def unitM[A](a: A) = M[A](s => Pair(a, s));
+ def unitM[A](a: A) = M[A](s => (a, s));
def showM(m: M[Value]): String = {
- val Pair(a, s1) = m in 0;
+ val (a, s1) = m in 0;
"Value: " + a + "; Count: " + s1
}
@@ -41,15 +41,15 @@ object stateInterpreter {
override def toString() = "<function>"
}
- type Environment = List[Pair[Name, Value]];
+ type Environment = List[Tuple2[Name, Value]];
def lookup(x: Name, e: Environment): M[Value] = e match {
case List() => unitM(Wrong)
- case Pair(y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
+ case (y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
}
- def add(a: Value, b: Value): M[Value] = Pair(a, b) match {
- case Pair(Num(m), Num(n)) => for (_ <- tickS) yield Num(m + n)
+ def add(a: Value, b: Value): M[Value] = (a, b) match {
+ case (Num(m), Num(n)) => for (_ <- tickS) yield Num(m + n)
case _ => unitM(Wrong)
}
@@ -65,14 +65,14 @@ object stateInterpreter {
b <- interp(r, e);
c <- add(a, b))
yield c
- case Lam(x, t) => unitM(Fun(a => interp(t, Pair(x, a) :: e)))
+ case Lam(x, t) => unitM(Fun(a => interp(t, (x, a) :: e)))
case App(f, t) => for (a <- interp(f, e);
b <- interp(t, e);
c <- apply(a, b))
yield c
}
- def test(t: Term): String =
+ def test(t: Term): String =
showM(interp(t, List()));
val term0 = App(Lam("x", Add(Var("x"), Var("x"))), Add(Con(10), Con(11)));
diff --git a/docs/examples/patterns.scala b/docs/examples/patterns.scala
index 738deabc66..d082fcc3de 100644
--- a/docs/examples/patterns.scala
+++ b/docs/examples/patterns.scala
@@ -13,17 +13,17 @@ object patterns {
case Leaf(x) => x
}
- def find[a,b](it: Iterator[Pair[a, b]], x: a): Option[b] = {
+ def find[a,b](it: Iterator[Tuple2[a, b]], x: a): Option[b] = {
var result: Option[b] = None
var found = false
while (it.hasNext && !found) {
- val Pair(x1, y) = it.next
+ val (x1, y) = it.next
if (x == x1) { found = true; result = Some(y) }
}
result
}
- def printFinds[a](xs: List[Pair[a, String]], x: a) =
+ def printFinds[a](xs: List[Tuple2[a, String]], x: a) =
find(xs.iterator, x) match {
case Some(y) => System.out.println(y)
case None => System.out.println("no match")
@@ -31,6 +31,6 @@ object patterns {
def main(args: Array[String]) {
println("sum of leafs=" + sumLeaves(tree1))
- printFinds(List(Pair(3, "three"), Pair(4, "four")), 4)
+ printFinds(List((3, "three"), (4, "four")), 4)
}
}
diff --git a/docs/examples/pilib/elasticBuffer.scala b/docs/examples/pilib/elasticBuffer.scala
index 5fec96ab6c..c173735dbb 100644
--- a/docs/examples/pilib/elasticBuffer.scala
+++ b/docs/examples/pilib/elasticBuffer.scala
@@ -8,7 +8,7 @@ object elasticBuffer {
* Recursive type for channels that carry a "String" channel and
* an object of the type we define.
*/
- class MetaChan extends Chan[Pair[Chan[String], MetaChan]]
+ class MetaChan extends Chan[Tuple2[Chan[String], MetaChan]]
def Buffer(put: Chan[String], get: Chan[String]): Unit = {
@@ -18,19 +18,19 @@ object elasticBuffer {
def Bl(i:Chan[String], l: MetaChan,
o: Chan[String], r: MetaChan): unit =
choice (
- l(Pair(o,r)) * (System.out.println("Removed one cell.")),
+ l((o,r)) * (System.out.println("Removed one cell.")),
i * (inp => Cl(i, l, o, r, inp))
)
/**
* A buffer cell containing a value, ready to receive (o,r) from the right.
*/
- def Cl(i: Chan[String], l: MetaChan,
+ def Cl(i: Chan[String], l: MetaChan,
o: Chan[String], r: MetaChan, content: String): Unit =
choice (
o(content) * (Bl(i,l,o,r)),
i * (inp => Dl(i,l,o,r,content, inp)),
- r * ( { case Pair(newo, newr) => Cl(i,l,newo,newr,content) })
+ r * ( { case (newo, newr) => Cl(i,l,newo,newr,content) })
)
/**
diff --git a/docs/examples/pilib/handover.scala b/docs/examples/pilib/handover.scala
index c9b6156c2c..4e9a5670a0 100644
--- a/docs/examples/pilib/handover.scala
+++ b/docs/examples/pilib/handover.scala
@@ -13,14 +13,14 @@ object handoverRecursive {
* Recursive type for channels that carry a channel "unit" and
* an object of the type we define.
*/
- class Switch extends Chan[Pair[Chan[unit], Switch]]
+ class Switch extends Chan[Tuple2[Chan[unit], Switch]]
/**
* Car.
*/
def Car(talk: Chan[unit], switch: Switch): unit =
choice (
- switch * ({ case Pair(t,s) => Car(t, s) }),
+ switch * ({ case (t,s) => Car(t, s) }),
talk(()) * ( {
Thread.sleep(1 + random.nextInt(1000));
System.out.println("Car emitted a message.");
@@ -32,20 +32,20 @@ object handoverRecursive {
* Control center.
*/
def Control(talk1: Chan[unit], switch1: Switch,
- gain1: Switch, lose1: Switch,
+ gain1: Switch, lose1: Switch,
talk2: Chan[unit], switch2: Switch,
gain2: Switch, lose2: Switch): unit
= {
def Control1: unit= {
Thread.sleep(1 + random.nextInt(1000));
- lose1.write(Pair(talk2, switch2));
- gain2.write(Pair(talk2, switch2));
+ lose1.write((talk2, switch2));
+ gain2.write((talk2, switch2));
Control2
}
def Control2: unit = {
Thread.sleep(1 + random.nextInt(1000));
- lose2.write(Pair(talk1, switch1));
- gain1.write(Pair(talk1, switch1));
+ lose2.write((talk1, switch1));
+ gain1.write((talk1, switch1));
Control1
}
Control1
@@ -62,8 +62,8 @@ object handoverRecursive {
System.out.println(id + " received a message.")
ActiveTransmitter(id, talk, switch, gain, lose)
}),
- lose * ({ case Pair(t, s) => {
- switch.write(Pair(t, s))
+ lose * ({ case (t, s) => {
+ switch.write((t, s))
IdleTransmitter(id, gain, lose)
}})
);
@@ -72,7 +72,7 @@ object handoverRecursive {
* Idle transmitter.
*/
def IdleTransmitter(id: String, gain: Switch, lose: Switch): unit = {
- val Pair(t, s) = gain.read;
+ val (t, s) = gain.read;
ActiveTransmitter(id, t, s, gain, lose)
}
@@ -108,7 +108,7 @@ object handoverCast {
def Car(talk: Chan[Any], switch: Chan[Any]): unit =
choice (
switch * (o => {
- val Pair(t,s) = o.asInstanceOf[Pair[Chan[Any],Chan[Any]]];
+ val (t,s) = o.asInstanceOf[Tuple2[Chan[Any],Chan[Any]]];
Car(t, s)
}),
talk(()) * ( {
@@ -122,20 +122,20 @@ object handoverCast {
* Control center.
*/
def Control(talk1: Chan[Any], switch1: Chan[Any],
- gain1: Chan[Any], lose1: Chan[Any],
+ gain1: Chan[Any], lose1: Chan[Any],
talk2: Chan[Any], switch2: Chan[Any],
gain2: Chan[Any], lose2: Chan[Any]): unit
= {
def Control1: unit = {
Thread.sleep(1 + random.nextInt(1000));
- lose1.write(Pair(talk2, switch2));
- gain2.write(Pair(talk2, switch2));
+ lose1.write((talk2, switch2));
+ gain2.write((talk2, switch2));
Control2
}
def Control2: unit = {
Thread.sleep(1 + random.nextInt(1000));
- lose2.write(Pair(talk1, switch1));
- gain1.write(Pair(talk1, switch1));
+ lose2.write((talk1, switch1));
+ gain1.write((talk1, switch1));
Control1
}
Control1
@@ -153,8 +153,8 @@ object handoverCast {
ActiveTransmitter(id, talk, switch, gain, lose)
}),
lose * (o => {
- val Pair(t, s) = o.asInstanceOf[Pair[Chan[Any],Chan[Any]]]
- switch.write(Pair(t, s))
+ val (t, s) = o.asInstanceOf[Tuple2[Chan[Any],Chan[Any]]]
+ switch.write((t, s))
IdleTransmitter(id, gain, lose)
})
)
@@ -163,7 +163,7 @@ object handoverCast {
* Idle transmitter.
*/
def IdleTransmitter(id: String, gain: Chan[Any], lose: Chan[Any]): unit = {
- val Pair(t, s) = gain.read.asInstanceOf[Pair[Chan[Any],Chan[Any]]]
+ val (t, s) = gain.read.asInstanceOf[Tuple2[Chan[Any],Chan[Any]]]
ActiveTransmitter(id, t, s, gain, lose)
}
diff --git a/docs/examples/pilib/piNat.scala b/docs/examples/pilib/piNat.scala
index a1a0e682e1..c6d9bdaf5c 100644
--- a/docs/examples/pilib/piNat.scala
+++ b/docs/examples/pilib/piNat.scala
@@ -4,23 +4,23 @@ import scala.concurrent.pilib._
/** Church encoding of naturals in the Pi-calculus */
object piNat extends Application {
-
+
/** Locations of Pi-calculus natural */
- class NatChan extends Chan[Triple[Chan[Unit], Chan[NatChan], Chan[NatChan]]]
+ class NatChan extends Chan[Tuple3[Chan[Unit], Chan[NatChan], Chan[NatChan]]]
/** Zero */
def Z(l: NatChan): Unit = choice (
- l * { case Triple(z, sd, d) => z.write(()) }
+ l * { case (z, sd, d) => z.write(()) }
)
/** Successor of Double */
def SD(n: NatChan, l: NatChan): Unit = choice (
- l * { case Triple(z, sd, d) => sd.write(n) }
+ l * { case (z, sd, d) => sd.write(n) }
)
/** Double */
def D(n: NatChan, l: NatChan): Unit = choice (
- l * { case Triple(z, sd, d) => d.write(n) }
+ l * { case (z, sd, d) => d.write(n) }
)
/** Make "l" a location representing the natural "n" */
@@ -34,7 +34,7 @@ object piNat extends Application {
val z = new Chan[Unit]
val sd = new Chan[NatChan]
val d = new Chan[NatChan]
- spawn < m.write(Triple(z, sd, d)) >;
+ spawn < m.write((z, sd, d)) >;
choice (
z * { x => make(1, n) },
sd * { m1 => { val n1 = new NatChan; spawn < D(n1, n) >; Succ(m1, n1) } },
@@ -47,7 +47,7 @@ object piNat extends Application {
val z = new Chan[Unit]
val sd = new Chan[NatChan]
val d = new Chan[NatChan]
- spawn < l.write(Triple(z, sd, d)) >;
+ spawn < l.write((z, sd, d)) >;
choice (
z * { x => spawn < Z(m) >; Z(n) },
sd * { l1 => { val m1 = new NatChan; val n1 = new NatChan;
@@ -64,7 +64,7 @@ object piNat extends Application {
val z = new Chan[Unit]
val sd = new Chan[NatChan]
val d = new Chan[NatChan]
- spawn < n.write(Triple(z, sd, d)) >;
+ spawn < n.write((z, sd, d)) >;
choice (
z * { x => 0 },
sd * { n1 => 2 * value(n1) + 1 },
diff --git a/docs/examples/typeinf.scala b/docs/examples/typeinf.scala
index d4bc8bf3e1..ac6cc35f6b 100644
--- a/docs/examples/typeinf.scala
+++ b/docs/examples/typeinf.scala
@@ -53,11 +53,11 @@ object typeInfer {
(emptySubst /: tyvars) ((s, tv) => s.extend(tv, newTyvar())) (tpe)
}
- type Env = List[Pair[String, TypeScheme]]
+ type Env = List[Tuple2[String, TypeScheme]]
def lookup(env: Env, x: String): TypeScheme = env match {
case List() => null
- case Pair(y, t) :: env1 => if (x == y) t else lookup(env1, x)
+ case (y, t) :: env1 => if (x == y) t else lookup(env1, x)
}
def gen(env: Env, t: Type): TypeScheme =
@@ -69,22 +69,22 @@ object typeInfer {
case Tycon(k, ts) => (List[Tyvar]() /: ts) ((tvs, t) => tvs union tyvars(t))
}
- def tyvars(ts: TypeScheme): List[Tyvar] =
+ def tyvars(ts: TypeScheme): List[Tyvar] =
tyvars(ts.tpe) diff ts.tyvars;
def tyvars(env: Env): List[Tyvar] =
(List[Tyvar]() /: env) ((tvs, nt) => tvs union tyvars(nt._2))
- def mgu(t: Type, u: Type, s: Subst): Subst = Pair(s(t), s(u)) match {
- case Pair(Tyvar(a), Tyvar(b)) if (a == b) =>
+ def mgu(t: Type, u: Type, s: Subst): Subst = (s(t), s(u)) match {
+ case (Tyvar(a), Tyvar(b)) if (a == b) =>
s
- case Pair(Tyvar(a), _) if !(tyvars(u) contains a) =>
+ case (Tyvar(a), _) if !(tyvars(u) contains a) =>
s.extend(Tyvar(a), u)
- case Pair(_, Tyvar(a)) =>
+ case (_, Tyvar(a)) =>
mgu(u, t, s)
- case Pair(Arrow(t1, t2), Arrow(u1, u2)) =>
+ case (Arrow(t1, t2), Arrow(u1, u2)) =>
mgu(t1, u1, mgu(t2, u2, s))
- case Pair(Tycon(k1, ts), Tycon(k2, us)) if (k1 == k2) =>
+ case (Tycon(k1, ts), Tycon(k2, us)) if (k1 == k2) =>
(s /: (ts zip us)) ((s, tu) => mgu(tu._1, tu._2, s))
case _ =>
throw new TypeError("cannot unify " + s(t) + " with " + s(u))
@@ -103,7 +103,7 @@ object typeInfer {
case Lam(x, e1) =>
val a, b = newTyvar()
val s1 = mgu(t, Arrow(a, b), s)
- val env1 = Pair(x, TypeScheme(List(), a)) :: env
+ val env1 = (x, TypeScheme(List(), a)) :: env
tp(env1, e1, b, s1)
case App(e1, e2) =>
@@ -114,7 +114,7 @@ object typeInfer {
case Let(x, e1, e2) =>
val a = newTyvar()
val s1 = tp(env, e1, a, s)
- tp(Pair(x, gen(env, s1(a))) :: env, e2, t, s1)
+ tp((x, gen(env, s1(a))) :: env, e2, t, s1)
}
}
var current: Term = null
@@ -134,18 +134,18 @@ object typeInfer {
private val a = typeInfer.newTyvar()
val env = List(
/*
- Pair("true", gen(booleanType)),
- Pair("false", gen(booleanType)),
- Pair("if", gen(Arrow(booleanType, Arrow(a, Arrow(a, a))))),
- Pair("zero", gen(intType)),
- Pair("succ", gen(Arrow(intType, intType))),
- Pair("nil", gen(listType(a))),
- Pair("cons", gen(Arrow(a, Arrow(listType(a), listType(a))))),
- Pair("isEmpty", gen(Arrow(listType(a), booleanType))),
- Pair("head", gen(Arrow(listType(a), a))),
- Pair("tail", gen(Arrow(listType(a), listType(a)))),
+ ("true", gen(booleanType)),
+ ("false", gen(booleanType)),
+ ("if", gen(Arrow(booleanType, Arrow(a, Arrow(a, a))))),
+ ("zero", gen(intType)),
+ ("succ", gen(Arrow(intType, intType))),
+ ("nil", gen(listType(a))),
+ ("cons", gen(Arrow(a, Arrow(listType(a), listType(a))))),
+ ("isEmpty", gen(Arrow(listType(a), booleanType))),
+ ("head", gen(Arrow(listType(a), a))),
+ ("tail", gen(Arrow(listType(a), listType(a)))),
*/
- Pair("fix", gen(Arrow(Arrow(a, a), a)))
+ ("fix", gen(Arrow(Arrow(a, a), a)))
)
}
@@ -181,7 +181,7 @@ object typeInfer {
yield Lam(x, t): Term )
|||
( for (
- letid <- id if letid == "let";
+ letid <- id if letid == "let";
x <- ident;
_ <- wschr('=');
t <- term;
@@ -220,7 +220,7 @@ object typeInfer {
val input = 0
def any = new Parser[char] {
def apply(in: int): Parser[char]#Result =
- if (in < s.length()) Some(Pair(s charAt in, in + 1)) else None
+ if (in < s.length()) Some((s charAt in, in + 1)) else None
}
}
@@ -239,7 +239,7 @@ object typeInfer {
if (args.length == 1) {
val ps = new ParseString(args(0)) with MiniMLParsers
ps.all(ps.input) match {
- case Some(Pair(term, _)) =>
+ case Some((term, _)) =>
"" + term + ": " + showType(term)
case None =>
"syntax error"
diff --git a/src/actors/scala/actors/Future.scala b/src/actors/scala/actors/Future.scala
index 9d123cb2d5..4421c7a07a 100644
--- a/src/actors/scala/actors/Future.scala
+++ b/src/actors/scala/actors/Future.scala
@@ -180,17 +180,17 @@ object Futures {
var cnt = 0
val mappedFts = fts.map(ft =>
- Pair({cnt+=1; cnt-1}, ft))
+ ({cnt+=1; cnt-1}, ft))
- val unsetFts = mappedFts.filter((p: Pair[Int, Future[Any]]) => {
+ val unsetFts = mappedFts.filter((p: Tuple2[Int, Future[Any]]) => {
if (p._2.isSet) { resultsMap(p._1) = Some(p._2()); false }
else { resultsMap(p._1) = None; true }
})
- val partFuns = unsetFts.map((p: Pair[Int, Future[Any]]) => {
+ val partFuns = unsetFts.map((p: Tuple2[Int, Future[Any]]) => {
val FutCh = p._2.inputChannel
- val singleCase: PartialFunction[Any, Pair[Int, Any]] = {
- case FutCh ! any => Pair(p._1, any)
+ val singleCase: PartialFunction[Any, Tuple2[Int, Any]] = {
+ case FutCh ! any => (p._1, any)
}
singleCase
})
@@ -201,7 +201,7 @@ object Futures {
}
Actor.timer.schedule(timerTask, timeout)
- def awaitWith(partFuns: Seq[PartialFunction[Any, Pair[Int, Any]]]) {
+ def awaitWith(partFuns: Seq[PartialFunction[Any, Tuple2[Int, Any]]]) {
val reaction: PartialFunction[Any, Unit] = new PartialFunction[Any, Unit] {
def isDefinedAt(msg: Any) = msg match {
case TIMEOUT => true
@@ -212,7 +212,7 @@ object Futures {
case _ => {
val pfOpt = partFuns find (_ isDefinedAt msg)
val pf = pfOpt.get // succeeds always
- val Pair(idx, subres) = pf(msg)
+ val (idx, subres) = pf(msg)
resultsMap(idx) = Some(subres)
val partFunsRest = partFuns filter (_ != pf)
diff --git a/src/actors/scala/actors/remote/NetKernel.scala b/src/actors/scala/actors/remote/NetKernel.scala
index 4795ff3eb6..57d7af6d26 100644
--- a/src/actors/scala/actors/remote/NetKernel.scala
+++ b/src/actors/scala/actors/remote/NetKernel.scala
@@ -43,8 +43,8 @@ private[remote] class NetKernel(service: Service) {
private val names = new mutable.HashMap[OutputChannel[Any], Symbol]
def register(name: Symbol, a: OutputChannel[Any]): Unit = synchronized {
- actors += Pair(name, a)
- names += Pair(a, name)
+ actors(name) = a
+ names(a) = name
}
def getOrCreateName(from: OutputChannel[Any]) = names.get(from) match {
@@ -79,7 +79,7 @@ private[remote] class NetKernel(service: Service) {
def createProxy(node: Node, sym: Symbol): Proxy = {
val p = new Proxy(node, sym, this)
- proxies += Pair((node, sym), p)
+ proxies((node, sym)) = p
p
}
@@ -99,7 +99,7 @@ private[remote] class NetKernel(service: Service) {
proxies.synchronized {
proxies.get((senderNode, senderName)) match {
case Some(senderProxy) => // do nothing
- case None => proxies += Pair((senderNode, senderName), p)
+ case None => proxies((senderNode, senderName)) = p
}
}
diff --git a/src/actors/scala/actors/remote/Proxy.scala b/src/actors/scala/actors/remote/Proxy.scala
index 43a43ac99c..9949b36181 100644
--- a/src/actors/scala/actors/remote/Proxy.scala
+++ b/src/actors/scala/actors/remote/Proxy.scala
@@ -142,7 +142,7 @@ private[remote] class DelegateActor(creator: Proxy, node: Node, name: Symbol, ke
// create a new reply channel...
val replyCh = new Channel[Any](this)
// ...that maps to session
- sessionMap += Pair(replyCh, session)
+ sessionMap(replyCh) = session
// local send
out.send(msg, replyCh)
@@ -178,7 +178,7 @@ private[remote] class DelegateActor(creator: Proxy, node: Node, name: Symbol, ke
// create fresh session ID...
val fresh = FreshNameCreator.newName(node+"@"+name)
// ...that maps to reply channel
- channelMap += Pair(fresh, sender)
+ channelMap(fresh) = sender
kernel.forward(sender, node, name, msg, fresh)
} else {
kernel.forward(sender, node, name, msg, 'nosession)
diff --git a/src/actors/scala/actors/remote/RemoteActor.scala b/src/actors/scala/actors/remote/RemoteActor.scala
index 799076a01f..2daf9ceb43 100644
--- a/src/actors/scala/actors/remote/RemoteActor.scala
+++ b/src/actors/scala/actors/remote/RemoteActor.scala
@@ -64,7 +64,7 @@ object RemoteActor {
val serv = TcpService(port, cl)
val kern = serv.kernel
val s = Actor.self(Scheduler)
- kernels += Pair(s, kern)
+ kernels(s) = kern
s.onTerminate {
Debug.info("alive actor "+s+" terminated")
@@ -90,7 +90,7 @@ object RemoteActor {
val kernel = kernels.get(Actor.self(Scheduler)) match {
case None =>
val serv = TcpService(TcpService.generatePort, cl)
- kernels += Pair(Actor.self(Scheduler), serv.kernel)
+ kernels(Actor.self(Scheduler)) = serv.kernel
serv.kernel
case Some(k) =>
k
diff --git a/src/actors/scala/actors/remote/TcpService.scala b/src/actors/scala/actors/remote/TcpService.scala
index 75e36b2738..69e5c46c52 100644
--- a/src/actors/scala/actors/remote/TcpService.scala
+++ b/src/actors/scala/actors/remote/TcpService.scala
@@ -35,7 +35,7 @@ object TcpService {
service
case None =>
val service = new TcpService(port, cl)
- ports += Pair(port, service)
+ ports(port) = service
service.start()
Debug.info("created service at "+service.node)
service
@@ -106,9 +106,9 @@ class TcpService(port: Int, cl: ClassLoader) extends Thread with Service {
// when remote net kernel comes up
(pendingSends.get(node): @unchecked) match {
case None =>
- pendingSends += Pair(node, List(data))
+ pendingSends(node) = List(data)
case Some(msgs) if msgs.length < TcpService.BufSize =>
- pendingSends += Pair(node, data :: msgs)
+ pendingSends(node) = data :: msgs
}
}
@@ -183,7 +183,7 @@ class TcpService(port: Int, cl: ClassLoader) extends Thread with Service {
new mutable.HashMap[Node, TcpServiceWorker]
private[actors] def addConnection(node: Node, worker: TcpServiceWorker) = synchronized {
- connections += Pair(node, worker)
+ connections(node) = worker
}
def getConnection(n: Node) = synchronized {
diff --git a/src/compiler/scala/tools/ant/ScalaTool.scala b/src/compiler/scala/tools/ant/ScalaTool.scala
index e7ac53c8fb..bb6a933d3f 100644
--- a/src/compiler/scala/tools/ant/ScalaTool.scala
+++ b/src/compiler/scala/tools/ant/ScalaTool.scala
@@ -139,7 +139,7 @@ class ScalaTool extends ScalaMatchingTask {
val st = s.trim
val stArray = st.split("=", 2)
if (stArray.length == 2) {
- if (input != "") List(Pair(stArray(0), stArray(1))) else Nil
+ if (input != "") List((stArray(0), stArray(1))) else Nil
}
else
buildError("Property " + st + " is not formatted properly.")
@@ -170,7 +170,7 @@ class ScalaTool extends ScalaMatchingTask {
private def getProperties: String =
properties.map({
- case Pair(name,value) => "-D" + name + "=\"" + value + "\""
+ case (name,value) => "-D" + name + "=\"" + value + "\""
}).mkString("", " ", "")
/*============================================================================*\
diff --git a/src/compiler/scala/tools/ant/sabbus/Compilers.scala b/src/compiler/scala/tools/ant/sabbus/Compilers.scala
index b1994233e8..a0aad49f20 100644
--- a/src/compiler/scala/tools/ant/sabbus/Compilers.scala
+++ b/src/compiler/scala/tools/ant/sabbus/Compilers.scala
@@ -27,7 +27,7 @@ object Compilers extends scala.collection.DefaultMap[String, Compiler] {
if (debug) println("Making compiler " + id)
if (debug) println(" memory before: " + freeMemoryString)
val comp = new Compiler(classpath, settings)
- container += Pair(id, comp)
+ container(id) = comp
if (debug) println(" memory after: " + freeMemoryString)
comp
}
diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala
index 60f7857d0c..939641c3eb 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala
@@ -69,7 +69,7 @@ abstract class Liveness {
case STORE_LOCAL(local) if (!genSet(local)) => killSet = killSet + local
case _ => ()
}
- Pair(genSet, killSet)
+ (genSet, killSet)
}
override def run() {
diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala
index 7a53293384..f10d7cdc40 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala
@@ -418,7 +418,7 @@ abstract class TypeFlowAnalysis {
!blackballed(concreteMethod)
}
if(isCandidate) {
- remainingCALLs += Pair(cm, CallsiteInfo(b, receiver, result.stack.length, concreteMethod))
+ remainingCALLs(cm) = CallsiteInfo(b, receiver, result.stack.length, concreteMethod)
} else {
remainingCALLs.remove(cm)
isOnWatchlist.remove(cm)
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala
index c166b0bb7e..4f9f4c9e31 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala
@@ -741,13 +741,13 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
var flatKeys: List[Int] = Nil
var targets: List[asm.Label] = Nil
var default: asm.Label = null
- var switchBlocks: List[Pair[asm.Label, Tree]] = Nil
+ var switchBlocks: List[Tuple2[asm.Label, Tree]] = Nil
// collect switch blocks and their keys, but don't emit yet any switch-block.
for (caze @ CaseDef(pat, guard, body) <- tree.cases) {
assert(guard == EmptyTree, guard)
val switchBlockPoint = new asm.Label
- switchBlocks ::= Pair(switchBlockPoint, body)
+ switchBlocks ::= (switchBlockPoint, body)
pat match {
case Literal(value) =>
flatKeys ::= value.intValue
@@ -772,7 +772,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
// emit switch-blocks.
val postMatch = new asm.Label
for (sb <- switchBlocks.reverse) {
- val Pair(caseLabel, caseBody) = sb
+ val (caseLabel, caseBody) = sb
markProgramPoint(caseLabel)
genLoad(caseBody, generatedType)
bc goTo postMatch
@@ -790,7 +790,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
genLoad(expr, expectedType)
val end = currProgramPoint()
if (emitVars) { // add entries to LocalVariableTable JVM attribute
- for (Pair(sym, start) <- varsInScope.reverse) { emitLocalVarScope(sym, start, end) }
+ for ((sym, start) <- varsInScope.reverse) { emitLocalVarScope(sym, start, end) }
}
varsInScope = savedScope
}
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala
index c22ced26a5..64ed094a47 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala
@@ -112,7 +112,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters {
val ta = exemplars.get(a)
val tb = exemplars.get(b)
- val res = Pair(ta.isInterface, tb.isInterface) match {
+ val res = (ta.isInterface, tb.isInterface) match {
case (true, true) =>
// exercised by test/files/run/t4761.scala
if (tb.isSubtypeOf(ta.c)) ta.c
@@ -759,7 +759,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters {
def emitParamAnnotations(jmethod: asm.MethodVisitor, pannotss: List[List[AnnotationInfo]]) {
val annotationss = pannotss map (_ filter shouldEmitAnnotation)
if (annotationss forall (_.isEmpty)) return
- for (Pair(annots, idx) <- annotationss.zipWithIndex;
+ for ((annots, idx) <- annotationss.zipWithIndex;
annot <- annots) {
val AnnotationInfo(typ, args, assocs) = annot
assert(args.isEmpty, args)
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeSkelBuilder.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeSkelBuilder.scala
index 5fe03624cf..c921d11d00 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeSkelBuilder.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeSkelBuilder.scala
@@ -436,7 +436,7 @@ abstract class BCodeSkelBuilder extends BCodeHelpers {
var labelDef: scala.collection.Map[Symbol, LabelDef] = null// (LabelDef-sym -> LabelDef)
// bookkeeping the scopes of non-synthetic local vars, to emit debug info (`emitVars`).
- var varsInScope: List[Pair[Symbol, asm.Label]] = null // (local-var-sym -> start-of-scope)
+ var varsInScope: List[Tuple2[Symbol, asm.Label]] = null // (local-var-sym -> start-of-scope)
// helpers around program-points.
def lastInsn: asm.tree.AbstractInsnNode = {
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeTypes.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeTypes.scala
index 916d118b6e..5be5abd895 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeTypes.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeTypes.scala
@@ -90,11 +90,11 @@ abstract class BCodeTypes extends BCodeIdiomatic {
)
boxResultType =
- for(Pair(csym, msym) <- currentRun.runDefinitions.boxMethod)
+ for((csym, msym) <- currentRun.runDefinitions.boxMethod)
yield (msym -> classLiteral(primitiveTypeMap(csym)))
unboxResultType =
- for(Pair(csym, msym) <- currentRun.runDefinitions.unboxMethod)
+ for((csym, msym) <- currentRun.runDefinitions.unboxMethod)
yield (msym -> primitiveTypeMap(csym))
// boxed classes are looked up in the `exemplars` map by jvmWiseLUB().
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala
index 5e885fdd04..217d2b6835 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala
@@ -335,7 +335,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM {
assert(a.isClass)
assert(b.isClass)
- val res = Pair(a.isInterface, b.isInterface) match {
+ val res = (a.isInterface, b.isInterface) match {
case (true, true) =>
global.lub(List(a.tpe, b.tpe)).typeSymbol // TODO assert == firstCommonSuffix of resp. parents
case (true, false) =>
@@ -1014,7 +1014,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM {
def emitParamAnnotations(jmethod: asm.MethodVisitor, pannotss: List[List[AnnotationInfo]]) {
val annotationss = pannotss map (_ filter shouldEmitAnnotation)
if (annotationss forall (_.isEmpty)) return
- for (Pair(annots, idx) <- annotationss.zipWithIndex;
+ for ((annots, idx) <- annotationss.zipWithIndex;
annot <- annots) {
val AnnotationInfo(typ, args, assocs) = annot
assert(args.isEmpty, args)
@@ -2156,7 +2156,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM {
def getMerged(): scala.collection.Map[Local, List[Interval]] = {
// TODO should but isn't: unbalanced start(s) of scope(s)
- val shouldBeEmpty = pending filter { p => val Pair(_, st) = p; st.nonEmpty }
+ val shouldBeEmpty = pending filter { p => val (_, st) = p; st.nonEmpty }
val merged = mutable.Map[Local, List[Interval]]()
def addToMerged(lv: Local, start: Label, end: Label) {
val intv = Interval(start, end)
@@ -2169,7 +2169,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM {
(b) take the latest end (onePastLast if none available)
(c) merge the thus made-up interval
*/
- for(Pair(k, st) <- shouldBeEmpty) {
+ for((k, st) <- shouldBeEmpty) {
var start = st.toList.sortBy(_.getOffset).head
if(merged.isDefinedAt(k)) {
val balancedStart = merged(k).head.lstart
@@ -2206,25 +2206,25 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM {
}
// adding non-param locals
var anonCounter = 0
- var fltnd: List[Triple[String, Local, Interval]] = Nil
- for(Pair(local, ranges) <- scoping.getMerged()) {
+ var fltnd: List[Tuple3[String, Local, Interval]] = Nil
+ for((local, ranges) <- scoping.getMerged()) {
var name = javaName(local.sym)
if (name == null) {
anonCounter += 1
name = "<anon" + anonCounter + ">"
}
for(intrvl <- ranges) {
- fltnd ::= Triple(name, local, intrvl)
+ fltnd ::= (name, local, intrvl)
}
}
// quest for deterministic output that Map.toList doesn't provide (so that ant test.stability doesn't complain).
val srtd = fltnd.sortBy { kr =>
- val Triple(name: String, _, intrvl: Interval) = kr
+ val (name: String, _, intrvl: Interval) = kr
- Triple(intrvl.start, intrvl.end - intrvl.start, name) // ie sort by (start, length, name)
+ (intrvl.start, intrvl.end - intrvl.start, name) // ie sort by (start, length, name)
}
- for(Triple(name, local, Interval(start, end)) <- srtd) {
+ for((name, local, Interval(start, end)) <- srtd) {
jmethod.visitLocalVariable(name, descriptor(local.kind), null, start, end, indexOf(local))
}
// "There may be no more than one LocalVariableTable attribute per local variable in the Code attribute"
diff --git a/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala b/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala
index 0cfcea87f8..0f317422ac 100644
--- a/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala
+++ b/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala
@@ -119,7 +119,7 @@ abstract class DeadCodeElimination extends SubComponent {
m foreachBlock { bb =>
useful(bb) = new mutable.BitSet(bb.size)
var rd = rdef.in(bb)
- for (Pair(i, idx) <- bb.toList.zipWithIndex) {
+ for ((i, idx) <- bb.toList.zipWithIndex) {
// utility for adding to worklist
def moveToWorkList() = moveToWorkListIf(cond = true)
@@ -137,7 +137,7 @@ abstract class DeadCodeElimination extends SubComponent {
i match {
case LOAD_LOCAL(_) =>
- defs = defs + Pair(((bb, idx)), rd.vars)
+ defs = defs + (((bb, idx), rd.vars))
moveToWorkListIf(cond = false)
case STORE_LOCAL(l) =>
@@ -350,7 +350,7 @@ abstract class DeadCodeElimination extends SubComponent {
val oldInstr = bb.toList
bb.open()
bb.clear()
- for (Pair(i, idx) <- oldInstr.zipWithIndex) {
+ for ((i, idx) <- oldInstr.zipWithIndex) {
if (useful(bb)(idx)) {
debuglog(" * " + i + " is useful")
bb.emit(i, i.pos)
diff --git a/src/compiler/scala/tools/nsc/plugins/Plugin.scala b/src/compiler/scala/tools/nsc/plugins/Plugin.scala
index 1578caff26..d194c095f8 100644
--- a/src/compiler/scala/tools/nsc/plugins/Plugin.scala
+++ b/src/compiler/scala/tools/nsc/plugins/Plugin.scala
@@ -144,7 +144,7 @@ object Plugin {
// (j, Try(descriptor))
def required(j: Path) = j -> loadDescriptionFromJar(j)
- type Paired = Pair[Path, Try[PluginDescription]]
+ type Paired = Tuple2[Path, Try[PluginDescription]]
val included: List[Paired] = (dirs flatMap (_ ifDirectory scan)).flatten
val exploded: List[Paired] = jars flatMap (_ ifDirectory explode)
val explicit: List[Paired] = jars flatMap (_ ifFile required)
diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala
index cd96b5182c..8900450fa3 100644
--- a/src/library/scala/Predef.scala
+++ b/src/library/scala/Predef.scala
@@ -26,8 +26,6 @@ import scala.io.ReadStdin
* [[scala.collection.immutable.Set]], and the [[scala.collection.immutable.List]]
* constructors ([[scala.collection.immutable.::]] and
* [[scala.collection.immutable.Nil]]).
- * The types `Pair` (a [[scala.Tuple2]]) and `Triple` (a [[scala.Tuple3]]), with
- * simple constructors, are also provided.
*
* === Console I/O ===
* Predef provides a number of simple functions for console I/O, such as
@@ -230,13 +228,17 @@ object Predef extends LowPriorityImplicits with DeprecatedPredef {
// tupling ------------------------------------------------------------
+ @deprecated("Use built-in tuple syntax or Tuple2 instead", "2.11.0")
type Pair[+A, +B] = Tuple2[A, B]
+ @deprecated("Use built-in tuple syntax or Tuple2 instead", "2.11.0")
object Pair {
def apply[A, B](x: A, y: B) = Tuple2(x, y)
def unapply[A, B](x: Tuple2[A, B]): Option[Tuple2[A, B]] = Some(x)
}
+ @deprecated("Use built-in tuple syntax or Tuple3 instead", "2.11.0")
type Triple[+A, +B, +C] = Tuple3[A, B, C]
+ @deprecated("Use built-in tuple syntax or Tuple3 instead", "2.11.0")
object Triple {
def apply[A, B, C](x: A, y: B, z: C) = Tuple3(x, y, z)
def unapply[A, B, C](x: Tuple3[A, B, C]): Option[Tuple3[A, B, C]] = Some(x)
diff --git a/src/repl/scala/tools/nsc/interpreter/JavapClass.scala b/src/repl/scala/tools/nsc/interpreter/JavapClass.scala
index 50c90968af..496d5face1 100644
--- a/src/repl/scala/tools/nsc/interpreter/JavapClass.scala
+++ b/src/repl/scala/tools/nsc/interpreter/JavapClass.scala
@@ -180,7 +180,7 @@ class JavapClass(
/** Base class for javap tool adapters for java 6 and 7. */
abstract class JavapTool {
type ByteAry = Array[Byte]
- type Input = Pair[String, Try[ByteAry]]
+ type Input = Tuple2[String, Try[ByteAry]]
/** Run the tool. */
def apply(raw: Boolean, options: Seq[String])(inputs: Seq[Input]): List[JpResult]
diff --git a/src/scaladoc/scala/tools/ant/Scaladoc.scala b/src/scaladoc/scala/tools/ant/Scaladoc.scala
index fd6d637212..36a1405b11 100644
--- a/src/scaladoc/scala/tools/ant/Scaladoc.scala
+++ b/src/scaladoc/scala/tools/ant/Scaladoc.scala
@@ -574,7 +574,7 @@ class Scaladoc extends ScalaMatchingTask {
\*============================================================================*/
/** Initializes settings and source files */
- protected def initialize: Pair[Settings, List[File]] = {
+ protected def initialize: Tuple2[Settings, List[File]] = {
// Tests if all mandatory attributes are set and valid.
if (origin.isEmpty) buildError("Attribute 'srcdir' is not set.")
if (getOrigin.isEmpty) buildError("Attribute 'srcdir' is not set.")
@@ -660,14 +660,14 @@ class Scaladoc extends ScalaMatchingTask {
log("Scaladoc params = '" + addParams + "'", Project.MSG_DEBUG)
docSettings processArgumentString addParams
- Pair(docSettings, sourceFiles)
+ (docSettings, sourceFiles)
}
def safeBuildError(message: String): Unit = if (nofail) log(message) else buildError(message)
/** Performs the compilation. */
override def execute() = {
- val Pair(docSettings, sourceFiles) = initialize
+ val (docSettings, sourceFiles) = initialize
val reporter = new ConsoleReporter(docSettings)
try {
val docProcessor = new scala.tools.nsc.doc.DocFactory(reporter, docSettings)
diff --git a/src/scalap/scala/tools/scalap/Arguments.scala b/src/scalap/scala/tools/scalap/Arguments.scala
index 41346d13c0..cb0a92b6b3 100644
--- a/src/scalap/scala/tools/scalap/Arguments.scala
+++ b/src/scalap/scala/tools/scalap/Arguments.scala
@@ -46,8 +46,8 @@ object Arguments {
}
def parseBinding(str: String, separator: Char): (String, String) = (str indexOf separator) match {
- case -1 => argumentError("missing '" + separator + "' in binding '" + str + "'") ; Pair("", "")
- case idx => Pair((str take idx).trim, (str drop (idx + 1)).trim)
+ case -1 => argumentError("missing '" + separator + "' in binding '" + str + "'") ; ("", "")
+ case idx => ((str take idx).trim, (str drop (idx + 1)).trim)
}
def parse(args: Array[String]): Arguments = {
@@ -141,7 +141,7 @@ class Arguments {
if (key.length > 0)
bindings.getOrElseUpdate(tag, new mutable.HashMap)(key) = value
- def addBinding(tag: String, binding: Pair[String, String]): Unit =
+ def addBinding(tag: String, binding: Tuple2[String, String]): Unit =
addBinding(tag, binding._1, binding._2)
def addOther(arg: String): Unit = others += arg
diff --git a/test/disabled/run/lisp.scala b/test/disabled/run/lisp.scala
index 06e68f508a..73f24da757 100644
--- a/test/disabled/run/lisp.scala
+++ b/test/disabled/run/lisp.scala
@@ -12,11 +12,11 @@ class LispTokenizer(s: String) extends Iterator[String] {
while (i < s.length() && s.charAt(i) <= ' ') i += 1
i < s.length()
}
- def next: String =
+ def next: String =
if (hasNext) {
val start = i
if (isDelimiter(s charAt i)) i += 1
- else
+ else
do i = i + 1
while (!isDelimiter(s charAt i))
s.substring(start, i)
@@ -190,10 +190,10 @@ object LispCaseClasses extends Lisp {
def extendEnv(env: Environment,
ps: List[String], args: List[Data]): Environment =
- Pair(ps, args) match {
- case Pair(List(), List()) =>
+ (ps, args) match {
+ case (List(), List()) =>
env
- case Pair(p :: ps1, arg :: args1) =>
+ case (p :: ps1, arg :: args1) =>
extendEnv(env.extend(p, arg), ps1, args1)
case _ =>
lispError("wrong number of arguments")
@@ -381,10 +381,10 @@ object LispAny extends Lisp {
def extendEnv(env: Environment,
ps: List[String], args: List[Data]): Environment =
- Pair(ps, args) match {
- case Pair(List(), List()) =>
+ (ps, args) match {
+ case (List(), List()) =>
env
- case Pair(p :: ps1, arg :: args1) =>
+ case (p :: ps1, arg :: args1) =>
extendEnv(env.extend(p, arg), ps1, args1)
case _ =>
lispError("wrong number of arguments")
diff --git a/test/files/jvm/typerep.scala b/test/files/jvm/typerep.scala
index 1d6f0b7907..4f900d98d7 100644
--- a/test/files/jvm/typerep.scala
+++ b/test/files/jvm/typerep.scala
@@ -86,7 +86,7 @@ object testArrays {
object testTuples {
println(getType((3, "abc")))
- println(getType(Triple('a', 'b', "c")))
+ println(getType(('a', 'b', "c")))
println(getType(((3, "abc"), (4, "xyz"))))
println(getType(((Some('b'), 3), (Some('a'), 4))))
//println(getType(((Some('b'), 3), (None, 4))))
diff --git a/test/files/neg/patmatexhaust.scala b/test/files/neg/patmatexhaust.scala
index aa7dac7d7d..f937197829 100644
--- a/test/files/neg/patmatexhaust.scala
+++ b/test/files/neg/patmatexhaust.scala
@@ -22,9 +22,9 @@ class TestSealedExhaustive { // compile only
def ma3(x:Mult) = (x,x) match { // not exhaustive
case (Kult(_), Qult()) => // Kult missing
- //case Pair(Kult(_), Kult(_)) =>
+ //case (Kult(_), Kult(_)) =>
case (Qult(), Kult(_)) => // Qult missing
- //case Pair(Qult(), Qult()) =>
+ //case (Qult(), Qult()) =>
}
def ma3u(x:Mult) = ((x,x) : @unchecked) match { // not exhaustive, but not checked!
diff --git a/test/files/neg/t414.scala b/test/files/neg/t414.scala
index 1662b9a105..86646d13c2 100644
--- a/test/files/neg/t414.scala
+++ b/test/files/neg/t414.scala
@@ -1,5 +1,5 @@
case class Empty[a]() extends IntMap[a];
-case class Node[a](left: IntMap[a], keyVal: Pair[Int, a], right: IntMap[a]) extends IntMap[a];
+case class Node[a](left: IntMap[a], keyVal: Tuple2[Int, a], right: IntMap[a]) extends IntMap[a];
abstract class IntMap[a] {
def lookup(key: Int): a = this match {
case Empty =>
diff --git a/test/files/neg/t5702-neg-bad-and-wild.check b/test/files/neg/t5702-neg-bad-and-wild.check
index ff9e5e5703..a52136dbf8 100644
--- a/test/files/neg/t5702-neg-bad-and-wild.check
+++ b/test/files/neg/t5702-neg-bad-and-wild.check
@@ -23,6 +23,6 @@ t5702-neg-bad-and-wild.scala:23: error: bad simple pattern: bad use of _* (a seq
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 simple pattern: bad use of _* (sequence pattern not allowed)
- val (b, _ * ) = Pair(5,6) // bad use of _* (sequence pattern not allowed)
+ val (b, _ * ) = (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
index 3833a002b1..aadda37da7 100644
--- a/test/files/neg/t5702-neg-bad-and-wild.scala
+++ b/test/files/neg/t5702-neg-bad-and-wild.scala
@@ -21,7 +21,7 @@ object Test {
//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)
+ val (b, _ * ) = (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/t997.scala b/test/files/neg/t997.scala
index e8d10f4317..1198738f24 100644
--- a/test/files/neg/t997.scala
+++ b/test/files/neg/t997.scala
@@ -1,5 +1,5 @@
// An extractor with 2 results
-object Foo { def unapply(x : String) = Some(Pair(x, x)) }
+object Foo { def unapply(x : String) = Some((x, x)) }
object Test extends App {
diff --git a/test/files/neg/wellkinded_wrongarity.check b/test/files/neg/wellkinded_wrongarity.check
index 1dc38db5c1..b9f033b453 100644
--- a/test/files/neg/wellkinded_wrongarity.check
+++ b/test/files/neg/wellkinded_wrongarity.check
@@ -1,4 +1,4 @@
-wellkinded_wrongarity.scala:5: error: Pair takes two type parameters, expected: one
-object mp extends Monad[Pair]
+wellkinded_wrongarity.scala:5: error: Tuple2 takes two type parameters, expected: one
+object mp extends Monad[Tuple2]
^
one error found
diff --git a/test/files/neg/wellkinded_wrongarity.scala b/test/files/neg/wellkinded_wrongarity.scala
index 2bb0e2ce8a..39c7601d53 100644
--- a/test/files/neg/wellkinded_wrongarity.scala
+++ b/test/files/neg/wellkinded_wrongarity.scala
@@ -2,4 +2,4 @@
class Monad[m[x]]
-object mp extends Monad[Pair]
+object mp extends Monad[Tuple2]
diff --git a/test/files/pos/bounds.scala b/test/files/pos/bounds.scala
index cfea4626c3..26bc84a1b9 100644
--- a/test/files/pos/bounds.scala
+++ b/test/files/pos/bounds.scala
@@ -1,11 +1,11 @@
trait Map[A, +C] {
- def ++ [B1 >: C] (kvs: Iterable[Pair[A, B1]]): Map[A, B1] = this
- def ++ [B1 >: C] (kvs: Iterator[Pair[A, B1]]): Map[A, B1] = this
+ def ++ [B1 >: C] (kvs: Iterable[Tuple2[A, B1]]): Map[A, B1] = this
+ def ++ [B1 >: C] (kvs: Iterator[Tuple2[A, B1]]): Map[A, B1] = this
}
class ListMap[A, +B] extends Map[A, B] {}
object ListMap {
def empty[X, Y] = new ListMap[X, Y]
- def apply[A1, B2](elems: Pair[A1, B2]*): Map[A1, B2] = empty[A1,B2].++(elems.iterator)
+ def apply[A1, B2](elems: Tuple2[A1, B2]*): Map[A1, B2] = empty[A1,B2].++(elems.iterator)
}
diff --git a/test/files/pos/patmat.scala b/test/files/pos/patmat.scala
index 4e652b146e..51b879abf2 100644
--- a/test/files/pos/patmat.scala
+++ b/test/files/pos/patmat.scala
@@ -3,8 +3,8 @@
object ZipFun {
//just compilation
- def zipFun[a, b](xs: List[a], ys: List[b]): List[Pair[a, b]] = (Pair(xs, ys): @unchecked) match {
- // !!! case Pair(List(), _), Pair(_, List()) => List()
+ def zipFun[a, b](xs: List[a], ys: List[b]): List[Tuple2[a, b]] = ((xs, ys): @unchecked) match {
+ // !!! case (List(), _), (_, List()) => List()
case (x :: xs1, y :: ys1) => (x, y) :: zipFun(xs1, ys1)
}
}
diff --git a/test/files/pos/spec-doubledef-new.scala b/test/files/pos/spec-doubledef-new.scala
index ad9c6399a5..589ceb33b2 100644
--- a/test/files/pos/spec-doubledef-new.scala
+++ b/test/files/pos/spec-doubledef-new.scala
@@ -19,12 +19,12 @@ abstract class B[T, @specialized(scala.Int) U : TypeTag, @specialized(scala.Int)
val u: U
val v: V
- def f(t: T, v2: V): Pair[U, V] = {
+ def f(t: T, v2: V): Tuple2[U, V] = {
val m: Array[U] = null
if (m.isEmpty) {
- Pair(u, v)
+ (u, v)
} else {
- Pair(u, v2)
+ (u, v2)
}
}
} \ No newline at end of file
diff --git a/test/files/pos/spec-doubledef-old.scala b/test/files/pos/spec-doubledef-old.scala
index 86b0d857d3..bde259e4fa 100644
--- a/test/files/pos/spec-doubledef-old.scala
+++ b/test/files/pos/spec-doubledef-old.scala
@@ -17,12 +17,12 @@ abstract class B[T, @specialized(scala.Int) U : Manifest, @specialized(scala.Int
val u: U
val v: V
- def f(t: T, v2: V): Pair[U, V] = {
+ def f(t: T, v2: V): Tuple2[U, V] = {
val m: Array[U] = null
if (m.isEmpty) {
- Pair(u, v)
+ (u, v)
} else {
- Pair(u, v2)
+ (u, v2)
}
}
}
diff --git a/test/files/pos/t0064.scala b/test/files/pos/t0064.scala
index c2ce4bf6d0..1eeca8dcad 100644
--- a/test/files/pos/t0064.scala
+++ b/test/files/pos/t0064.scala
@@ -1,6 +1,6 @@
object B {
def main(Args:Array[String]) = {
- val Pair(_,x) = Pair(1,2);
+ val (_,x) = (1,2);
x + 1;
}
}
diff --git a/test/files/pos/t247.scala b/test/files/pos/t247.scala
index e976404e61..fdcafeb2c6 100644
--- a/test/files/pos/t247.scala
+++ b/test/files/pos/t247.scala
@@ -16,11 +16,11 @@ class Tree[KEY,Entry](order:Order[KEY]) {
def size =0;
}
-class TreeMap[KEY,VALUE](_factory:TreeMapFactory[KEY]) extends Tree[KEY,Pair[KEY,VALUE]](_factory.order) with scala.collection.DefaultMap[KEY, VALUE] with Map[KEY, VALUE] {
+class TreeMap[KEY,VALUE](_factory:TreeMapFactory[KEY]) extends Tree[KEY,Tuple2[KEY,VALUE]](_factory.order) with scala.collection.DefaultMap[KEY, VALUE] with Map[KEY, VALUE] {
val factory = _factory
val order = _factory.order;
def this(newOrder:Order[KEY]) = this(new TreeMapFactory[KEY](newOrder));
def get(key:KEY) = null;
- def iterator:Iterator[Pair[KEY,VALUE]] = null;
+ def iterator:Iterator[Tuple2[KEY,VALUE]] = null;
override def size = super[Tree].size
}
diff --git a/test/files/pos/t443.scala b/test/files/pos/t443.scala
index 5b5e3ea828..cdaefe9ecd 100644
--- a/test/files/pos/t443.scala
+++ b/test/files/pos/t443.scala
@@ -1,10 +1,10 @@
object Test {
- def lookup(): Option[Pair[String, String]] =
- ((null: Option[Pair[String, String]]) : @unchecked) match {
- case Some(Pair(_, _)) =>
+ def lookup(): Option[Tuple2[String, String]] =
+ ((null: Option[Tuple2[String, String]]) : @unchecked) match {
+ case Some((_, _)) =>
if (true)
- Some(Pair(null, null))
+ Some((null, null))
else
lookup() match {
case Some(_) => Some(null)
diff --git a/test/files/pos/t4579.scala b/test/files/pos/t4579.scala
index 8951ec011f..cd1553f02a 100644
--- a/test/files/pos/t4579.scala
+++ b/test/files/pos/t4579.scala
@@ -190,10 +190,10 @@ object LispCaseClasses extends Lisp {
def extendEnv(env: Environment,
ps: List[String], args: List[Data]): Environment =
- Pair(ps, args) match {
- case Pair(List(), List()) =>
+ (ps, args) match {
+ case (List(), List()) =>
env
- case Pair(p :: ps1, arg :: args1) =>
+ case (p :: ps1, arg :: args1) =>
extendEnv(env.extend(p, arg), ps1, args1)
case _ =>
lispError("wrong number of arguments")
@@ -381,10 +381,10 @@ object LispAny extends Lisp {
def extendEnv(env: Environment,
ps: List[String], args: List[Data]): Environment =
- Pair(ps, args) match {
- case Pair(List(), List()) =>
+ (ps, args) match {
+ case (List(), List()) =>
env
- case Pair(p :: ps1, arg :: args1) =>
+ case (p :: ps1, arg :: args1) =>
extendEnv(env.extend(p, arg), ps1, args1)
case _ =>
lispError("wrong number of arguments")
diff --git a/test/files/pos/t5120.scala b/test/files/pos/t5120.scala
index 6731af14e4..86d4470bd5 100644
--- a/test/files/pos/t5120.scala
+++ b/test/files/pos/t5120.scala
@@ -5,9 +5,9 @@ class Test {
class ScopedKey[T]
class Value[T]
- class Compiled[T](val settings: Seq[Pair[T]])
+ class Compiled[T](val settings: Seq[Tuple2[T]])
- case class Pair[T](k: ScopedKey[T], v: ScopedKey[T])
+ case class Tuple2[T](k: ScopedKey[T], v: ScopedKey[T])
def transform[T](x: T) = x
diff --git a/test/files/pos/tcpoly_bounds1.scala b/test/files/pos/tcpoly_bounds1.scala
index 5874cc664d..63263cb152 100644
--- a/test/files/pos/tcpoly_bounds1.scala
+++ b/test/files/pos/tcpoly_bounds1.scala
@@ -1,7 +1,7 @@
-class Foo[t[x]<: Pair[Int, x]]
+class Foo[t[x]<: Tuple2[Int, x]]
//
-class MyPair[z](a: Int, b: z) extends Pair[Int, z](a,b)
+class MyPair[z](a: Int, b: z) extends Tuple2[Int, z](a,b)
object foo extends Foo[MyPair]
diff --git a/test/files/pos/typealiases.scala b/test/files/pos/typealiases.scala
index d03b521f77..93d1dce4dc 100644
--- a/test/files/pos/typealiases.scala
+++ b/test/files/pos/typealiases.scala
@@ -14,7 +14,7 @@ trait Test[T] {
object main extends Test[Int] {
val pair1 = (1,1)
- implicit def topair(x: Int): Pair[Int, Int] = (x,x)
+ implicit def topair(x: Int): Tuple2[Int, Int] = (x,x)
val pair2: MyPair[Int] = 1
val x: Short = 1
}
diff --git a/test/files/pos/unapplyNeedsMemberType.scala b/test/files/pos/unapplyNeedsMemberType.scala
index b423257e04..3a96e189af 100644
--- a/test/files/pos/unapplyNeedsMemberType.scala
+++ b/test/files/pos/unapplyNeedsMemberType.scala
@@ -19,7 +19,7 @@ class Join[a] extends Gunk[a] {
def append(s1: Seq, s2: Seq): Seq = s1 // mock implementation
def unapply_Cons(s: Any) = s match {
- case App(Cons(x, xs), ys) => Some(Pair(x, append(xs, ys)))
+ case App(Cons(x, xs), ys) => Some((x, append(xs, ys)))
case _ => null
}
}
diff --git a/test/files/pos/valdefs.scala b/test/files/pos/valdefs.scala
index 85ffa132b7..c8f78cd2bf 100644
--- a/test/files/pos/valdefs.scala
+++ b/test/files/pos/valdefs.scala
@@ -11,6 +11,6 @@ object test {
}
abstract class Sub2() extends Base() {
- override val Pair(x, y) = Pair("abc", 2.0);
+ override val (x, y) = ("abc", 2.0);
}
}
diff --git a/test/files/positions/ExcludedPrefix1.scala b/test/files/positions/ExcludedPrefix1.scala
index f3562c37f0..b3182eae78 100644
--- a/test/files/positions/ExcludedPrefix1.scala
+++ b/test/files/positions/ExcludedPrefix1.scala
@@ -35,7 +35,7 @@ object ExcludedPrefix1 {
(i,
j) = (0, 0)
- val Pair(
+ val (
k,
l) = (0, 0)
}
diff --git a/test/files/positions/Overlap4.scala b/test/files/positions/Overlap4.scala
index 0049293954..f54837295b 100644
--- a/test/files/positions/Overlap4.scala
+++ b/test/files/positions/Overlap4.scala
@@ -1,3 +1,3 @@
object Overlap4 {
- val Pair(a, b) = (0, 0)
+ val (a, b) = (0, 0)
}
diff --git a/test/files/positions/Scaladoc7.scala b/test/files/positions/Scaladoc7.scala
index 6175222e3f..0198d4d6ac 100644
--- a/test/files/positions/Scaladoc7.scala
+++ b/test/files/positions/Scaladoc7.scala
@@ -2,5 +2,5 @@ object Scaladoc7 {
/**
* Foo
*/
- val Pair(i, j) = (1, 2)
+ val (i, j) = (1, 2)
}
diff --git a/test/files/presentation/callcc-interpreter.check b/test/files/presentation/callcc-interpreter.check
index f031c52c86..1f868097ca 100644
--- a/test/files/presentation/callcc-interpreter.check
+++ b/test/files/presentation/callcc-interpreter.check
@@ -1,8 +1,8 @@
reload: CallccInterpreter.scala
-askTypeCompletion at CallccInterpreter.scala(51,38)
+askTypeCompletion at CallccInterpreter.scala(51,34)
================================================================================
-[response] askTypeCompletion at (51,38)
+[response] askTypeCompletion at (51,34)
retrieved 59 members
abstract trait Term extends AnyRef
abstract trait Value extends AnyRef
@@ -83,8 +83,8 @@ def showM(m: callccInterpreter.M[callccInterpreter.Value]): String = m.in.apply(
askType at CallccInterpreter.scala(50,30)
================================================================================
[response] askTypeAt (50,30)
-def add(a: callccInterpreter.Value, b: callccInterpreter.Value): callccInterpreter.M[_ >: callccInterpreter.Num with callccInterpreter.Wrong.type <: Product with Serializable with callccInterpreter.Value] = scala.this.Predef.Pair.apply[callccInterpreter.Value, callccInterpreter.Value](a, b) match {
- case scala.this.Predef.Pair.unapply[callccInterpreter.Value, callccInterpreter.Value](<unapply-selector>) <unapply> ((n: Int)callccInterpreter.Num((m @ _)), (n: Int)callccInterpreter.Num((n @ _))) => this.unitM[callccInterpreter.Num](callccInterpreter.this.Num.apply(m.+(n)))
+def add(a: callccInterpreter.Value, b: callccInterpreter.Value): callccInterpreter.M[_ >: callccInterpreter.Num with callccInterpreter.Wrong.type <: Product with Serializable with callccInterpreter.Value] = scala.Tuple2.apply[callccInterpreter.Value, callccInterpreter.Value](a, b) match {
+ case (_1: callccInterpreter.Value, _2: callccInterpreter.Value)(callccInterpreter.Value, callccInterpreter.Value)((n: Int)callccInterpreter.Num((m @ _)), (n: Int)callccInterpreter.Num((n @ _))) => this.unitM[callccInterpreter.Num](callccInterpreter.this.Num.apply(m.+(n)))
case _ => callccInterpreter.this.unitM[callccInterpreter.Wrong.type](callccInterpreter.this.Wrong)
}
================================================================================
diff --git a/test/files/presentation/callcc-interpreter/src/CallccInterpreter.scala b/test/files/presentation/callcc-interpreter/src/CallccInterpreter.scala
index ce3b996b96..d498fe0b17 100644
--- a/test/files/presentation/callcc-interpreter/src/CallccInterpreter.scala
+++ b/test/files/presentation/callcc-interpreter/src/CallccInterpreter.scala
@@ -40,15 +40,15 @@ object callccInterpreter {
override def toString() = "<function>"
}
- type Environment = List[Pair[Name, Value]]
+ type Environment = List[Tuple2[Name, Value]]
def lookup(x: Name, e: Environment): M[Value] = e match {
case List() => unitM(Wrong)
- case Pair(y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
+ case (y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
}
- def add(a: Value, b: Value) /*?*/ = Pair(a, b) match {
- case Pair(Num(m), Num(n)) => this./*!*/unitM(Num(m + n))
+ def add(a: Value, b: Value) /*?*/ = (a, b) match {
+ case (Num(m), Num(n)) => this./*!*/unitM(Num(m + n))
case _ => unitM(Wrong)
}
@@ -60,16 +60,20 @@ object callccInterpreter {
def interp(t: Term, e: Environment): M[Value] = t match {
case Var(x) => lookup(x, e)
case Con(n) => unitM(Num(n))
- case Add(l, r) => for (val a <- interp(l, e);
- val b <- interp(r, e);
- val c <- add(a, b))
- yield c
- case Lam(x, t) => unitM(Fun(a => interp(t, Pair(x, a) :: e)))
- case App(f, t) => for (val a <- interp(f, e);
- val b <- interp(t, e);
- val c <- apply(a, b))
- yield c
- case Ccc(x, t) => callCC(k => interp(t, Pair(x, Fun(k)) :: e))
+ case Add(l, r) =>
+ for {
+ a <- interp(l, e)
+ b <- interp(r, e)
+ c <- add(a, b)
+ } yield c
+ case Lam(x, t) => unitM(Fun(a => interp(t, (x, a) :: e)))
+ case App(f, t) =>
+ for {
+ a <- interp(f, e)
+ b <- interp(t, e)
+ c <- apply(a, b)
+ } yield c
+ case Ccc(x, t) => callCC(k => interp(t, (x, Fun(k)) :: e))
}
def test(t: Term): String = showM(interp(t, List()))
diff --git a/test/files/run/Course-2002-05.scala b/test/files/run/Course-2002-05.scala
index e6764b92c8..80317bc757 100644
--- a/test/files/run/Course-2002-05.scala
+++ b/test/files/run/Course-2002-05.scala
@@ -3,15 +3,15 @@
//############################################################################
object M0 {
- def partition[a](xs: List[a], pred: a => Boolean): Pair[List[a], List[a]] = {
+ def partition[a](xs: List[a], pred: a => Boolean): Tuple2[List[a], List[a]] = {
if (xs.isEmpty)
- Pair(List(),List())
+ (List(),List())
else {
val tailPartition = partition(xs.tail, pred);
if (pred(xs.head))
- Pair(xs.head :: tailPartition._1, tailPartition._2)
+ (xs.head :: tailPartition._1, tailPartition._2)
else
- Pair(tailPartition._1, xs.head :: tailPartition._2)
+ (tailPartition._1, xs.head :: tailPartition._2)
}
}
@@ -49,9 +49,9 @@ object M0 {
//############################################################################
object M1 {
- def partition[a](xs: List[a], pred: a => Boolean): Pair[List[a], List[a]] = {
- xs.foldRight[Pair[List[a], List[a]]](Pair(List(), List())) {
- (x, p) => if (pred (x)) Pair(x :: p._1, p._2) else Pair(p._1, x :: p._2)
+ def partition[a](xs: List[a], pred: a => Boolean): Tuple2[List[a], List[a]] = {
+ xs.foldRight[Tuple2[List[a], List[a]]]((List(), List())) {
+ (x, p) => if (pred (x)) (x :: p._1, p._2) else (p._1, x :: p._2)
}
}
@@ -136,7 +136,7 @@ object M3 {
def adjoinRow(placement: Placement): List[Placement] =
range(1, n)
.filter (column => isSafe(column, placement))
- .map (column => Pair(row, column) :: placement);
+ .map (column => (row, column) :: placement);
placeQueens(row - 1) flatMap adjoinRow
}
diff --git a/test/files/run/Course-2002-06.scala b/test/files/run/Course-2002-06.scala
index e4fb86a966..908a934041 100644
--- a/test/files/run/Course-2002-06.scala
+++ b/test/files/run/Course-2002-06.scala
@@ -55,7 +55,7 @@ abstract class Graphics(_width: Double, _height: Double) {
}
/** Draw a list of segments on the picture.*/
- def drawSegments(frm: Frame)(segments: List[Pair[Vector, Vector]]): Unit =
+ def drawSegments(frm: Frame)(segments: List[Tuple2[Vector, Vector]]): Unit =
if (segments.isEmpty) ()
else {
drawSegment(frm)(segments.head._1, segments.head._2);
diff --git a/test/files/run/Course-2002-07.scala b/test/files/run/Course-2002-07.scala
index 055ff74d81..2d9457653f 100644
--- a/test/files/run/Course-2002-07.scala
+++ b/test/files/run/Course-2002-07.scala
@@ -181,10 +181,10 @@ object M4 {
object M5 {
- def zipFun[a,b](xs:List[a], ys:List[b]):List[Pair[a,b]] = Pair(xs,ys) match {
- case Pair(List(), _) => List()
- case Pair(_, List()) => List()
- case Pair(x :: xs1, y :: ys1) => Pair(x, y) :: zipFun(xs1, ys1)
+ def zipFun[a,b](xs:List[a], ys:List[b]):List[Tuple2[a,b]] = (xs,ys) match {
+ case (List(), _) => List()
+ case (_, List()) => List()
+ case (x :: xs1, y :: ys1) => (x, y) :: zipFun(xs1, ys1)
}
def test_zipFun[a,b](xs: List[a], ys: List[b]) = {
@@ -216,9 +216,9 @@ object M5 {
object M6 {
- def zipFun[a,b](xs:List[a], ys:List[b]):List[Pair[a,b]] = (Pair(xs,ys): @unchecked) match {
- // !!! case Pair(List(), _), Pair(_, List()) => List()
- case Pair(x :: xs1, y :: ys1) => Pair(x, y) :: zipFun(xs1, ys1)
+ def zipFun[a,b](xs:List[a], ys:List[b]):List[Tuple2[a,b]] = ((xs,ys): @unchecked) match {
+ // !!! case (List(), _), (_, List()) => List()
+ case (x :: xs1, y :: ys1) => (x, y) :: zipFun(xs1, ys1)
}
def test_zipFun[a,b](xs: List[a], ys: List[b]) = {
@@ -374,9 +374,9 @@ object M9 {
object MA {
- def lookup[k,v](xs: List[Pair[k,v]], k: k): v = xs match {
+ def lookup[k,v](xs: List[Tuple2[k,v]], k: k): v = xs match {
case List() => sys.error("no value for " + k)
- case Pair(k1,v1) :: xs1 => if (k1 == k) v1 else lookup(xs1, k)
+ case (k1,v1) :: xs1 => if (k1 == k) v1 else lookup(xs1, k)
}
trait Expr {
@@ -437,8 +437,8 @@ object MA {
val g1 = g0 derive x;
Console.println("g (x) = " + g0);
Console.println("g'(x) = " + g1);
- Console.println("g (3) = " + evalvars(List(Pair("x",3)))(g0));
- Console.println("g'(3) = " + evalvars(List(Pair("x",3)))(g1));
+ Console.println("g (3) = " + evalvars(List(("x",3)))(g0));
+ Console.println("g'(3) = " + evalvars(List(("x",3)))(g1));
Console.println;
}
@@ -453,26 +453,26 @@ object Utils {
if (y == 1) x else if (y % 2 == 0) power0(x*x,y/2) else x*power0(x, y-1);
def power(x: Int, y: Int): Int = (x,y) match {
- case Pair(0,0) => sys.error("power(0,0)")
- case Pair(0,_) => 0
- case Pair(1,_) => 1
- case Pair(_,0) => 1
- case Pair(_,1) => x
- case Pair(_,2) => x*x
- case Pair(_,_) => if (y < 0) 1/power0(x,y) else power0(x,y)
+ case (0,0) => sys.error("power(0,0)")
+ case (0,_) => 0
+ case (1,_) => 1
+ case (_,0) => 1
+ case (_,1) => x
+ case (_,2) => x*x
+ case (_,_) => if (y < 0) 1/power0(x,y) else power0(x,y)
}
def lookup(entries: List[(String,Int)], key: String): Int = entries match {
case List() => sys.error("no value for " + key)
- case Pair(k,v) :: _ if (k == key) => v
+ case (k,v) :: _ if (k == key) => v
case _ :: rest => lookup(rest, key)
}
def compare(xs: List[String], ys: List[String]): Int = (xs, ys) match {
- case Pair(List(), List()) => 0
- case Pair(List(), _ ) => -1
- case Pair(_ , List()) => +1
- case Pair(x::xs , y::ys ) => {
+ case (List(), List()) => 0
+ case (List(), _ ) => -1
+ case (_ , List()) => +1
+ case (x::xs , y::ys ) => {
val diff = x.compareTo(y);
if (diff != 0) diff else compare(xs,ys)
}
@@ -508,18 +508,18 @@ object MB {
private def +< (that: Expr): Boolean = (this +<? that) < 0;
private def +<= (that: Expr): Boolean = (this +<? that) <= 0;
- private def +<? (that: Expr): Int = Pair(this,that) match {
- case Pair(Add(_,_), _ ) => 0
- case Pair(_ , Add(_,_)) => 0
- case Pair(_ , _ ) => compare(this.vars,that.vars)
+ private def +<? (that: Expr): Int = (this,that) match {
+ case (Add(_,_), _ ) => 0
+ case (_ , Add(_,_)) => 0
+ case (_ , _ ) => compare(this.vars,that.vars)
}
- def + (that: Expr): Expr = if (that +<= this) Pair(this,that) match {
- case Pair(_ , Lit(0) ) => this
- case Pair(Lit(l) , Lit(r) ) => Lit(l + r)
- case Pair(_ , Add(rl,rr)) => (this + rl) + rr
- case Pair(Add(ll,lr), _ ) if (lr +<= that) => ll + (that + lr)
- case Pair(_ , _ ) => {
+ def + (that: Expr): Expr = if (that +<= this) (this,that) match {
+ case (_ , Lit(0) ) => this
+ case (Lit(l) , Lit(r) ) => Lit(l + r)
+ case (_ , Add(rl,rr)) => (this + rl) + rr
+ case (Add(ll,lr), _ ) if (lr +<= that) => ll + (that + lr)
+ case (_ , _ ) => {
val l = this.term;
val r = that.term;
if (l equ r) Lit(this.count + that.count) * r else Add(this, that)
@@ -528,41 +528,41 @@ object MB {
private def *< (that: Expr): Boolean = (this *<? that) < 0;
private def *<= (that: Expr): Boolean = (this *<? that) <= 0;
- private def *<? (that: Expr): Int = Pair(this,that) match {
- case Pair(Mul(_,_), _ ) => 0
- case Pair(_ , Mul(_,_)) => 0
- case Pair(Add(_,_), Add(_,_)) => 0
- case Pair(Add(_,_), _ ) => -1
- case Pair(_ , Add(_,_)) => +1
- case Pair(Lit(_) , Lit(_) ) => 0
- case Pair(Lit(_) , _ ) => -1
- case Pair(_ , Lit(_) ) => +1
- case Pair(Var(l) , Var(r) ) => l.compareTo(r)
- case Pair(Var(_) , Pow(r,_)) => if (this *<= r) -1 else +1
- case Pair(Pow(l,_), Var(_) ) => if (l *< that) -1 else +1
- case Pair(Pow(l,_), Pow(r,_)) => l *<? r
+ private def *<? (that: Expr): Int = (this,that) match {
+ case (Mul(_,_), _ ) => 0
+ case (_ , Mul(_,_)) => 0
+ case (Add(_,_), Add(_,_)) => 0
+ case (Add(_,_), _ ) => -1
+ case (_ , Add(_,_)) => +1
+ case (Lit(_) , Lit(_) ) => 0
+ case (Lit(_) , _ ) => -1
+ case (_ , Lit(_) ) => +1
+ case (Var(l) , Var(r) ) => l.compareTo(r)
+ case (Var(_) , Pow(r,_)) => if (this *<= r) -1 else +1
+ case (Pow(l,_), Var(_) ) => if (l *< that) -1 else +1
+ case (Pow(l,_), Pow(r,_)) => l *<? r
}
- def * (that: Expr): Expr = if (this *<= that) Pair(this,that) match {
- case Pair(Lit(0) , _ ) => this
- case Pair(Lit(1) , _ ) => that
- case Pair(Mul(ll,lr), r ) => ll * (lr * r)
- case Pair(Add(ll,lr), r ) => ll * r + lr * r
- case Pair(Lit(l) , Lit(r) ) => Lit(l * r)
- case Pair(Var(_) , Var(_) ) if (this equ that) => Pow(this,2)
- case Pair(Var(_) , Pow(r,n) ) if (this equ r) => Pow(this,n + 1)
- case Pair(Pow(ll,lr), Pow(rl,rr)) if (ll equ rl) => Pow(ll,lr + rr)
- case Pair(l , Mul(rl,rr)) if (rl *<= l) => (rl * l) * rr
- case Pair(_ , _ ) => Mul(this,that)
+ def * (that: Expr): Expr = if (this *<= that) (this,that) match {
+ case (Lit(0) , _ ) => this
+ case (Lit(1) , _ ) => that
+ case (Mul(ll,lr), r ) => ll * (lr * r)
+ case (Add(ll,lr), r ) => ll * r + lr * r
+ case (Lit(l) , Lit(r) ) => Lit(l * r)
+ case (Var(_) , Var(_) ) if (this equ that) => Pow(this,2)
+ case (Var(_) , Pow(r,n) ) if (this equ r) => Pow(this,n + 1)
+ case (Pow(ll,lr), Pow(rl,rr)) if (ll equ rl) => Pow(ll,lr + rr)
+ case (l , Mul(rl,rr)) if (rl *<= l) => (rl * l) * rr
+ case (_ , _ ) => Mul(this,that)
} else that * this;
def ^ (that: Int): Expr = (this,that) match {
- case Pair(_ ,1) => this
- case Pair(Lit(i) ,n) => Lit(power(i,n))
- case Pair(Var(_) ,n) => Pow(this,n)
- case Pair(Add(_,_),n) => this * (this ^ (n - 1))
- case Pair(Mul(l,r),n) => (l ^ n) * (r ^ n)
- case Pair(Pow(e,m),n) => Pow(e,m + n)
+ case (_ ,1) => this
+ case (Lit(i) ,n) => Lit(power(i,n))
+ case (Var(_) ,n) => Pow(this,n)
+ case (Add(_,_),n) => this * (this ^ (n - 1))
+ case (Mul(l,r),n) => (l ^ n) * (r ^ n)
+ case (Pow(e,m),n) => Pow(e,m + n)
}
def derive(v: Var): Expr = this match {
@@ -581,12 +581,12 @@ object MB {
case Pow(l, r) => power(l.evaluate(vars), r)
}
- def equ(that: Expr): Boolean = Pair(this,that) match {
- case Pair(Lit(l) ,Lit(r)) => l == r
- case Pair(Var(l) ,Var(r)) => l == r
- case Pair(Add(ll,lr),Add(rl,rr)) => (ll equ rl) && (lr equ rr)
- case Pair(Mul(ll,lr),Mul(rl,rr)) => (ll equ rl) && (lr equ rr)
- case Pair(Pow(ll,lr),Pow(rl,rr)) => (ll equ rl) && (lr == rr)
+ def equ(that: Expr): Boolean = (this,that) match {
+ case (Lit(l) ,Lit(r)) => l == r
+ case (Var(l) ,Var(r)) => l == r
+ case (Add(ll,lr),Add(rl,rr)) => (ll equ rl) && (lr equ rr)
+ case (Mul(ll,lr),Mul(rl,rr)) => (ll equ rl) && (lr equ rr)
+ case (Pow(ll,lr),Pow(rl,rr)) => (ll equ rl) && (lr == rr)
case _ => false
}
@@ -667,7 +667,7 @@ object MB {
Console.println;
def check(n: String, f: Expr, x: Int, e: Int) {
- val a: Int = f.evaluate(List(Pair("x",x)));
+ val a: Int = f.evaluate(List(("x",x)));
val s: String = if (a == e) "ok" else "KO(" + e + ")";
Console.println(n + "(" + x + ") = " + a + " " + s);
}
diff --git a/test/files/run/Course-2002-08.scala b/test/files/run/Course-2002-08.scala
index 38b8363661..5e21edaba3 100644
--- a/test/files/run/Course-2002-08.scala
+++ b/test/files/run/Course-2002-08.scala
@@ -163,7 +163,7 @@ object M5 {
}
abstract class Simulation() {
- private type Agenda = List[Pair[Int, Action]];
+ private type Agenda = List[Tuple2[Int, Action]];
private var agenda: Agenda = List();
private var curtime = 0;
def currentTime: Int = curtime;
@@ -171,17 +171,17 @@ object M5 {
def afterDelay(delay: Int)(action: Action): Unit = {
def insert(ag: Agenda, time: Int): Agenda = ag match {
case List() =>
- List(Pair(time, action))
- case Pair(t, act) :: ag1 =>
- if (time < t) Pair(time, action) :: ag
- else Pair(t, act) :: insert(ag1, time)
+ List((time, action))
+ case (t, act) :: ag1 =>
+ if (time < t) (time, action) :: ag
+ else (t, act) :: insert(ag1, time)
}
agenda = insert(agenda, curtime + delay)
}
private def next: Unit = agenda match {
case List() => ()
- case Pair(time, action) :: ag1 => {
+ case (time, action) :: ag1 => {
agenda = ag1;
curtime = time;
action();
@@ -413,7 +413,7 @@ object M5 {
class Simulator() {
type Action = () => Unit;
- type Agenda = List[Pair[Int, Action]];
+ type Agenda = List[Tuple2[Int, Action]];
private var agenda: Agenda = List();
private var curtime = 0;
@@ -421,17 +421,17 @@ class Simulator() {
def afterDelay(delay: Int)(action: Action) = {
def insert(ag: Agenda, time: Int): Agenda = ag match {
case List() =>
- List(Pair(time, action))
- case Pair(t, act) :: ag1 =>
- if (time < t) Pair(time, action) :: ag
- else Pair(t, act) :: insert(ag1, time)
+ List((time, action))
+ case (t, act) :: ag1 =>
+ if (time < t) (time, action) :: ag
+ else (t, act) :: insert(ag1, time)
}
agenda = insert(agenda, curtime + delay)
}
def next: Unit = agenda match {
case List() => ()
- case Pair(time, action) :: rest => {
+ case (time, action) :: rest => {
agenda = rest;
curtime = time;
action();
@@ -567,8 +567,8 @@ class Main() extends CircuitSimulator() {
demux(in, ctrl.reverse, out.reverse);
probe("in", in);
- for (Pair(x,c) <- range(0,n) zip ctrl) { probe("ctrl" + x, c) }
- for (Pair(x,o) <- range(0,outNum) zip out) { probe("out" + x, o) }
+ for ((x,c) <- range(0,n) zip ctrl) { probe("ctrl" + x, c) }
+ for ((x,o) <- range(0,outNum) zip out) { probe("out" + x, o) }
in.setSignal(true);
run;
diff --git a/test/files/run/Course-2002-09.scala b/test/files/run/Course-2002-09.scala
index 87f91111d8..704f2ec0aa 100644
--- a/test/files/run/Course-2002-09.scala
+++ b/test/files/run/Course-2002-09.scala
@@ -13,11 +13,11 @@ object NoConstraint extends Constraint {
}
class Adder(a1: Quantity,a2: Quantity,sum: Quantity) extends Constraint {
- def newValue = Triple(a1.getValue, a2.getValue, sum.getValue) match {
- case Triple(Some(x1), Some(x2), _ ) => sum.setValue(x1 + x2, this)
- case Triple(Some(x1), _ , Some(r)) => a2.setValue(r - x1, this)
- case Triple(_ , Some(x2), Some(r)) => a1.setValue(r - x2, this)
- case _ =>
+ def newValue = (a1.getValue, a2.getValue, sum.getValue) match {
+ case (Some(x1), Some(x2), _ ) => sum.setValue(x1 + x2, this)
+ case (Some(x1), _ , Some(r)) => a2.setValue(r - x1, this)
+ case (_ , Some(x2), Some(r)) => a1.setValue(r - x2, this)
+ case _ =>
}
def dropValue: Unit = {
a1.forgetValue(this); a2.forgetValue(this); sum.forgetValue(this);
@@ -29,13 +29,13 @@ class Adder(a1: Quantity,a2: Quantity,sum: Quantity) extends Constraint {
class Multiplier(m1: Quantity, m2: Quantity, prod: Quantity)
extends Constraint {
- def newValue = Triple(m1.getValue, m2.getValue, prod.getValue) match {
- case Triple(Some(0d), _ , _ ) => prod.setValue(0, this);
- case Triple(_ , Some(0d), _ ) => prod.setValue(0, this);
- case Triple(Some(x1), Some(x2), _ ) => prod.setValue(x1 * x2, this)
- case Triple(Some(x1), _ , Some(r)) => m2.setValue(r / x1, this)
- case Triple(_, Some(x2), Some(r)) => m1.setValue(r / x2, this)
- case _ =>
+ def newValue = (m1.getValue, m2.getValue, prod.getValue) match {
+ case (Some(0d), _ , _ ) => prod.setValue(0, this);
+ case (_ , Some(0d), _ ) => prod.setValue(0, this);
+ case (Some(x1), Some(x2), _ ) => prod.setValue(x1 * x2, this)
+ case (Some(x1), _ , Some(r)) => m2.setValue(r / x1, this)
+ case (_, Some(x2), Some(r)) => m1.setValue(r / x2, this)
+ case _ =>
}
def dropValue: Unit = {
m1.forgetValue(this); m2.forgetValue(this); prod.forgetValue(this);
@@ -46,11 +46,11 @@ class Multiplier(m1: Quantity, m2: Quantity, prod: Quantity)
}
class Squarer(square: Quantity, root: Quantity) extends Constraint {
- def newValue: Unit = Pair(square.getValue, root.getValue) match {
- case Pair(Some(x), _ )if (x < 0) => sys.error("Square of negative number")
- case Pair(Some(x), _ ) => root.setValue(Math.sqrt(x), this)
- case Pair(_ , Some(x)) => square.setValue(x*x, this)
- case _ =>
+ def newValue: Unit = (square.getValue, root.getValue) match {
+ case (Some(x), _ )if (x < 0) => sys.error("Square of negative number")
+ case (Some(x), _ ) => root.setValue(Math.sqrt(x), this)
+ case (_ , Some(x)) => square.setValue(x*x, this)
+ case _ =>
}
def dropValue: Unit = {
square.forgetValue(this); root.forgetValue(this);
@@ -60,9 +60,9 @@ class Squarer(square: Quantity, root: Quantity) extends Constraint {
}
class Eq(a: Quantity, b: Quantity) extends Constraint {
- def newValue = (Pair(a.getValue, b.getValue): @unchecked) match {
- case Pair(Some(x), _ ) => b.setValue(x, this);
- case Pair(_ , Some(y)) => a.setValue(y, this);
+ def newValue = ((a.getValue, b.getValue): @unchecked) match {
+ case (Some(x), _ ) => b.setValue(x, this);
+ case (_ , Some(y)) => a.setValue(y, this);
}
def dropValue {
a.forgetValue(this); b.forgetValue(this);
diff --git a/test/files/run/Course-2002-13.scala b/test/files/run/Course-2002-13.scala
index 4bd3614fb0..a596a33873 100644
--- a/test/files/run/Course-2002-13.scala
+++ b/test/files/run/Course-2002-13.scala
@@ -74,18 +74,18 @@ object Terms {
val NoTerm = Con("<none>", List());
- def unify1(x: Term, y: Term, s: Subst): Option[Subst] = Pair(x, y) match {
- case Pair(Var(a), Var(b)) if (a == b) =>
+ def unify1(x: Term, y: Term, s: Subst): Option[Subst] = (x, y) match {
+ case (Var(a), Var(b)) if (a == b) =>
Some(s)
- case Pair(Var(a), _) => lookup(s, a) match {
+ case (Var(a), _) => lookup(s, a) match {
case Some(x1) => unify(x1, y, s)
case None => if (y.tyvars contains a) None else Some(Binding(a, y) :: s)
}
- case Pair(_, Var(b)) => lookup(s, b) match {
+ case (_, Var(b)) => lookup(s, b) match {
case Some(y1) => unify(x, y1, s)
case None => if (x.tyvars contains b) None else Some(Binding(b, x) :: s)
}
- case Pair(Con(a, xs), Con(b, ys)) if (a == b) =>
+ case (Con(a, xs), Con(b, ys)) if (a == b) =>
unify(xs, ys, s)
case _ => None
}
@@ -96,9 +96,9 @@ object Terms {
ss
}
- def unify(xs: List[Term], ys: List[Term], s: Subst): Option[Subst] = Pair(xs, ys) match {
- case Pair(List(), List()) => Some(s)
- case Pair(x :: xs1, y :: ys1) =>
+ def unify(xs: List[Term], ys: List[Term], s: Subst): Option[Subst] = (xs, ys) match {
+ case (List(), List()) => Some(s)
+ case (x :: xs1, y :: ys1) =>
unify(x, y, s) match {
case Some(s1) => unify(xs1, ys1, s1)
case None => None
diff --git a/test/files/run/bugs.scala b/test/files/run/bugs.scala
index ba8449c299..02849b5817 100644
--- a/test/files/run/bugs.scala
+++ b/test/files/run/bugs.scala
@@ -46,7 +46,7 @@ object Bug135Test {
def test(args: Array[String]) {
val myMap:TreeMap[Int, String] = new TreeMap
- val map1 = myMap + Pair(42, "The answer")
+ val map1 = myMap + ((42, "The answer"))
println(map1.get(42))
}
diff --git a/test/files/run/map_test.scala b/test/files/run/map_test.scala
index 1ea864ed58..b76dfb4577 100644
--- a/test/files/run/map_test.scala
+++ b/test/files/run/map_test.scala
@@ -20,7 +20,7 @@ object Test extends App {
val map2 = map1.updated(17,"A small random number")
val map3 = map2.updated(666,"A bigger random number")
val map4 = map3.updated(4711,"A big random number")
- map1 == myMap + Pair(42, "The answer")
+ map1 == myMap + ((42, "The answer"))
var i = 0
var map = map4
while(i < 43) {
diff --git a/test/files/run/patmatnew.scala b/test/files/run/patmatnew.scala
index b212e10f8d..3c0d00dc6c 100644
--- a/test/files/run/patmatnew.scala
+++ b/test/files/run/patmatnew.scala
@@ -46,7 +46,7 @@ object Test {
object SimpleUnapply {
def run() { // from sortedmap, old version
List((1, 2)).head match {
- case kv@Pair(key, _) => kv.toString + " " + key.toString
+ case kv@(key, _) => kv.toString + " " + key.toString
}
}
@@ -400,9 +400,9 @@ object Test {
// these are exhaustive matches
// should not generate any warnings
def f[A](z: (Option[A], Option[A])) = z match {
- case Pair(None, Some(x)) => 1
- case Pair(Some(x), None) => 2
- case Pair(Some(x), Some(y)) => 3
+ case (None, Some(x)) => 1
+ case (Some(x), None) => 2
+ case (Some(x), Some(y)) => 3
case _ => 4
}
@@ -419,9 +419,9 @@ object Test {
}
def h[A](x: (Option[A], Option[A])) = x match {
- case Pair(None, _: Some[_]) => 1
- case Pair(_: Some[_], None) => 2
- case Pair(_: Some[_], _: Some[_]) => 3
+ case (None, _: Some[_]) => 1
+ case (_: Some[_], None) => 2
+ case (_: Some[_], _: Some[_]) => 3
case _ => 4
}
@@ -539,17 +539,17 @@ object Test {
case class Operator(x: Int);
val EQ = new Operator(2);
- def analyze(x: Pair[Operator, Int]) = x match {
- case Pair(EQ, 0) => "0"
- case Pair(EQ, 1) => "1"
- case Pair(EQ, 2) => "2"
+ def analyze(x: Tuple2[Operator, Int]) = x match {
+ case (EQ, 0) => "0"
+ case (EQ, 1) => "1"
+ case (EQ, 2) => "2"
}
def run() {
- val x = Pair(EQ, 0);
+ val x = (EQ, 0);
assertEquals("0", analyze(x)); // should print "0"
- val y = Pair(EQ, 1);
+ val y = (EQ, 1);
assertEquals("1", analyze(y)); // should print "1"
- val z = Pair(EQ, 2);
+ val z = (EQ, 2);
assertEquals("2", analyze(z)); // should print "2"
}
}
diff --git a/test/files/run/t3888.scala b/test/files/run/t3888.scala
index 19771041fc..8701b42ff0 100644
--- a/test/files/run/t3888.scala
+++ b/test/files/run/t3888.scala
@@ -24,6 +24,6 @@ object Test {
}
}
-class P extends Pair(1, 1) {
+class P extends Tuple2(1, 1) {
override def equals(x: Any) = true
}
diff --git a/test/files/run/tailcalls.scala b/test/files/run/tailcalls.scala
index e5d8891cc7..1653b14de9 100644
--- a/test/files/run/tailcalls.scala
+++ b/test/files/run/tailcalls.scala
@@ -169,7 +169,7 @@ class TailCall[S](s: S) {
aux[T](x, y);
}
final def g3[T](x: Int, y: Int, zs: List[T]): Int = {
- def aux[U](n: Int, v: Int, ls: List[Pair[T,U]]): Int =
+ def aux[U](n: Int, v: Int, ls: List[Tuple2[T,U]]): Int =
if (n == 0) v else aux(n - 1, v - 1, ls);
aux(x, y, Nil);
}
diff --git a/test/files/run/tcpoly_parseridioms.check b/test/files/run/tcpoly_parseridioms.check
index ab829e0a0e..8bd0a086d6 100644
--- a/test/files/run/tcpoly_parseridioms.check
+++ b/test/files/run/tcpoly_parseridioms.check
@@ -4,8 +4,8 @@ It would fail on the following input: ParseResult()
^
tcpoly_parseridioms.scala:17: warning: match may not be exhaustive.
It would fail on the following input: ParseResult()
- def apply(in: Input): ParseResult[Pair[T, U]] = a(in) match {
- ^
+ def apply(in: Input): ParseResult[Tuple2[T, U]] = a(in) match {
+ ^
tcpoly_parseridioms.scala:30: warning: match may not be exhaustive.
It would fail on the following input: ParseResult()
case Failure(_, _) => b(in) match {
diff --git a/test/files/run/tcpoly_parseridioms.scala b/test/files/run/tcpoly_parseridioms.scala
index c8bcf693a1..d22f68b558 100644
--- a/test/files/run/tcpoly_parseridioms.scala
+++ b/test/files/run/tcpoly_parseridioms.scala
@@ -13,10 +13,10 @@ trait Parsers {
}
// sequence
- def sq[T, U](a: => Parser[T], b: => Parser[U]): Parser[Pair[T, U]] = new Parser[Pair[T, U]] {
- def apply(in: Input): ParseResult[Pair[T, U]] = a(in) match {
+ def sq[T, U](a: => Parser[T], b: => Parser[U]): Parser[Tuple2[T, U]] = new Parser[Tuple2[T, U]] {
+ def apply(in: Input): ParseResult[Tuple2[T, U]] = a(in) match {
case Success(next, x) => b(next) match {
- case Success(next2, y) => Success(next2, Pair(x,y))
+ case Success(next2, y) => Success(next2, (x,y))
case Failure(_, msg) => Failure(in, msg)
}
case Failure(_, msg) => Failure(in, msg)
@@ -49,7 +49,7 @@ trait Parsers {
}
}
- def apply_++[s, tt](fun: Parser[s => tt], arg: Parser[s]): Parser[tt] = lift[Pair[s=>tt, s], tt]({case Pair(f, a) => f(a)})(sq(fun, arg))
+ def apply_++[s, tt](fun: Parser[s => tt], arg: Parser[s]): Parser[tt] = lift[Tuple2[s=>tt, s], tt]({case (f, a) => f(a)})(sq(fun, arg))
def success[u](v: u): Parser[u] = new Parser[u] {
def apply(in: Input) = Success(in, v)
diff --git a/test/files/run/withIndex.scala b/test/files/run/withIndex.scala
index 910b1f1f9e..ebf1941c95 100644
--- a/test/files/run/withIndex.scala
+++ b/test/files/run/withIndex.scala
@@ -11,7 +11,7 @@ object Test {
Console.println(str.zipWithIndex.toList)
assert {
ary.zipWithIndex match {
- case _: Array[Pair[_,_]] => true
+ case _: Array[Tuple2[_,_]] => true
case _ => false
}
}
diff --git a/test/pending/run/reify_callccinterpreter.scala b/test/pending/run/reify_callccinterpreter.scala
index d9f7736769..82c70da28f 100644
--- a/test/pending/run/reify_callccinterpreter.scala
+++ b/test/pending/run/reify_callccinterpreter.scala
@@ -43,15 +43,15 @@ object Test extends App {
override def toString() = "<function>"
}
- type Environment = List[Pair[Name, Value]];
+ type Environment = List[Tuple2[Name, Value]];
def lookup(x: Name, e: Environment): M[Value] = e match {
case List() => unitM(Wrong)
- case Pair(y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
+ case (y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
}
- def add(a: Value, b: Value): M[Value] = Pair(a, b) match {
- case Pair(Num(m), Num(n)) => unitM(Num(m + n))
+ def add(a: Value, b: Value): M[Value] = (a, b) match {
+ case (Num(m), Num(n)) => unitM(Num(m + n))
case _ => unitM(Wrong)
}
@@ -67,12 +67,12 @@ object Test extends App {
b <- interp(r, e);
c <- add(a, b))
yield c
- case Lam(x, t) => unitM(Fun(a => interp(t, Pair(x, a) :: e)))
+ case Lam(x, t) => unitM(Fun(a => interp(t, (x, a) :: e)))
case App(f, t) => for (a <- interp(f, e);
b <- interp(t, e);
c <- apply(a, b))
yield c
- case Ccc(x, t) => callCC(k => interp(t, Pair(x, Fun(k)) :: e))
+ case Ccc(x, t) => callCC(k => interp(t, (x, Fun(k)) :: e))
}
def test(t: Term): String = showM(interp(t, List()))
diff --git a/test/pending/run/reify_simpleinterpreter.scala b/test/pending/run/reify_simpleinterpreter.scala
index 6cf87ea7c5..1f6d6c8da7 100644
--- a/test/pending/run/reify_simpleinterpreter.scala
+++ b/test/pending/run/reify_simpleinterpreter.scala
@@ -32,15 +32,15 @@ object Test extends App {
override def toString() = "<function>"
}
- type Environment = List[Pair[Name, Value]]
+ type Environment = List[Tuple2[Name, Value]]
def lookup(x: Name, e: Environment): M[Value] = e match {
case List() => unitM(Wrong)
- case Pair(y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
+ case (y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
}
- def add(a: Value, b: Value): M[Value] = Pair(a, b) match {
- case Pair(Num(m), Num(n)) => unitM(Num(m + n))
+ def add(a: Value, b: Value): M[Value] = (a, b) match {
+ case (Num(m), Num(n)) => unitM(Num(m + n))
case _ => unitM(Wrong)
}
@@ -56,7 +56,7 @@ object Test extends App {
b <- interp(r, e);
c <- add(a, b))
yield c
- case Lam(x, t) => unitM(Fun(a => interp(t, Pair(x, a) :: e)))
+ case Lam(x, t) => unitM(Fun(a => interp(t, (x, a) :: e)))
case App(f, t) => for (a <- interp(f, e);
b <- interp(t, e);
c <- apply(a, b))
diff --git a/test/pending/shootout/fasta.scala b/test/pending/shootout/fasta.scala
index 8b711083a5..ae99ba5936 100644
--- a/test/pending/shootout/fasta.scala
+++ b/test/pending/shootout/fasta.scala
@@ -5,7 +5,7 @@
import java.io._
-object fasta {
+object fasta {
def main(args: Array[String]) = {
val ALU =
@@ -18,31 +18,31 @@ object fasta {
"AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA"
val _IUB = Array(
- Pair('a', 0.27),
- Pair('c', 0.12),
- Pair('g', 0.12),
- Pair('t', 0.27),
-
- Pair('B', 0.02),
- Pair('D', 0.02),
- Pair('H', 0.02),
- Pair('K', 0.02),
- Pair('M', 0.02),
- Pair('N', 0.02),
- Pair('R', 0.02),
- Pair('S', 0.02),
- Pair('V', 0.02),
- Pair('W', 0.02),
- Pair('Y', 0.02)
+ ('a', 0.27),
+ ('c', 0.12),
+ ('g', 0.12),
+ ('t', 0.27),
+
+ ('B', 0.02),
+ ('D', 0.02),
+ ('H', 0.02),
+ ('K', 0.02),
+ ('M', 0.02),
+ ('N', 0.02),
+ ('R', 0.02),
+ ('S', 0.02),
+ ('V', 0.02),
+ ('W', 0.02),
+ ('Y', 0.02)
)
val IUB = makeCumulative(_IUB)
val _HomoSapiens = Array(
- Pair('a', 0.3029549426680),
- Pair('c', 0.1979883004921),
- Pair('g', 0.1975473066391),
- Pair('t', 0.3015094502008)
+ ('a', 0.3029549426680),
+ ('c', 0.1979883004921),
+ ('g', 0.1975473066391),
+ ('t', 0.3015094502008)
)
val HomoSapiens = makeCumulative(_HomoSapiens)
@@ -61,15 +61,15 @@ object fasta {
s.writeRandomSequence(HomoSapiens,n*5)
s.close
- }
+ }
- def makeCumulative(a: Array[Pair[Char,Double]]) = {
+ def makeCumulative(a: Array[Tuple2[Char,Double]]) = {
var cp = 0.0
a map (frequency =>
- frequency match {
- case Pair(code,percent) =>
- cp = cp + percent; new Frequency(code.toByte,cp)
- }
+ frequency match {
+ case (code,percent) =>
+ cp = cp + percent; new Frequency(code.toByte,cp)
+ }
)
}
@@ -79,7 +79,7 @@ object fasta {
// We could use instances of Pair or Tuple2 but specific labels
// make the code more readable than index numbers
-class Frequency(_code: Byte, _percent: Double){
+class Frequency(_code: Byte, _percent: Double){
var code = _code; var percent = _percent;
}
@@ -101,13 +101,13 @@ class FastaOutputStream(out: OutputStream) extends BufferedOutputStream(out) {
val m = if (n < LineLength) n else LineLength
var i = 0
- while (i < m){
+ while (i < m){
if (k == kn) k = 0
val b = alu(k)
if (count < buf.length){ buf(count) = b; count = count + 1 }
else { write(b) } // flush buffer
k = k+1
- i = i+1
+ i = i+1
}
write(nl)
@@ -122,11 +122,11 @@ class FastaOutputStream(out: OutputStream) extends BufferedOutputStream(out) {
val m = if (n < LineLength) n else LineLength
var i = 0
- while (i < m){
+ while (i < m){
val b = selectRandom(distribution)
if (count < buf.length){ buf(count) = b; count = count + 1 }
else { write(b) } // flush buffer
- i = i+1
+ i = i+1
}
if (count < buf.length){ buf(count) = nl; count = count + 1 }
diff --git a/test/pending/shootout/revcomp.scala-2.scala b/test/pending/shootout/revcomp.scala-2.scala
index 92260ad021..03fb25af1b 100644
--- a/test/pending/shootout/revcomp.scala-2.scala
+++ b/test/pending/shootout/revcomp.scala-2.scala
@@ -6,7 +6,7 @@
import java.io._
import scala.collection.mutable.Stack
-object revcomp {
+object revcomp {
val IUB = IUBCodeComplements
@@ -16,7 +16,7 @@ object revcomp {
val a: Array[Byte] = new Array( 'z'.toByte )
for (indexValue <- code zip comp)
- indexValue match { case Pair(i,v) => a(i) = v }
+ indexValue match { case (i,v) => a(i) = v }
a
}
@@ -49,18 +49,18 @@ object revcomp {
if (desc.length > 0) complementReverseWrite(desc, lines, w)
w.close
- }
+ }
- def complementReverseWrite(desc: String, lines: LineStack,
+ def complementReverseWrite(desc: String, lines: LineStack,
w: BufferedOutputStream) = {
def inplaceComplementReverse(b: Array[Byte]) = {
- var i = 0
+ var i = 0
var j = b.length - 1
while (i < j){
- val swap = b(i)
- b(i) = IUB( b(j) )
+ val swap = b(i)
+ b(i) = IUB( b(j) )
b(j) = IUB( swap )
i = i + 1
j = j - 1
@@ -79,11 +79,11 @@ object revcomp {
while (!lines.isEmpty) {
val line = lines.pop
inplaceComplementReverse(line)
-
+
if (isSplitLine){
if (isFirstLine){ w.write(line); isFirstLine = false }
else { w.write(line,0,n-k); w.write(nl); w.write(line,n-k,k) }
- }
+ }
else { w.write(line); w.write(nl) }
}
if (isSplitLine && !isFirstLine) w.write(nl)
diff --git a/test/pending/shootout/revcomp.scala-3.scala b/test/pending/shootout/revcomp.scala-3.scala
index ae12f0499b..39a0409127 100644
--- a/test/pending/shootout/revcomp.scala-3.scala
+++ b/test/pending/shootout/revcomp.scala-3.scala
@@ -6,7 +6,7 @@
import java.io._
import scala.collection.mutable.Stack
-object revcomp {
+object revcomp {
def main(args: Array[String]) = {
val out = new FastaOutputStream(System.out)
val in = new FastaInputStream(System.in)
@@ -17,12 +17,12 @@ object revcomp {
in.close
out.close
- }
+ }
}
trait FastaByteStream {
- val nl = '\n'.toByte
+ val nl = '\n'.toByte
type Line = Array[Byte]
type LineStack = Stack[Line]
@@ -31,13 +31,13 @@ trait FastaByteStream {
// extend the Java BufferedInputStream class
-final class FastaInputStream(in: InputStream)
+final class FastaInputStream(in: InputStream)
extends BufferedInputStream(in) with FastaByteStream {
val gt = '>'.toByte
val sc = ';'.toByte
- def readSequenceStack(): Pair[Line,LineStack] = {
+ def readSequenceStack(): Tuple2[Line,LineStack] = {
var header: Line = null
val lines: LineStack = new Stack
@@ -49,14 +49,14 @@ final class FastaInputStream(in: InputStream)
header = line
} else {
pos = pos - line.length - 1 // reposition to start of line
- return Pair(header,lines)
+ return (header,lines)
}
} else {
if (c != sc) lines push line // ';'
}
line = readLine()
}
- return Pair(header,lines)
+ return (header,lines)
}
def readLine() = {
@@ -65,7 +65,7 @@ final class FastaInputStream(in: InputStream)
else {
mark(128) // mark the start of the line
if (count == 0) read() // fill buffer
-
+
var i = markpos
while (i < count && buf(i) != nl) i = i + 1
@@ -74,11 +74,11 @@ final class FastaInputStream(in: InputStream)
while (i < count && buf(i) != nl) i = i + 1
}
- if (i < count){
+ if (i < count){
bytes = new Array(i - markpos)
System.arraycopy(buf, markpos, bytes, 0, i - markpos);
pos = i+1
- }
+ }
}
bytes
}
@@ -87,7 +87,7 @@ final class FastaInputStream(in: InputStream)
// extend the Java BufferedOutputStream class
-final class FastaOutputStream(in: OutputStream)
+final class FastaOutputStream(in: OutputStream)
extends BufferedOutputStream(in) with FastaByteStream {
private val IUB = IUBCodeComplements
@@ -98,19 +98,19 @@ final class FastaOutputStream(in: OutputStream)
val iub: Array[Byte] = new Array( 'z'.toByte )
for (indexValue <- code zip comp)
- indexValue match { case Pair(i,v) => iub(i) = v }
+ indexValue match { case (i,v) => iub(i) = v }
iub
}
- def writeReverseComplement(sequence: Pair[Line,LineStack]) = {
+ def writeReverseComplement(sequence: Tuple2[Line,LineStack]) = {
def inplaceComplementReverse(b: Array[Byte]) = {
- var i = 0
+ var i = 0
var j = b.length - 1
while (i < j){
- val swap = b(i)
- b(i) = IUB( b(j) )
+ val swap = b(i)
+ b(i) = IUB( b(j) )
b(j) = IUB( swap )
i = i + 1
j = j - 1
@@ -119,7 +119,7 @@ final class FastaOutputStream(in: OutputStream)
}
sequence match {
- case Pair(header,lines) => {
+ case (header,lines) => {
write(header); write(nl)
@@ -131,11 +131,11 @@ final class FastaOutputStream(in: OutputStream)
while (!lines.isEmpty) {
val line = lines.pop
inplaceComplementReverse(line)
-
+
if (isSplitLine){
- if (isFirstLine){ write(line); isFirstLine = false }
+ if (isFirstLine){ write(line); isFirstLine = false }
else { write(line,0,LineLength-k); write(nl); write(line,LineLength-k,k) }
- }
+ }
else { write(line); write(nl) }
}