summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeth Tisue <seth@tisue.net>2015-10-16 13:38:20 +0200
committerSeth Tisue <seth@tisue.net>2015-10-16 13:48:14 +0200
commit3141fdd6628df5c123db0250abc8ccfcf20d7eff (patch)
tree9f96dbbf3f27dd4ed3105b7b0562c46e39441220
parentc99e53e8a05fc5d45f8e8a28da68d3977be65bfa (diff)
parentae5f0de71686a250d1bfa72db530015c0f9ddb3a (diff)
downloadscala-3141fdd6628df5c123db0250abc8ccfcf20d7eff.tar.gz
scala-3141fdd6628df5c123db0250abc8ccfcf20d7eff.tar.bz2
scala-3141fdd6628df5c123db0250abc8ccfcf20d7eff.zip
merge 2.11.x onto 2.12.x, Oct 16 2015
there were merge conflicts in the Eclipse config that I resolved with --ours. I invite @performantdata to submit a followup PR bringing the Eclipse stuff into a good state on 2.12.x. there was a test failure in test/junit/scala/collection/mutable/OpenHashMapTest.scala due to the 2.12 compiler emitting the field backing a private var differently (with an unmangled name). Lukas says the difference is expected, so I just updated the code in the test. there were no other merge conflicts. % git log --decorate --oneline -1 origin/2.11.x | cat ae5f0de (origin/HEAD, origin/2.11.x) Merge pull request #4791 from performantdata/issue/9508 % git log --decorate --oneline -1 origin/2.12.x | cat c99e53e (HEAD -> 2.12.x, origin/2.12.x) Merge pull request #4797 from lrytz/M3-versions % export MB=$(git merge-base 2.12.x origin/2.11.x) % echo $MB 42cafa21f3c4a08c6dd34608278f810b6ec2886f % git log --graph --oneline --decorate $MB...origin/2.11.x | cat * ae5f0de (origin/HEAD, origin/2.11.x) Merge pull request #4791 from performantdata/issue/9508 |\ | * 08dca37 (origin/pull/4791) SI-9508 fix classpaths in Eclipse configuration * | fe76232 Merge pull request #4798 from performantdata/issue/9513 |\ \ | * | 9c97a7f (origin/pull/4798) Suppress unneeded import. | * | 30d704d Document some OpenHashMap internal methods. | * | 1fb32fc SI-9513 decrement "deleted" count in OpenHashMap.put() when slot reused | |/ * | 14f875c Merge pull request #4788 from dk14/patch-1 |\ \ | * | 42acd55 (origin/pull/4788) explicitly specify insertion-order feature in docs | / * | 68ce049 Merge pull request #4771 from som-snytt/issue/9492-here |\ \ | * | f290962 (origin/pull/4771) SI-9492 Line trimming paste | * | bc3589d SI-9492 REPL paste here doc | / * | 9834fc8 Merge pull request #4610 from todesking/spec-implicits-remove-obsolete |\ \ | * | 46009b1 (origin/pull/4610) Add view/context-bound parameter ordering rule | * | 6eba305 Spec: Implicit parameters with context/view bound is allowed since 2.10 | / * | d792e35 Merge pull request #4789 from janekdb/2.11.x-param-names-predicates-operations |\ \ | |/ |/| | * b19a07e (origin/pull/4789) Rename forall, exists and find predicate and operator params. |/ * 648c7a1 Merge pull request #4790 from SethTisue/issue/9501 |\ | * 40d12f1 (origin/pull/4790) SI-9501 link README to Scala Hacker Guide * e0b5891 Merge pull request #4786 from performantdata/issue/9506 * 39acad8 (origin/pull/4786) SI-9506 suppress Scala IDE-generated files in the Eclipse project dirs * 74dc364 SI-9506 suppress Scala IDE-generated files in the Eclipse project dirs % git merge ae5f0de Auto-merging src/repl/scala/tools/nsc/interpreter/ILoop.scala Auto-merging src/library/scala/util/Either.scala Auto-merging src/library/scala/runtime/Tuple3Zipped.scala Auto-merging src/library/scala/runtime/Tuple2Zipped.scala Auto-merging src/library/scala/collection/parallel/ParIterableLike.scala Auto-merging src/library/scala/collection/immutable/ListMap.scala Auto-merging src/library/scala/collection/TraversableLike.scala Auto-merging src/eclipse/test-junit/.classpath CONFLICT (content): Merge conflict in src/eclipse/test-junit/.classpath Auto-merging src/eclipse/scaladoc/.classpath CONFLICT (content): Merge conflict in src/eclipse/scaladoc/.classpath Auto-merging src/eclipse/scala-compiler/.classpath Auto-merging src/eclipse/repl/.classpath CONFLICT (content): Merge conflict in src/eclipse/repl/.classpath Auto-merging src/eclipse/partest/.classpath CONFLICT (content): Merge conflict in src/eclipse/partest/.classpath Auto-merging src/eclipse/interactive/.classpath Auto-merging README.md Automatic merge failed; fix conflicts and then commit the result. % git checkout --ours src/eclipse/partest/.classpath % git checkout --ours src/eclipse/repl/.classpath % git checkout --ours src/eclipse/scaladoc/.classpath % git checkout --ours src/eclipse/test-junit/.classpath % git add -u % emacs test/junit/scala/collection/mutable/OpenHashMapTest.scala % git diff test/junit/scala/collection/mutable/OpenHashMapTest.scala | cat ... - val field = m.getClass.getDeclaredField("scala$collection$mutable$OpenHashMap$$deleted") + val field = m.getClass.getDeclaredField("deleted") ... % git add -u
-rw-r--r--README.md11
-rw-r--r--spec/07-implicits.md12
-rw-r--r--src/eclipse/interactive/.gitignore2
-rw-r--r--src/eclipse/partest/.gitignore2
-rw-r--r--src/eclipse/reflect/.gitignore2
-rw-r--r--src/eclipse/repl/.gitignore2
-rw-r--r--src/eclipse/scala-compiler/.gitignore2
-rw-r--r--src/eclipse/scala-library/.gitignore2
-rw-r--r--src/eclipse/scaladoc/.gitignore2
-rw-r--r--src/eclipse/scalap/.gitignore2
-rw-r--r--src/eclipse/test-junit/.gitignore2
-rw-r--r--src/library/scala/collection/GenTraversableOnce.scala23
-rw-r--r--src/library/scala/collection/TraversableLike.scala2
-rw-r--r--src/library/scala/collection/immutable/ListMap.scala2
-rw-r--r--src/library/scala/collection/immutable/RedBlackTree.scala4
-rw-r--r--src/library/scala/collection/immutable/Set.scala74
-rw-r--r--src/library/scala/collection/mutable/OpenHashMap.scala19
-rw-r--r--src/library/scala/collection/parallel/ParIterableLike.scala18
-rw-r--r--src/library/scala/runtime/Tuple2Zipped.scala8
-rw-r--r--src/library/scala/runtime/Tuple3Zipped.scala8
-rw-r--r--src/library/scala/util/Either.scala12
-rw-r--r--src/repl/scala/tools/nsc/interpreter/ILoop.scala51
-rw-r--r--src/repl/scala/tools/nsc/interpreter/ReplProps.scala2
-rw-r--r--test/files/run/repl-paste-5.check28
-rw-r--r--test/files/run/repl-paste-5.scala18
-rw-r--r--test/junit/scala/collection/mutable/OpenHashMapTest.scala42
26 files changed, 264 insertions, 88 deletions
diff --git a/README.md b/README.md
index 40c61a0aa1..ea61d72122 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,18 @@
# Welcome!
This is the official repository for the [Scala Programming Language](http://www.scala-lang.org).
+# How to contribute
+
To contribute to the Scala Standard Library, Scala Compiler and Scala Language Specification, please send us a [pull request](https://help.github.com/articles/using-pull-requests/#fork--pull) from your fork of this repository! We do have to ask you to sign the [Scala CLA](http://typesafe.com/contribute/cla/scala) before we can merge any of your work into our code base, to protect its open source nature.
-For more information on building and developing the core of Scala, read on! Please also check out our [guidelines for contributing](CONTRIBUTING.md).
+For more information on building and developing the core of Scala, read on!
+
+Please also check out:
+
+* our [guidelines for contributing](CONTRIBUTING.md).
+* the ["Scala Hacker Guide"](http://scala-lang.org/contribute/hacker-guide.html) covers some of the same ground as this README, but in greater detail and in a more tutorial style, using a running example.
+
+# Reporting issues
We're still using Jira for issue reporting, so please [report any issues](https://issues.scala-lang.org) over there.
(We would love to start using GitHub Issues, but we're too resource-constrained to take on this migration right now.)
diff --git a/spec/07-implicits.md b/spec/07-implicits.md
index 726320ed33..28f6dfe5a8 100644
--- a/spec/07-implicits.md
+++ b/spec/07-implicits.md
@@ -357,8 +357,16 @@ they appear and all the resulting evidence parameters are concatenated
in one implicit parameter section. Since traits do not take
constructor parameters, this translation does not work for them.
Consequently, type-parameters in traits may not be view- or context-bounded.
-Also, a method or class with view- or context bounds may not define any
-additional implicit parameters.
+
+Evidence parameters are prepended to the existing implicit parameter section, if one exists.
+
+For example:
+
+```scala
+def foo[A: M](implicit b: B): C
+// expands to:
+// def foo[A](implicit evidence$1: M[A], b: B): C
+```
###### Example
The `<=` method from the [`Ordered` example](#example-ordered) can be declared
diff --git a/src/eclipse/interactive/.gitignore b/src/eclipse/interactive/.gitignore
new file mode 100644
index 0000000000..fe789dd686
--- /dev/null
+++ b/src/eclipse/interactive/.gitignore
@@ -0,0 +1,2 @@
+# what appears to be a Scala IDE-generated file
+.cache-main
diff --git a/src/eclipse/partest/.gitignore b/src/eclipse/partest/.gitignore
new file mode 100644
index 0000000000..fe789dd686
--- /dev/null
+++ b/src/eclipse/partest/.gitignore
@@ -0,0 +1,2 @@
+# what appears to be a Scala IDE-generated file
+.cache-main
diff --git a/src/eclipse/reflect/.gitignore b/src/eclipse/reflect/.gitignore
new file mode 100644
index 0000000000..fe789dd686
--- /dev/null
+++ b/src/eclipse/reflect/.gitignore
@@ -0,0 +1,2 @@
+# what appears to be a Scala IDE-generated file
+.cache-main
diff --git a/src/eclipse/repl/.gitignore b/src/eclipse/repl/.gitignore
new file mode 100644
index 0000000000..fe789dd686
--- /dev/null
+++ b/src/eclipse/repl/.gitignore
@@ -0,0 +1,2 @@
+# what appears to be a Scala IDE-generated file
+.cache-main
diff --git a/src/eclipse/scala-compiler/.gitignore b/src/eclipse/scala-compiler/.gitignore
new file mode 100644
index 0000000000..fe789dd686
--- /dev/null
+++ b/src/eclipse/scala-compiler/.gitignore
@@ -0,0 +1,2 @@
+# what appears to be a Scala IDE-generated file
+.cache-main
diff --git a/src/eclipse/scala-library/.gitignore b/src/eclipse/scala-library/.gitignore
new file mode 100644
index 0000000000..fe789dd686
--- /dev/null
+++ b/src/eclipse/scala-library/.gitignore
@@ -0,0 +1,2 @@
+# what appears to be a Scala IDE-generated file
+.cache-main
diff --git a/src/eclipse/scaladoc/.gitignore b/src/eclipse/scaladoc/.gitignore
new file mode 100644
index 0000000000..fe789dd686
--- /dev/null
+++ b/src/eclipse/scaladoc/.gitignore
@@ -0,0 +1,2 @@
+# what appears to be a Scala IDE-generated file
+.cache-main
diff --git a/src/eclipse/scalap/.gitignore b/src/eclipse/scalap/.gitignore
new file mode 100644
index 0000000000..fe789dd686
--- /dev/null
+++ b/src/eclipse/scalap/.gitignore
@@ -0,0 +1,2 @@
+# what appears to be a Scala IDE-generated file
+.cache-main
diff --git a/src/eclipse/test-junit/.gitignore b/src/eclipse/test-junit/.gitignore
new file mode 100644
index 0000000000..fe789dd686
--- /dev/null
+++ b/src/eclipse/test-junit/.gitignore
@@ -0,0 +1,2 @@
+# what appears to be a Scala IDE-generated file
+.cache-main
diff --git a/src/library/scala/collection/GenTraversableOnce.scala b/src/library/scala/collection/GenTraversableOnce.scala
index f77462ce88..a45ec965f5 100644
--- a/src/library/scala/collection/GenTraversableOnce.scala
+++ b/src/library/scala/collection/GenTraversableOnce.scala
@@ -393,20 +393,35 @@ trait GenTraversableOnce[+A] extends Any {
*/
def minBy[B](f: A => B)(implicit cmp: Ordering[B]): A
- def forall(pred: A => Boolean): Boolean
+ /** Tests whether a predicate holds for all elements of this $coll.
+ *
+ * $mayNotTerminateInf
+ *
+ * @param p the predicate used to test elements.
+ * @return `true` if this $coll is empty or the given predicate `p`
+ * holds for all elements of this $coll, otherwise `false`.
+ */
+ def forall(@deprecatedName('pred) p: A => Boolean): Boolean
- def exists(pred: A => Boolean): Boolean
+ /** Tests whether a predicate holds for at least one element of this $coll.
+ *
+ * $mayNotTerminateInf
+ *
+ * @param p the predicate used to test elements.
+ * @return `true` if the given predicate `p` is satisfied by at least one element of this $coll, otherwise `false`
+ */
+ def exists(@deprecatedName('pred) p: A => Boolean): Boolean
/** Finds the first element of the $coll satisfying a predicate, if any.
*
* $mayNotTerminateInf
* $orderDependent
*
- * @param pred the predicate used to test elements.
+ * @param p the predicate used to test elements.
* @return an option value containing the first element in the $coll
* that satisfies `p`, or `None` if none exists.
*/
- def find(pred: A => Boolean): Option[A]
+ def find(@deprecatedName('pred) p: A => Boolean): Option[A]
/** Copies values of this $coll to an array.
* Fills the given array `xs` with values of this $coll.
diff --git a/src/library/scala/collection/TraversableLike.scala b/src/library/scala/collection/TraversableLike.scala
index f187a7a655..a0b1430d17 100644
--- a/src/library/scala/collection/TraversableLike.scala
+++ b/src/library/scala/collection/TraversableLike.scala
@@ -357,7 +357,7 @@ trait TraversableLike[+A, +Repr] extends Any
result
}
- /** Tests whether a predicate holds for some of the elements of this $coll.
+ /** Tests whether a predicate holds for at least one element of this $coll.
*
* $mayNotTerminateInf
*
diff --git a/src/library/scala/collection/immutable/ListMap.scala b/src/library/scala/collection/immutable/ListMap.scala
index c5773338f5..c59f4f7436 100644
--- a/src/library/scala/collection/immutable/ListMap.scala
+++ b/src/library/scala/collection/immutable/ListMap.scala
@@ -36,7 +36,7 @@ object ListMap extends ImmutableMapFactory[ListMap] {
}
}
-/** This class implements immutable maps using a list-based data structure.
+/** This class implements immutable maps using a list-based data structure, which preserves insertion order.
* Instances of `ListMap` represent empty maps; they can be either created by
* calling the constructor directly, or by applying the function `ListMap.empty`.
*
diff --git a/src/library/scala/collection/immutable/RedBlackTree.scala b/src/library/scala/collection/immutable/RedBlackTree.scala
index 7e8cfcc902..afb4c9c552 100644
--- a/src/library/scala/collection/immutable/RedBlackTree.scala
+++ b/src/library/scala/collection/immutable/RedBlackTree.scala
@@ -409,11 +409,11 @@ object RedBlackTree {
def cons[B](x: B, xs: NList[B]): NList[B] = new NList(x, xs)
- def foldLeft[A, B](xs: NList[A], z: B)(f: (B, A) => B): B = {
+ def foldLeft[A, B](xs: NList[A], z: B)(op: (B, A) => B): B = {
var acc = z
var these = xs
while (these ne null) {
- acc = f(acc, these.head)
+ acc = op(acc, these.head)
these = these.tail
}
acc
diff --git a/src/library/scala/collection/immutable/Set.scala b/src/library/scala/collection/immutable/Set.scala
index a115469b83..031e5248c1 100644
--- a/src/library/scala/collection/immutable/Set.scala
+++ b/src/library/scala/collection/immutable/Set.scala
@@ -33,7 +33,7 @@ trait Set[A] extends Iterable[A]
with Parallelizable[A, ParSet[A]]
{
override def companion: GenericCompanion[Set] = Set
-
+
/** Returns this $coll as an immutable set, perhaps accepting a
* wider range of elements. Since it already is an
@@ -63,7 +63,7 @@ trait Set[A] extends Iterable[A]
object Set extends ImmutableSetFactory[Set] {
/** $setCanBuildFromInfo */
implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, Set[A]] = setCanBuildFrom[A]
-
+
/** An optimized representation for immutable empty sets */
private object EmptySet extends AbstractSet[Any] with Set[Any] with Serializable {
override def size: Int = 0
@@ -71,7 +71,7 @@ object Set extends ImmutableSetFactory[Set] {
def + (elem: Any): Set[Any] = new Set1(elem)
def - (elem: Any): Set[Any] = this
def iterator: Iterator[Any] = Iterator.empty
- override def foreach[U](f: Any => U): Unit = {}
+ override def foreach[U](f: Any => U): Unit = ()
override def toSet[B >: Any]: Set[B] = this.asInstanceOf[Set[B]]
}
private[collection] def emptyInstance: Set[Any] = EmptySet
@@ -90,17 +90,17 @@ object Set extends ImmutableSetFactory[Set] {
else this
def iterator: Iterator[A] =
Iterator(elem1)
- override def foreach[U](f: A => U): Unit = {
+ override def foreach[U](f: A => U): Unit = {
f(elem1)
}
- override def exists(f: A => Boolean): Boolean = {
- f(elem1)
+ override def exists(@deprecatedName('f) p: A => Boolean): Boolean = {
+ p(elem1)
}
- override def forall(f: A => Boolean): Boolean = {
- f(elem1)
+ override def forall(@deprecatedName('f) p: A => Boolean): Boolean = {
+ p(elem1)
}
- override def find(f: A => Boolean): Option[A] = {
- if (f(elem1)) Some(elem1)
+ override def find(@deprecatedName('f) p: A => Boolean): Option[A] = {
+ if (p(elem1)) Some(elem1)
else None
}
// Why is Set1 non-final? Need to fix that!
@@ -124,18 +124,18 @@ object Set extends ImmutableSetFactory[Set] {
else this
def iterator: Iterator[A] =
Iterator(elem1, elem2)
- override def foreach[U](f: A => U): Unit = {
+ override def foreach[U](f: A => U): Unit = {
f(elem1); f(elem2)
}
- override def exists(f: A => Boolean): Boolean = {
- f(elem1) || f(elem2)
+ override def exists(@deprecatedName('f) p: A => Boolean): Boolean = {
+ p(elem1) || p(elem2)
}
- override def forall(f: A => Boolean): Boolean = {
- f(elem1) && f(elem2)
+ override def forall(@deprecatedName('f) p: A => Boolean): Boolean = {
+ p(elem1) && p(elem2)
}
- override def find(f: A => Boolean): Option[A] = {
- if (f(elem1)) Some(elem1)
- else if (f(elem2)) Some(elem2)
+ override def find(@deprecatedName('f) p: A => Boolean): Option[A] = {
+ if (p(elem1)) Some(elem1)
+ else if (p(elem2)) Some(elem2)
else None
}
// Why is Set2 non-final? Need to fix that!
@@ -159,19 +159,19 @@ object Set extends ImmutableSetFactory[Set] {
else this
def iterator: Iterator[A] =
Iterator(elem1, elem2, elem3)
- override def foreach[U](f: A => U): Unit = {
+ override def foreach[U](f: A => U): Unit = {
f(elem1); f(elem2); f(elem3)
}
- override def exists(f: A => Boolean): Boolean = {
- f(elem1) || f(elem2) || f(elem3)
+ override def exists(@deprecatedName('f) p: A => Boolean): Boolean = {
+ p(elem1) || p(elem2) || p(elem3)
}
- override def forall(f: A => Boolean): Boolean = {
- f(elem1) && f(elem2) && f(elem3)
+ override def forall(@deprecatedName('f) p: A => Boolean): Boolean = {
+ p(elem1) && p(elem2) && p(elem3)
}
- override def find(f: A => Boolean): Option[A] = {
- if (f(elem1)) Some(elem1)
- else if (f(elem2)) Some(elem2)
- else if (f(elem3)) Some(elem3)
+ override def find(@deprecatedName('f) p: A => Boolean): Option[A] = {
+ if (p(elem1)) Some(elem1)
+ else if (p(elem2)) Some(elem2)
+ else if (p(elem3)) Some(elem3)
else None
}
// Why is Set3 non-final? Need to fix that!
@@ -196,20 +196,20 @@ object Set extends ImmutableSetFactory[Set] {
else this
def iterator: Iterator[A] =
Iterator(elem1, elem2, elem3, elem4)
- override def foreach[U](f: A => U): Unit = {
+ override def foreach[U](f: A => U): Unit = {
f(elem1); f(elem2); f(elem3); f(elem4)
}
- override def exists(f: A => Boolean): Boolean = {
- f(elem1) || f(elem2) || f(elem3) || f(elem4)
+ override def exists(@deprecatedName('f) p: A => Boolean): Boolean = {
+ p(elem1) || p(elem2) || p(elem3) || p(elem4)
}
- override def forall(f: A => Boolean): Boolean = {
- f(elem1) && f(elem2) && f(elem3) && f(elem4)
+ override def forall(@deprecatedName('f) p: A => Boolean): Boolean = {
+ p(elem1) && p(elem2) && p(elem3) && p(elem4)
}
- override def find(f: A => Boolean): Option[A] = {
- if (f(elem1)) Some(elem1)
- else if (f(elem2)) Some(elem2)
- else if (f(elem3)) Some(elem3)
- else if (f(elem4)) Some(elem4)
+ override def find(@deprecatedName('f) p: A => Boolean): Option[A] = {
+ if (p(elem1)) Some(elem1)
+ else if (p(elem2)) Some(elem2)
+ else if (p(elem3)) Some(elem3)
+ else if (p(elem4)) Some(elem4)
else None
}
// Why is Set4 non-final? Need to fix that!
diff --git a/src/library/scala/collection/mutable/OpenHashMap.scala b/src/library/scala/collection/mutable/OpenHashMap.scala
index 24f5761cf5..5f8f5b9a0a 100644
--- a/src/library/scala/collection/mutable/OpenHashMap.scala
+++ b/src/library/scala/collection/mutable/OpenHashMap.scala
@@ -81,6 +81,9 @@ extends AbstractMap[Key, Value]
h ^ (h >>> 7) ^ (h >>> 4)
}
+ /** Increase the size of the table.
+ * Copy only the occupied slots, effectively eliminating the deleted slots.
+ */
private[this] def growTable() = {
val oldSize = mask + 1
val newSize = 4 * oldSize
@@ -92,8 +95,18 @@ extends AbstractMap[Key, Value]
deleted = 0
}
+ /** Return the index of the first slot in the hash table (in probe order)
+ * that either is empty, or is or was last occupied by the given key.
+ */
private[this] def findIndex(key: Key) : Int = findIndex(key, hashOf(key))
+ /** Return the index of the first slot in the hash table (in probe order)
+ * that either is empty, or is or was last occupied by the given key.
+ *
+ * This method is an optimization for when the hash value is in hand.
+ *
+ * @param hash hash value for `key`
+ */
private[this] def findIndex(key: Key, hash: Int): Int = {
var j = hash
@@ -136,7 +149,11 @@ extends AbstractMap[Key, Value]
None
} else {
val res = entry.value
- if (entry.value == None) { size += 1; modCount += 1 }
+ if (entry.value == None) {
+ size += 1
+ deleted -= 1
+ modCount += 1
+ }
entry.value = Some(value)
res
}
diff --git a/src/library/scala/collection/parallel/ParIterableLike.scala b/src/library/scala/collection/parallel/ParIterableLike.scala
index 53f9a7b87a..a5a82764d6 100644
--- a/src/library/scala/collection/parallel/ParIterableLike.scala
+++ b/src/library/scala/collection/parallel/ParIterableLike.scala
@@ -520,22 +520,22 @@ self: ParIterableLike[T, Repr, Sequential] =>
*
* $abortsignalling
*
- * @param pred a predicate used to test elements
+ * @param p a predicate used to test elements
* @return true if `p` holds for all elements, false otherwise
*/
- def forall(pred: T => Boolean): Boolean = {
- tasksupport.executeAndWaitResult(new Forall(pred, splitter assign new DefaultSignalling with VolatileAbort))
+ def forall(@deprecatedName('pred) p: T => Boolean): Boolean = {
+ tasksupport.executeAndWaitResult(new Forall(p, splitter assign new DefaultSignalling with VolatileAbort))
}
/** Tests whether a predicate holds for some element of this $coll.
*
* $abortsignalling
*
- * @param pred a predicate used to test elements
+ * @param p a predicate used to test elements
* @return true if `p` holds for some element, false otherwise
*/
- def exists(pred: T => Boolean): Boolean = {
- tasksupport.executeAndWaitResult(new Exists(pred, splitter assign new DefaultSignalling with VolatileAbort))
+ def exists(@deprecatedName('pred) p: T => Boolean): Boolean = {
+ tasksupport.executeAndWaitResult(new Exists(p, splitter assign new DefaultSignalling with VolatileAbort))
}
/** Finds some element in the collection for which the predicate holds, if such
@@ -546,11 +546,11 @@ self: ParIterableLike[T, Repr, Sequential] =>
*
* $abortsignalling
*
- * @param pred predicate used to test the elements
+ * @param p predicate used to test the elements
* @return an option value with the element if such an element exists, or `None` otherwise
*/
- def find(pred: T => Boolean): Option[T] = {
- tasksupport.executeAndWaitResult(new Find(pred, splitter assign new DefaultSignalling with VolatileAbort))
+ def find(@deprecatedName('pred) p: T => Boolean): Option[T] = {
+ tasksupport.executeAndWaitResult(new Find(p, splitter assign new DefaultSignalling with VolatileAbort))
}
/** Creates a combiner factory. Each combiner factory instance is used
diff --git a/src/library/scala/runtime/Tuple2Zipped.scala b/src/library/scala/runtime/Tuple2Zipped.scala
index 1c432b0403..15331d4160 100644
--- a/src/library/scala/runtime/Tuple2Zipped.scala
+++ b/src/library/scala/runtime/Tuple2Zipped.scala
@@ -84,12 +84,12 @@ final class Tuple2Zipped[El1, Repr1, El2, Repr2](val colls: (TraversableLike[El1
(b1.result(), b2.result())
}
- def exists(f: (El1, El2) => Boolean): Boolean = {
+ def exists(@deprecatedName('f) p: (El1, El2) => Boolean): Boolean = {
val elems2 = colls._2.iterator
for (el1 <- colls._1) {
if (elems2.hasNext) {
- if (f(el1, elems2.next()))
+ if (p(el1, elems2.next()))
return true
}
else return false
@@ -97,8 +97,8 @@ final class Tuple2Zipped[El1, Repr1, El2, Repr2](val colls: (TraversableLike[El1
false
}
- def forall(f: (El1, El2) => Boolean): Boolean =
- !exists((x, y) => !f(x, y))
+ def forall(@deprecatedName('f) p: (El1, El2) => Boolean): Boolean =
+ !exists((x, y) => !p(x, y))
def foreach[U](f: (El1, El2) => U): Unit = {
val elems2 = colls._2.iterator
diff --git a/src/library/scala/runtime/Tuple3Zipped.scala b/src/library/scala/runtime/Tuple3Zipped.scala
index 3bab86921b..62bee5ff0e 100644
--- a/src/library/scala/runtime/Tuple3Zipped.scala
+++ b/src/library/scala/runtime/Tuple3Zipped.scala
@@ -90,13 +90,13 @@ final class Tuple3Zipped[El1, Repr1, El2, Repr2, El3, Repr3](val colls: (Travers
result
}
- def exists(f: (El1, El2, El3) => Boolean): Boolean = {
+ def exists(@deprecatedName('f) p: (El1, El2, El3) => Boolean): Boolean = {
val elems2 = colls._2.iterator
val elems3 = colls._3.iterator
for (el1 <- colls._1) {
if (elems2.hasNext && elems3.hasNext) {
- if (f(el1, elems2.next(), elems3.next()))
+ if (p(el1, elems2.next(), elems3.next()))
return true
}
else return false
@@ -104,8 +104,8 @@ final class Tuple3Zipped[El1, Repr1, El2, Repr2, El3, Repr3](val colls: (Travers
false
}
- def forall(f: (El1, El2, El3) => Boolean): Boolean =
- !exists((x, y, z) => !f(x, y, z))
+ def forall(@deprecatedName('f) p: (El1, El2, El3) => Boolean): Boolean =
+ !exists((x, y, z) => !p(x, y, z))
def foreach[U](f: (El1, El2, El3) => U): Unit = {
val elems2 = colls._2.iterator
diff --git a/src/library/scala/util/Either.scala b/src/library/scala/util/Either.scala
index 6ea9da64f2..675b3c8c61 100644
--- a/src/library/scala/util/Either.scala
+++ b/src/library/scala/util/Either.scala
@@ -329,8 +329,8 @@ object Either {
* }}}
*
*/
- def forall(f: A => Boolean) = e match {
- case Left(a) => f(a)
+ def forall(@deprecatedName('f) p: A => Boolean) = e match {
+ case Left(a) => p(a)
case Right(_) => true
}
@@ -345,8 +345,8 @@ object Either {
* }}}
*
*/
- def exists(f: A => Boolean) = e match {
- case Left(a) => f(a)
+ def exists(@deprecatedName('f) p: A => Boolean) = e match {
+ case Left(a) => p(a)
case Right(_) => false
}
@@ -507,9 +507,9 @@ object Either {
* Left(12).right.exists(_ > 10) // false
* }}}
*/
- def exists(f: B => Boolean) = e match {
+ def exists(@deprecatedName('f) p: B => Boolean) = e match {
case Left(_) => false
- case Right(b) => f(b)
+ case Right(b) => p(b)
}
/**
diff --git a/src/repl/scala/tools/nsc/interpreter/ILoop.scala b/src/repl/scala/tools/nsc/interpreter/ILoop.scala
index 5851aa88df..060bccb451 100644
--- a/src/repl/scala/tools/nsc/interpreter/ILoop.scala
+++ b/src/repl/scala/tools/nsc/interpreter/ILoop.scala
@@ -693,25 +693,37 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter)
Iterator continually in.readLine("") takeWhile (x => x != null && cond(x))
}
+ /* :paste -raw file
+ * or
+ * :paste < EOF
+ * your code
+ * EOF
+ * :paste <~ EOF
+ * ~your code
+ * EOF
+ */
def pasteCommand(arg: String): Result = {
var shouldReplay: Option[String] = None
def result = Result(keepRunning = true, shouldReplay)
- val (raw, file) =
- if (arg.isEmpty) (false, None)
+ val (raw, file, margin) =
+ if (arg.isEmpty) (false, None, None)
else {
- val r = """(-raw)?(\s+)?([^\-]\S*)?""".r
- arg match {
- case r(flag, sep, name) =>
- if (flag != null && name != null && sep == null)
- echo(s"""I assume you mean "$flag $name"?""")
- (flag != null, Option(name))
- case _ =>
- echo("usage: :paste -raw file")
- return result
+ def maybeRaw(ss: List[String]) = if (ss.nonEmpty && ss.head == "-raw") (true, ss.tail) else (false, ss)
+ def maybeHere(ss: List[String]) =
+ if (ss.nonEmpty && ss.head.startsWith("<")) (ss.head.dropWhile(_ == '<'), ss.tail)
+ else (null, ss)
+
+ val (raw0, ss0) = maybeRaw(words(arg))
+ val (margin0, ss1) = maybeHere(ss0)
+ val file0 = ss1 match {
+ case Nil => null
+ case x :: Nil => x
+ case _ => echo("usage: :paste [-raw] file | < EOF") ; return result
}
+ (raw0, Option(file0), Option(margin0))
}
- val code = file match {
- case Some(name) =>
+ val code = (file, margin) match {
+ case (Some(name), None) =>
withFile(name) { f =>
shouldReplay = Some(s":paste $arg")
val s = f.slurp.trim
@@ -719,9 +731,16 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter)
else echo(s"Pasting file $f...")
s
} getOrElse ""
- case None =>
- echo("// Entering paste mode (ctrl-D to finish)\n")
- val text = (readWhile(_ => true) mkString "\n").trim
+ case (eof, _) =>
+ echo(s"// Entering paste mode (${ eof getOrElse "ctrl-D" } to finish)\n")
+ val delimiter = eof orElse replProps.pasteDelimiter.option
+ val input = readWhile(s => delimiter.isEmpty || delimiter.get != s) mkString "\n"
+ val text = (
+ margin filter (_.nonEmpty) map {
+ case "-" => input.lines map (_.trim) mkString "\n"
+ case m => input stripMargin m.head // ignore excess chars in "<<||"
+ } getOrElse input
+ ).trim
if (text.isEmpty) echo("\n// Nothing pasted, nothing gained.\n")
else echo("\n// Exiting paste mode, now interpreting.\n")
text
diff --git a/src/repl/scala/tools/nsc/interpreter/ReplProps.scala b/src/repl/scala/tools/nsc/interpreter/ReplProps.scala
index 588d92f81b..f3115d9800 100644
--- a/src/repl/scala/tools/nsc/interpreter/ReplProps.scala
+++ b/src/repl/scala/tools/nsc/interpreter/ReplProps.scala
@@ -64,6 +64,8 @@ class ReplProps {
if (p.isSet) p.get else shellWelcomeString
}
+ val pasteDelimiter = Prop[String]("scala.repl.here")
+
/** CSV of paged,across to enable pagination or `-x` style
* columns, "across" instead of down the column. Since
* pagination turns off columnar output, these flags are
diff --git a/test/files/run/repl-paste-5.check b/test/files/run/repl-paste-5.check
new file mode 100644
index 0000000000..8b97b8888d
--- /dev/null
+++ b/test/files/run/repl-paste-5.check
@@ -0,0 +1,28 @@
+
+scala> :paste < EOF
+// Entering paste mode (EOF to finish)
+
+class C { def c = 42 }
+EOF
+
+// Exiting paste mode, now interpreting.
+
+defined class C
+
+scala> new C().c
+res0: Int = 42
+
+scala> :paste <| EOF
+// Entering paste mode (EOF to finish)
+
+ |class D { def d = 42 }
+EOF
+
+// Exiting paste mode, now interpreting.
+
+defined class D
+
+scala> new D().d
+res1: Int = 42
+
+scala> :quit
diff --git a/test/files/run/repl-paste-5.scala b/test/files/run/repl-paste-5.scala
new file mode 100644
index 0000000000..890f47f141
--- /dev/null
+++ b/test/files/run/repl-paste-5.scala
@@ -0,0 +1,18 @@
+
+import scala.tools.partest.ReplTest
+
+object Test extends ReplTest {
+ //def code = ":paste < EOF\n" + (
+ def code =
+ """
+:paste < EOF
+class C { def c = 42 }
+EOF
+new C().c
+:paste <| EOF
+ |class D { def d = 42 }
+EOF
+new D().d
+ """
+ //)
+}
diff --git a/test/junit/scala/collection/mutable/OpenHashMapTest.scala b/test/junit/scala/collection/mutable/OpenHashMapTest.scala
new file mode 100644
index 0000000000..9b5c20e01a
--- /dev/null
+++ b/test/junit/scala/collection/mutable/OpenHashMapTest.scala
@@ -0,0 +1,42 @@
+package scala.collection.mutable
+
+import org.junit.Test
+import org.junit.Assert._
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+
+/** Tests for [[OpenHashMap]]. */
+@RunWith(classOf[JUnit4])
+class OpenHashMapTest {
+ /** Test that an [[OpenHashMap]] correctly maintains its internal `deleted` count. */
+ @Test
+ def maintainsDeletedCount {
+ val m = OpenHashMap.empty[Int, Int]
+
+ // Reflect to get the private `deleted` field's value, which should be zero.
+
+ /* TODO Doesn't work, due to SI-9306.
+ import scala.reflect.runtime.{universe => ru}
+
+ val mirror = ru.runtimeMirror(m.getClass.getClassLoader)
+ val mapType = ru.typeOf[OpenHashMap[Int, Int]]
+ val termSym = mapType.decls
+ .filterNot { s => s.isMethod }
+ .filter { s => s.fullName.endsWith("deleted") }
+ .head.asTerm
+
+ val fieldMirror = mirror.reflect(m).reflectField(termSym)
+ */
+ // Use Java reflection instead for now.
+ val field = m.getClass.getDeclaredField("deleted")
+ field.setAccessible(true)
+
+ m.put(0, 0)
+ m.remove(0)
+ assertEquals(1, field.getInt(m))
+
+ m.put(0, 0) // Add an entry with the same key
+ // TODO assertEquals(0, fieldMirror.get.asInstanceOf[Int])
+ assertEquals(0, field.getInt(m))
+ }
+}