summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/build/genprod.scala132
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala1
-rw-r--r--src/library/scala/Function0.scala2
-rw-r--r--src/library/scala/Function1.scala16
-rw-r--r--src/library/scala/Function2.scala14
-rw-r--r--src/library/scala/PartialFunction.scala2
-rw-r--r--src/library/scala/Predef.scala8
-rw-r--r--src/library/scala/Tuple2.scala114
-rw-r--r--src/library/scala/Tuple3.scala11
-rw-r--r--src/library/scala/runtime/RichFunction1.scala27
-rw-r--r--src/library/scala/runtime/RichFunction2.scala26
-rw-r--r--src/library/scala/runtime/Tuple2Zipped.scala109
-rw-r--r--test/files/neg/t5067.check8
-rw-r--r--test/files/neg/t5067.scala6
-rw-r--r--test/files/run/tuple-zipped.scala2
15 files changed, 294 insertions, 184 deletions
diff --git a/src/build/genprod.scala b/src/build/genprod.scala
index 8a5c44f1c1..1ea0bf7b73 100644
--- a/src/build/genprod.scala
+++ b/src/build/genprod.scala
@@ -123,7 +123,23 @@ object FunctionOne extends Function(1) {
* assert(succ(0) == anonfun1(0))
* """)
- override def moreMethods = ""
+ override def moreMethods = """
+ /** Composes two instances of Function1 in a new Function1, with this function applied last.
+ *
+ * @tparam A the type to which function `g` can be applied
+ * @param g a function A => T1
+ * @return a new function `f` such that `f(x) == apply(g(x))`
+ */
+ def compose[A](g: A => T1): A => R = { x => apply(g(x)) }
+
+ /** Composes two instances of Function1 in a new Function1, with this function applied first.
+ *
+ * @tparam A the result type of function `g`
+ * @param g a function R => A
+ * @return a new function `f` such that `f(x) == g(apply(x))`
+ */
+ def andThen[A](g: R => A): T1 => A = { x => g(apply(x)) }
+"""
}
object FunctionTwo extends Function(2) {
@@ -139,8 +155,6 @@ object FunctionTwo extends Function(2) {
* }
* assert(max(0, 1) == anonfun2(0, 1))
* """)
-
- override def moreMethods = ""
}
object Function {
@@ -241,6 +255,11 @@ class Function(val i: Int) extends Group("Function") with Arity {
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz */
object Tuple {
+ val zipImports = """
+import scala.collection.{ TraversableLike => TLike, IterableLike => ILike }
+import scala.collection.generic.{ CanBuildFrom => CBF }
+"""
+
def make(i: Int) = apply(i)()
def apply(i: Int) = i match {
case 1 => TupleOne
@@ -257,6 +276,7 @@ object TupleOne extends Tuple(1)
object TupleTwo extends Tuple(2)
{
+ override def imports = Tuple.zipImports
override def covariantSpecs = "@specialized(Int, Long, Double, Char, Boolean, AnyRef) "
override def moreMethods = """
/** Swaps the elements of this `Tuple`.
@@ -264,14 +284,112 @@ object TupleTwo extends Tuple(2)
* second element is the first element of this Tuple.
*/
def swap: Tuple2[T2,T1] = Tuple2(_2, _1)
+
+ @deprecated("Use `zipped` instead.", "2.9.0")
+ def zip[Repr1, El1, El2, To](implicit w1: T1 => TLike[El1, Repr1],
+ w2: T2 => Iterable[El2],
+ cbf1: CBF[Repr1, (El1, El2), To]): To = {
+ zipped map ((x, y) => ((x, y)))
+ }
+
+ /** Wraps a tuple in a `Zipped`, which supports 2-ary generalisations of `map`, `flatMap`, `filter`, etc.
+ * Note that there must be an implicit value to convert this tuple's types into a [[scala.collection.TraversableLike]]
+ * or [[scala.collection.IterableLike]].
+ * {{{
+ * scala> val tuple = (List(1,2,3),List('a','b','c'))
+ * tuple: (List[Int], List[Char]) = (List(1, 2, 3),List(a, b, c))
+ *
+ * scala> tuple.zipped map { (x,y) => x + ":" + y }
+ * res6: List[java.lang.String] = List(1:a, 2:b, 3:c)
+ * }}}
+ *
+ * @see Zipped
+ * Note: will not terminate for infinite-sized collections.
+ */
+ def zipped[Repr1, El1, Repr2, El2](implicit w1: T1 => TLike[El1, Repr1], w2: T2 => ILike[El2, Repr2]): Zipped[Repr1, El1, Repr2, El2]
+ = new Zipped[Repr1, El1, Repr2, El2](_1, _2)
+
+ class Zipped[+Repr1, +El1, +Repr2, +El2](coll1: TLike[El1, Repr1], coll2: ILike[El2, Repr2]) { // coll2: ILike for filter
+ def map[B, To](f: (El1, El2) => B)(implicit cbf: CBF[Repr1, B, To]): To = {
+ val b = cbf(coll1.repr)
+ b.sizeHint(coll1)
+ val elems2 = coll2.iterator
+
+ for (el1 <- coll1) {
+ if (elems2.hasNext)
+ b += f(el1, elems2.next)
+ else
+ return b.result
+ }
+
+ b.result
+ }
+
+ def flatMap[B, To](f: (El1, El2) => TraversableOnce[B])(implicit cbf: CBF[Repr1, B, To]): To = {
+ val b = cbf(coll1.repr)
+ val elems2 = coll2.iterator
+
+ for (el1 <- coll1) {
+ if (elems2.hasNext)
+ b ++= f(el1, elems2.next)
+ else
+ return b.result
+ }
+
+ b.result
+ }
+
+ def filter[To1, To2](f: (El1, El2) => Boolean)(implicit cbf1: CBF[Repr1, El1, To1], cbf2: CBF[Repr2, El2, To2]): (To1, To2) = {
+ val b1 = cbf1(coll1.repr)
+ val b2 = cbf2(coll2.repr)
+ val elems2 = coll2.iterator
+
+ for (el1 <- coll1) {
+ if (elems2.hasNext) {
+ val el2 = elems2.next
+ if (f(el1, el2)) {
+ b1 += el1
+ b2 += el2
+ }
+ }
+ else return (b1.result, b2.result)
+ }
+
+ (b1.result, b2.result)
+ }
+
+ def exists(f: (El1, El2) => Boolean): Boolean = {
+ val elems2 = coll2.iterator
+
+ for (el1 <- coll1) {
+ if (elems2.hasNext) {
+ if (f(el1, elems2.next))
+ return true
+ }
+ else return false
+ }
+ false
+ }
+
+ def forall(f: (El1, El2) => Boolean): Boolean =
+ !exists((x, y) => !f(x, y))
+
+ def foreach[U](f: (El1, El2) => U): Unit = {
+ val elems2 = coll2.iterator
+
+ for (el1 <- coll1) {
+ if (elems2.hasNext)
+ f(el1, elems2.next)
+ else
+ return
+ }
+ }
+ }
"""
}
object TupleThree extends Tuple(3) {
- override def imports = """
-import scala.collection.{ TraversableLike => TLike, IterableLike => ILike }
-import scala.collection.generic.{ CanBuildFrom => CBF }
- """
+ override def imports = Tuple.zipImports
override def moreMethods = """
@deprecated("Use `zipped` instead.", "2.9.0")
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
index f7898f2aa2..aace545ea5 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
@@ -1324,7 +1324,6 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with
val lastInstr = b.lastInstruction
for (instr <- b) {
-
instr match {
case THIS(clasz) => jcode.emitALOAD_0()
diff --git a/src/library/scala/Function0.scala b/src/library/scala/Function0.scala
index cc17f8797a..dceed26439 100644
--- a/src/library/scala/Function0.scala
+++ b/src/library/scala/Function0.scala
@@ -6,7 +6,7 @@
** |/ **
\* */
// GENERATED CODE: DO NOT EDIT.
-// genprod generated these sources at: Tue Apr 24 16:32:13 PDT 2012
+// genprod generated these sources at: Tue Feb 14 16:49:03 PST 2012
package scala
diff --git a/src/library/scala/Function1.scala b/src/library/scala/Function1.scala
index a4391c1509..8995ef912b 100644
--- a/src/library/scala/Function1.scala
+++ b/src/library/scala/Function1.scala
@@ -38,5 +38,21 @@ trait Function1[@specialized(scala.Int, scala.Long, scala.Float, scala.Double, s
*/
def apply(v1: T1): R
+ /** Composes two instances of Function1 in a new Function1, with this function applied last.
+ *
+ * @tparam A the type to which function `g` can be applied
+ * @param g a function A => T1
+ * @return a new function `f` such that `f(x) == apply(g(x))`
+ */
+ def compose[A](g: A => T1): A => R = { x => apply(g(x)) }
+
+ /** Composes two instances of Function1 in a new Function1, with this function applied first.
+ *
+ * @tparam A the result type of function `g`
+ * @param g a function R => A
+ * @return a new function `f` such that `f(x) == g(apply(x))`
+ */
+ def andThen[A](g: R => A): T1 => A = { x => g(apply(x)) }
+
override def toString() = "<function1>"
}
diff --git a/src/library/scala/Function2.scala b/src/library/scala/Function2.scala
index 5ea2b411bb..cacb96ef5d 100644
--- a/src/library/scala/Function2.scala
+++ b/src/library/scala/Function2.scala
@@ -37,6 +37,20 @@ trait Function2[@specialized(scala.Int, scala.Long, scala.Double) -T1, @speciali
* @return the result of function application.
*/
def apply(v1: T1, v2: T2): R
+ /** Creates a curried version of this function.
+ *
+ * @return a function `f` such that `f(x1)(x2) == apply(x1, x2)`
+ */ def curried: T1 => T2 => R = {
+ (x1: T1) => (x2: T2) => apply(x1, x2)
+ }
+ /** Creates a tupled version of this function: instead of 2 arguments,
+ * it accepts a single [[scala.Tuple2]] argument.
+ *
+ * @return a function `f` such that `f((x1, x2)) == f(Tuple2(x1, x2)) == apply(x1, x2)`
+ */
+ def tupled: Tuple2[T1, T2] => R = {
+ case Tuple2(x1, x2) => apply(x1, x2)
+ }
override def toString() = "<function2>"
}
diff --git a/src/library/scala/PartialFunction.scala b/src/library/scala/PartialFunction.scala
index fafaef9c2f..7154b8da34 100644
--- a/src/library/scala/PartialFunction.scala
+++ b/src/library/scala/PartialFunction.scala
@@ -78,7 +78,7 @@ trait PartialFunction[-A, +B] extends (A => B) { self =>
* @return a partial function with the same domain as this partial function, which maps
* arguments `x` to `k(this(x))`.
*/
- def andThen[C](k: B => C) : PartialFunction[A, C] = new PartialFunction[A, C] {
+ override def andThen[C](k: B => C) : PartialFunction[A, C] = new PartialFunction[A, C] {
def isDefinedAt(x: A): Boolean = self isDefinedAt x
def apply(x: A): C = k(self(x))
}
diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala
index 96b8b6d8d5..d2aa3a8b34 100644
--- a/src/library/scala/Predef.scala
+++ b/src/library/scala/Predef.scala
@@ -308,11 +308,11 @@ object Predef extends LowPriorityImplicits {
// views --------------------------------------------------------------
implicit def exceptionWrapper(exc: Throwable) = new runtime.RichException(exc)
- implicit def function1ToRichFunction1[T, R](f: T => R): runtime.RichFunction1[T, R] = new runtime.RichFunction1(f)
- implicit def function2ToRichFunction2[T1, T2, R](f: (T1, T2) => R): runtime.RichFunction2[T1, T2, R] =
- new runtime.RichFunction2(f)
- implicit def tuple2ToZipped[T1, T2](zz: (T1, T2)) = new runtime.Tuple2ZippedOps(zz)
+ implicit def zipped2ToTraversable[El1, El2](zz: Tuple2[_, _]#Zipped[_, El1, _, El2]): Traversable[(El1, El2)] =
+ new collection.AbstractTraversable[(El1, El2)] {
+ def foreach[U](f: ((El1, El2)) => U): Unit = zz foreach Function.untupled(f)
+ }
implicit def zipped3ToTraversable[El1, El2, El3](zz: Tuple3[_, _, _]#Zipped[_, El1, _, El2, _, El3]): Traversable[(El1, El2, El3)] =
new collection.AbstractTraversable[(El1, El2, El3)] {
diff --git a/src/library/scala/Tuple2.scala b/src/library/scala/Tuple2.scala
index 924b2b6fe3..37ab564c3c 100644
--- a/src/library/scala/Tuple2.scala
+++ b/src/library/scala/Tuple2.scala
@@ -9,6 +9,9 @@
package scala
+import scala.collection.{ TraversableLike => TLike, IterableLike => ILike }
+import scala.collection.generic.{ CanBuildFrom => CBF }
+
/** A tuple of 2 elements; the canonical representation of a [[scala.Product2]].
*
@@ -27,4 +30,115 @@ case class Tuple2[@specialized(Int, Long, Double, Char, Boolean, AnyRef) +T1, @s
*/
def swap: Tuple2[T2,T1] = Tuple2(_2, _1)
+ @deprecated("Use `zipped` instead.", "2.9.0")
+ def zip[Repr1, El1, El2, To](implicit w1: T1 => TLike[El1, Repr1],
+ w2: T2 => Iterable[El2],
+ cbf1: CBF[Repr1, (El1, El2), To]): To = {
+ zipped map ((x, y) => ((x, y)))
+ }
+
+ /** Wraps a tuple in a `Zipped`, which supports 2-ary generalisations of `map`, `flatMap`, `filter`, etc.
+ * Note that there must be an implicit value to convert this tuple's types into a [[scala.collection.TraversableLike]]
+ * or [[scala.collection.IterableLike]].
+ * {{{
+ * scala> val tuple = (List(1,2,3),List('a','b','c'))
+ * tuple: (List[Int], List[Char]) = (List(1, 2, 3),List(a, b, c))
+ *
+ * scala> tuple.zipped map { (x,y) => x + ":" + y }
+ * res6: List[java.lang.String] = List(1:a, 2:b, 3:c)
+ * }}}
+ *
+ * @see Zipped
+ * Note: will not terminate for infinite-sized collections.
+ */
+ def zipped[Repr1, El1, Repr2, El2](implicit w1: T1 => TLike[El1, Repr1], w2: T2 => ILike[El2, Repr2]): Zipped[Repr1, El1, Repr2, El2]
+ = new Zipped[Repr1, El1, Repr2, El2](_1, _2)
+
+ /**
+ * @define coll zipped
+ * @define Coll Zipped
+ * @define orderDependent
+ * @define orderDependentFold
+ * @define mayNotTerminateInf
+ * @define willNotTerminateInf
+ * @define collectExample
+ * @define undefinedorder
+ */
+ class Zipped[+Repr1, +El1, +Repr2, +El2](coll1: TLike[El1, Repr1], coll2: ILike[El2, Repr2]) { // coll2: ILike for filter
+ def map[B, To](f: (El1, El2) => B)(implicit cbf: CBF[Repr1, B, To]): To = {
+ val b = cbf(coll1.repr)
+ b.sizeHint(coll1)
+ val elems2 = coll2.iterator
+
+ for (el1 <- coll1) {
+ if (elems2.hasNext)
+ b += f(el1, elems2.next)
+ else
+ return b.result
+ }
+
+ b.result
+ }
+
+ def flatMap[B, To](f: (El1, El2) => TraversableOnce[B])(implicit cbf: CBF[Repr1, B, To]): To = {
+ val b = cbf(coll1.repr)
+ val elems2 = coll2.iterator
+
+ for (el1 <- coll1) {
+ if (elems2.hasNext)
+ b ++= f(el1, elems2.next)
+ else
+ return b.result
+ }
+
+ b.result
+ }
+
+ def filter[To1, To2](f: (El1, El2) => Boolean)(implicit cbf1: CBF[Repr1, El1, To1], cbf2: CBF[Repr2, El2, To2]): (To1, To2) = {
+ val b1 = cbf1(coll1.repr)
+ val b2 = cbf2(coll2.repr)
+ val elems2 = coll2.iterator
+
+ for (el1 <- coll1) {
+ if (elems2.hasNext) {
+ val el2 = elems2.next
+ if (f(el1, el2)) {
+ b1 += el1
+ b2 += el2
+ }
+ }
+ else return (b1.result, b2.result)
+ }
+
+ (b1.result, b2.result)
+ }
+
+ def exists(f: (El1, El2) => Boolean): Boolean = {
+ val elems2 = coll2.iterator
+
+ for (el1 <- coll1) {
+ if (elems2.hasNext) {
+ if (f(el1, elems2.next))
+ return true
+ }
+ else return false
+ }
+ false
+ }
+
+ def forall(f: (El1, El2) => Boolean): Boolean =
+ !exists((x, y) => !f(x, y))
+
+ def foreach[U](f: (El1, El2) => U): Unit = {
+ val elems2 = coll2.iterator
+
+ for (el1 <- coll1) {
+ if (elems2.hasNext)
+ f(el1, elems2.next)
+ else
+ return
+ }
+ }
+ }
+
}
diff --git a/src/library/scala/Tuple3.scala b/src/library/scala/Tuple3.scala
index dfa0c962a2..cd5ee23757 100644
--- a/src/library/scala/Tuple3.scala
+++ b/src/library/scala/Tuple3.scala
@@ -53,6 +53,17 @@ case class Tuple3[+T1, +T2, +T3](_1: T1, _2: T2, _3: T3)
w3: T3 => ILike[El3, Repr3]): Zipped[Repr1, El1, Repr2, El2, Repr3, El3]
= new Zipped[Repr1, El1, Repr2, El2, Repr3, El3](_1, _2, _3)
+ /**
+ * @define coll zipped
+ * @define Coll Zipped
+ * @define orderDependent
+ * @define orderDependentFold
+ * @define mayNotTerminateInf
+ * @define willNotTerminateInf
+ * @define collectExample
+ * @define undefinedorder
+ * @define thatInfo The class of the returned collection.
+ */
class Zipped[+Repr1, +El1, +Repr2, +El2, +Repr3, +El3](coll1: TLike[El1, Repr1],
coll2: ILike[El2, Repr2],
coll3: ILike[El3, Repr3]) {
diff --git a/src/library/scala/runtime/RichFunction1.scala b/src/library/scala/runtime/RichFunction1.scala
deleted file mode 100644
index 26651b8d6a..0000000000
--- a/src/library/scala/runtime/RichFunction1.scala
+++ /dev/null
@@ -1,27 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.runtime
-
-@inline final class RichFunction1[-T1, +R](f: T1 => R) {
- /** Composes two instances of Function1 in a new Function1, with the function on the left applied last.
- *
- * @tparam A the type to which function `g` can be applied
- * @param g a function A => T1
- * @return a new function `h` such that `h(x) == f(g(x))`
- */
- def compose[A](g: A => T1): A => R = { x => f(g(x)) }
-
- /** Composes two instances of Function1 in a new Function1, with the function on the left applied first.
- *
- * @tparam A the result type of function `g`
- * @param g a function R => A
- * @return a new function `h` such that `h(x) == g(f(x))`
- */
- def andThen[A](g: R => A): T1 => A = { x => g(f(x)) }
-}
diff --git a/src/library/scala/runtime/RichFunction2.scala b/src/library/scala/runtime/RichFunction2.scala
deleted file mode 100644
index 14e23be31b..0000000000
--- a/src/library/scala/runtime/RichFunction2.scala
+++ /dev/null
@@ -1,26 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.runtime
-
-@inline final class RichFunction2[-T1, -T2, +R](f: (T1, T2) => R) {
- /** Creates a curried version of this function.
- *
- * @return a function `f` such that `f(x1)(x2) == apply(x1, x2)`
- */
- def curried: T1 => T2 => R = (x1: T1) => (x2: T2) => f(x1, x2)
-
- /** Creates a tupled version of this function: instead of 2 arguments,
- * it accepts a single [[scala.Tuple2]] argument.
- *
- * @return a function `f` such that `f((x1, x2)) == f(Tuple2(x1, x2)) == apply(x1, x2)`
- */
- def tupled: ((T1, T2)) => R = {
- case Tuple2(x1, x2) => f(x1, x2)
- }
-}
diff --git a/src/library/scala/runtime/Tuple2Zipped.scala b/src/library/scala/runtime/Tuple2Zipped.scala
deleted file mode 100644
index 2eb2a47e46..0000000000
--- a/src/library/scala/runtime/Tuple2Zipped.scala
+++ /dev/null
@@ -1,109 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.runtime
-
-import scala.collection.{ TraversableLike => TLike, IterableLike => ILike }
-import scala.collection.generic.{ CanBuildFrom => CBF }
-
- /** Wraps a tuple in a `Zipped`, which supports 2-ary generalisations of `map`, `flatMap`, `filter`, etc.
- * Note that there must be an implicit value to convert this tuple's types into a [[scala.collection.TraversableLike]]
- * or [[scala.collection.IterableLike]].
- * {{{
- * scala> val tuple = (List(1,2,3),List('a','b','c'))
- * tuple: (List[Int], List[Char]) = (List(1, 2, 3),List(a, b, c))
- *
- * scala> tuple.zipped map { (x,y) => x + ":" + y }
- * res6: List[java.lang.String] = List(1:a, 2:b, 3:c)
- * }}}
- *
- * @see Zipped
- * Note: will not terminate for infinite-sized collections.
- */
-@inline private[scala] final class Tuple2Zipped[+Repr1, +El1, +Repr2, +El2](coll1: TLike[El1, Repr1], coll2: ILike[El2, Repr2]) {
- // coll2: ILike for filter
- def map[B, To](f: (El1, El2) => B)(implicit cbf: CBF[Repr1, B, To]): To = {
- val b = cbf(coll1.repr)
- b.sizeHint(coll1)
- val elems2 = coll2.iterator
-
- for (el1 <- coll1) {
- if (elems2.hasNext)
- b += f(el1, elems2.next)
- else
- return b.result
- }
-
- b.result
- }
-
- def flatMap[B, To](f: (El1, El2) => TraversableOnce[B])(implicit cbf: CBF[Repr1, B, To]): To = {
- val b = cbf(coll1.repr)
- val elems2 = coll2.iterator
-
- for (el1 <- coll1) {
- if (elems2.hasNext)
- b ++= f(el1, elems2.next)
- else
- return b.result
- }
-
- b.result
- }
-
- def filter[To1, To2](f: (El1, El2) => Boolean)(implicit cbf1: CBF[Repr1, El1, To1], cbf2: CBF[Repr2, El2, To2]): (To1, To2) = {
- val b1 = cbf1(coll1.repr)
- val b2 = cbf2(coll2.repr)
- val elems2 = coll2.iterator
-
- for (el1 <- coll1) {
- if (elems2.hasNext) {
- val el2 = elems2.next
- if (f(el1, el2)) {
- b1 += el1
- b2 += el2
- }
- }
- else return (b1.result, b2.result)
- }
-
- (b1.result, b2.result)
- }
-
- def exists(f: (El1, El2) => Boolean): Boolean = {
- val elems2 = coll2.iterator
-
- for (el1 <- coll1) {
- if (elems2.hasNext) {
- if (f(el1, elems2.next))
- return true
- }
- else return false
- }
- false
- }
-
- def forall(f: (El1, El2) => Boolean): Boolean =
- !exists((x, y) => !f(x, y))
-
- def foreach[U](f: (El1, El2) => U): Unit = {
- val elems2 = coll2.iterator
-
- for (el1 <- coll1) {
- if (elems2.hasNext)
- f(el1, elems2.next)
- else
- return
- }
- }
-}
-
-@inline private[scala] final class Tuple2ZippedOps[T1, T2](zz: (T1, T2)) {
- def zipped[Repr1, El1, Repr2, El2](implicit w1: T1 => TLike[El1, Repr1], w2: T2 => ILike[El2, Repr2]) =
- new Tuple2Zipped[Repr1, El1, Repr2, El2](w1(zz._1), w2(zz._2))
-}
diff --git a/test/files/neg/t5067.check b/test/files/neg/t5067.check
index 395eda7442..32491766d7 100644
--- a/test/files/neg/t5067.check
+++ b/test/files/neg/t5067.check
@@ -1,6 +1,6 @@
t5067.scala:3: error: type mismatch;
- found : ((Int, Int, Int)) => Int
- required: (Int, Int, Int) => Int
- override def tupled: (Int, Int, Int) => Int = super.tupled
- ^
+ found : ((Int, Int)) => Int
+ required: (Int, Int) => Int
+ override def tupled: (Int, Int) => Int = super.tupled
+ ^
one error found
diff --git a/test/files/neg/t5067.scala b/test/files/neg/t5067.scala
index 0a961d2f40..f8235c0e83 100644
--- a/test/files/neg/t5067.scala
+++ b/test/files/neg/t5067.scala
@@ -1,4 +1,4 @@
-class Foo extends Function3[Int, Int, Int, Int] {
- def apply(x: Int, y: Int, z: Int) = x + y + z
- override def tupled: (Int, Int, Int) => Int = super.tupled
+class Foo extends Function2[Int, Int, Int] {
+ def apply(x: Int, y: Int) = x + y
+ override def tupled: (Int, Int) => Int = super.tupled
}
diff --git a/test/files/run/tuple-zipped.scala b/test/files/run/tuple-zipped.scala
index 08dcc82de6..a9851346bc 100644
--- a/test/files/run/tuple-zipped.scala
+++ b/test/files/run/tuple-zipped.scala
@@ -15,7 +15,7 @@ object Test {
def main(args: Array[String]): Unit = {
for (cc1 <- xss1 ; cc2 <- xss2) {
- val sum1 = (cc1 zip cc2) map { case (x, y) => x + y } sum
+ val sum1 = (cc1, cc2).zip map { case (x, y) => x + y } sum
val sum2 = (cc1, cc2).zipped map (_ + _) sum
assert(sum1 == sum2)