summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2009-11-09 18:34:49 +0000
committerMartin Odersky <odersky@gmail.com>2009-11-09 18:34:49 +0000
commit7da30bf2d5195d1e7a156680b50167707f7a3d0a (patch)
tree083cd78a70a13ac5fab4609a2a2875be48501df0
parent2aeae987765bd5a63954b89ac8428db97b0a369f (diff)
downloadscala-7da30bf2d5195d1e7a156680b50167707f7a3d0a.tar.gz
scala-7da30bf2d5195d1e7a156680b50167707f7a3d0a.tar.bz2
scala-7da30bf2d5195d1e7a156680b50167707f7a3d0a.zip
added `locally' to Predef.
added overloaded hashes to Predef. some small changes.
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala2
-rw-r--r--src/library/scala/Predef.scala12
-rw-r--r--src/library/scala/collection/mutable/BufferProxy.scala4
-rw-r--r--test/files/pos/t2569/Child.scala9
-rw-r--r--test/files/pos/t2569/Parent.java13
5 files changed, 39 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index 0b285da72d..aaefab1f74 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -935,7 +935,7 @@ abstract class RefChecks extends InfoTransform {
unit.deprecationWarning(
tree.pos,
symbol.toString + " overrides concrete, non-deprecated symbol(s):" +
- concrOvers.map(_.fullNameString).mkString(" ", ", ", ""))
+ concrOvers.map(_.name.decode).mkString(" ", ", ", ""))
}
}
diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala
index df6cc61ee6..c3e0548183 100644
--- a/src/library/scala/Predef.scala
+++ b/src/library/scala/Predef.scala
@@ -91,11 +91,23 @@ object Predef extends LowPriorityImplicits {
def currentThread = java.lang.Thread.currentThread()
+ @inline def locally[T](x: T): T = x
+
// hashcode -----------------------------------------------------------
@inline def hash(x: Any): Int =
if (x.isInstanceOf[Number]) runtime.BoxesRunTime.numHash(x.asInstanceOf[Number]) else x.hashCode
+ @inline def hash(x: Number): Int =
+ runtime.BoxesRunTime.numHash(x.asInstanceOf[Number])
+
+ @inline def hash(x: Long): Int = {
+ val iv = x.intValue
+ if (iv == x.longValue) iv else x.hashCode
+ }
+
+ @inline def hash(x: Int): Int = x
+
// errors and asserts -------------------------------------------------
def error(message: String): Nothing = throw new RuntimeException(message)
diff --git a/src/library/scala/collection/mutable/BufferProxy.scala b/src/library/scala/collection/mutable/BufferProxy.scala
index 343233e351..a31beda57b 100644
--- a/src/library/scala/collection/mutable/BufferProxy.scala
+++ b/src/library/scala/collection/mutable/BufferProxy.scala
@@ -40,6 +40,8 @@ trait BufferProxy[A] extends Buffer[A] with Proxy {
* @param elem the element to append.
* @return the updated buffer.
*/
+ @deprecated("Use += instead if you intend to add by side effect to an existing collection.\n"+
+ "Use `clone() ++=' if you intend to create a new collection.")
override def +(elem: A): Buffer[A] = self.+(elem)
/** Append a single element to this buffer.
@@ -57,6 +59,8 @@ trait BufferProxy[A] extends Buffer[A] with Proxy {
* @param iter the iterable object.
* @return the updated buffer.
*/
+ @deprecated("Use ++= instead if you intend to add by side effect to an existing collection.\n"+
+ "Use `clone() ++=` if you intend to create a new collection.")
def ++(iter: scala.collection.Iterable[A]): Buffer[A] = self.++(iter)
/** Appends a number of elements provided by an iterable object
diff --git a/test/files/pos/t2569/Child.scala b/test/files/pos/t2569/Child.scala
new file mode 100644
index 0000000000..64f4dc172f
--- /dev/null
+++ b/test/files/pos/t2569/Child.scala
@@ -0,0 +1,9 @@
+package varargs
+
+ class Child extends Parent {
+
+ override def concatenate(strings: String*): String =
+ strings map("\"" + _ + "\"") mkString("(", ", ", ")")
+
+ }
+
diff --git a/test/files/pos/t2569/Parent.java b/test/files/pos/t2569/Parent.java
new file mode 100644
index 0000000000..89421becbd
--- /dev/null
+++ b/test/files/pos/t2569/Parent.java
@@ -0,0 +1,13 @@
+package varargs;
+
+ public class Parent {
+
+ public String concatenate(String... strings) {
+ StringBuilder builder = new StringBuilder();
+ for (String s : strings) {
+ builder.append(s);
+ }
+ return builder.toString();
+ }
+
+ }