Skip to content

Commit 7da30bf

Browse files
committed
added `locally' to Predef.
added overloaded hashes to Predef. some small changes.
1 parent 2aeae98 commit 7da30bf

File tree

5 files changed

+39
-1
lines changed

5 files changed

+39
-1
lines changed

src/compiler/scala/tools/nsc/typechecker/RefChecks.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@ abstract class RefChecks extends InfoTransform {
935935
unit.deprecationWarning(
936936
tree.pos,
937937
symbol.toString + " overrides concrete, non-deprecated symbol(s):" +
938-
concrOvers.map(_.fullNameString).mkString(" ", ", ", ""))
938+
concrOvers.map(_.name.decode).mkString(" ", ", ", ""))
939939
}
940940
}
941941

src/library/scala/Predef.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,23 @@ object Predef extends LowPriorityImplicits {
9191

9292
def currentThread = java.lang.Thread.currentThread()
9393

94+
@inline def locally[T](x: T): T = x
95+
9496
// hashcode -----------------------------------------------------------
9597

9698
@inline def hash(x: Any): Int =
9799
if (x.isInstanceOf[Number]) runtime.BoxesRunTime.numHash(x.asInstanceOf[Number]) else x.hashCode
98100

101+
@inline def hash(x: Number): Int =
102+
runtime.BoxesRunTime.numHash(x.asInstanceOf[Number])
103+
104+
@inline def hash(x: Long): Int = {
105+
val iv = x.intValue
106+
if (iv == x.longValue) iv else x.hashCode
107+
}
108+
109+
@inline def hash(x: Int): Int = x
110+
99111
// errors and asserts -------------------------------------------------
100112

101113
def error(message: String): Nothing = throw new RuntimeException(message)

src/library/scala/collection/mutable/BufferProxy.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ trait BufferProxy[A] extends Buffer[A] with Proxy {
4040
* @param elem the element to append.
4141
* @return the updated buffer.
4242
*/
43+
@deprecated("Use += instead if you intend to add by side effect to an existing collection.\n"+
44+
"Use `clone() ++=' if you intend to create a new collection.")
4345
override def +(elem: A): Buffer[A] = self.+(elem)
4446

4547
/** Append a single element to this buffer.
@@ -57,6 +59,8 @@ trait BufferProxy[A] extends Buffer[A] with Proxy {
5759
* @param iter the iterable object.
5860
* @return the updated buffer.
5961
*/
62+
@deprecated("Use ++= instead if you intend to add by side effect to an existing collection.\n"+
63+
"Use `clone() ++=` if you intend to create a new collection.")
6064
def ++(iter: scala.collection.Iterable[A]): Buffer[A] = self.++(iter)
6165

6266
/** Appends a number of elements provided by an iterable object

test/files/pos/t2569/Child.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package varargs
2+
3+
class Child extends Parent {
4+
5+
override def concatenate(strings: String*): String =
6+
strings map("\"" + _ + "\"") mkString("(", ", ", ")")
7+
8+
}
9+

test/files/pos/t2569/Parent.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package varargs;
2+
3+
public class Parent {
4+
5+
public String concatenate(String... strings) {
6+
StringBuilder builder = new StringBuilder();
7+
for (String s : strings) {
8+
builder.append(s);
9+
}
10+
return builder.toString();
11+
}
12+
13+
}

0 commit comments

Comments
 (0)