diff options
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/Cloneable.scala | 14 | ||||
-rw-r--r-- | src/library/scala/StringContext.scala | 38 | ||||
-rw-r--r-- | src/library/scala/annotation/cloneable.scala (renamed from src/library/scala/cloneable.scala) | 5 | ||||
-rw-r--r-- | src/library/scala/collection/convert/Wrappers.scala | 3 | ||||
-rw-r--r-- | src/library/scala/collection/mutable/ArrayStack.scala | 2 | ||||
-rw-r--r-- | src/library/scala/collection/mutable/Buffer.scala | 4 | ||||
-rw-r--r-- | src/library/scala/collection/mutable/BufferLike.scala | 2 | ||||
-rw-r--r-- | src/library/scala/collection/mutable/Cloneable.scala | 5 | ||||
-rw-r--r-- | src/library/scala/collection/mutable/PriorityQueue.scala | 2 | ||||
-rw-r--r-- | src/library/scala/collection/mutable/Queue.scala | 1 | ||||
-rw-r--r-- | src/library/scala/collection/mutable/Stack.scala | 1 | ||||
-rw-r--r-- | src/library/scala/package.scala | 3 |
12 files changed, 31 insertions, 49 deletions
diff --git a/src/library/scala/Cloneable.scala b/src/library/scala/Cloneable.scala new file mode 100644 index 0000000000..5ba76ddde5 --- /dev/null +++ b/src/library/scala/Cloneable.scala @@ -0,0 +1,14 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala + +/** + * Classes extending this trait are cloneable across platforms (Java, .NET). + */ +trait Cloneable extends java.lang.Cloneable diff --git a/src/library/scala/StringContext.scala b/src/library/scala/StringContext.scala index f400f18dab..f11dfb72ae 100644 --- a/src/library/scala/StringContext.scala +++ b/src/library/scala/StringContext.scala @@ -8,7 +8,7 @@ package scala -import collection.mutable.ArrayBuffer +import language.experimental.macros /** A class to support string interpolation. * This class supports string interpolation as outlined in Scala SIP-11. @@ -42,7 +42,7 @@ case class StringContext(parts: String*) { * @throws A `StringContext.InvalidEscapeException` if if a `parts` string contains a backslash (`\`) character * that does not start a valid escape sequence. */ - def s(args: Any*) = { + def s(args: Any*): String = { checkLengths(args: _*) val pi = parts.iterator val ai = args.iterator @@ -82,38 +82,8 @@ case class StringContext(parts: String*) { * string literally. This is achieved by replacing each such occurrence by the * format specifier `%%`. */ - def f(args: Any*) = { - checkLengths(args: _*) - val pi = parts.iterator - val bldr = new java.lang.StringBuilder - def copyString(first: Boolean): Unit = { - val str = treatEscapes(pi.next()) - val strIsEmpty = str.length == 0 - var start = 0 - var idx = 0 - if (!first) { - if (strIsEmpty || (str charAt 0) != '%') - bldr append "%s" - idx = 1 - } - if (!strIsEmpty) { - val len = str.length - while (idx < len) { - if (str(idx) == '%') { - bldr append (str substring (start, idx)) append "%%" - start = idx + 1 - } - idx += 1 - } - bldr append (str substring (start, idx)) - } - } - copyString(first = true) - while (pi.hasNext) { - copyString(first = false) - } - bldr.toString format (args: _*) - } + // The implementation is magically hardwired into `scala.tools.reflect.MacroImplementations.macro_StringInterpolation_f` + def f(args: Any*): String = macro ??? } object StringContext { diff --git a/src/library/scala/cloneable.scala b/src/library/scala/annotation/cloneable.scala index 32a1ea640d..aa45e8325f 100644 --- a/src/library/scala/cloneable.scala +++ b/src/library/scala/annotation/cloneable.scala @@ -6,11 +6,10 @@ ** |/ ** \* */ - - -package scala +package scala.annotation /** * An annotation that designates the class to which it is applied as cloneable */ +@deprecated("instead of `@cloneable class C`, use `class C extends Cloneable`", "2.10.0") class cloneable extends annotation.StaticAnnotation diff --git a/src/library/scala/collection/convert/Wrappers.scala b/src/library/scala/collection/convert/Wrappers.scala index 8c603dc91b..75707b69b0 100644 --- a/src/library/scala/collection/convert/Wrappers.scala +++ b/src/library/scala/collection/convert/Wrappers.scala @@ -467,4 +467,5 @@ private[collection] trait Wrappers { } } -object Wrappers extends Wrappers +@SerialVersionUID(0 - 5857859809262781311L) +object Wrappers extends Wrappers with Serializable diff --git a/src/library/scala/collection/mutable/ArrayStack.scala b/src/library/scala/collection/mutable/ArrayStack.scala index 040a0e2aa7..8f834d265b 100644 --- a/src/library/scala/collection/mutable/ArrayStack.scala +++ b/src/library/scala/collection/mutable/ArrayStack.scala @@ -59,7 +59,7 @@ object ArrayStack extends SeqFactory[ArrayStack] { * @define mayNotTerminateInf * @define willNotTerminateInf */ -@cloneable @SerialVersionUID(8565219180626620510L) +@SerialVersionUID(8565219180626620510L) class ArrayStack[T] private(private var table : Array[AnyRef], private var index : Int) extends AbstractSeq[T] diff --git a/src/library/scala/collection/mutable/Buffer.scala b/src/library/scala/collection/mutable/Buffer.scala index dd225cfab9..fd5dc66292 100644 --- a/src/library/scala/collection/mutable/Buffer.scala +++ b/src/library/scala/collection/mutable/Buffer.scala @@ -28,10 +28,10 @@ import generic._ * @define Coll `Buffer` * @define coll buffer */ -@cloneable trait Buffer[A] extends Seq[A] with GenericTraversableTemplate[A, Buffer] - with BufferLike[A, Buffer[A]] { + with BufferLike[A, Buffer[A]] + with scala.Cloneable { override def companion: GenericCompanion[Buffer] = Buffer } diff --git a/src/library/scala/collection/mutable/BufferLike.scala b/src/library/scala/collection/mutable/BufferLike.scala index f82a596b32..3274fe6194 100644 --- a/src/library/scala/collection/mutable/BufferLike.scala +++ b/src/library/scala/collection/mutable/BufferLike.scala @@ -58,13 +58,13 @@ import annotation.{migration, bridge} * mutates the collection in place, unlike similar but * undeprecated methods throughout the collections hierarchy. */ -@cloneable trait BufferLike[A, +This <: BufferLike[A, This] with Buffer[A]] extends Growable[A] with Shrinkable[A] with Scriptable[A] with Subtractable[A, This] with SeqLike[A, This] + with scala.Cloneable { self : This => // Abstract methods from Seq: diff --git a/src/library/scala/collection/mutable/Cloneable.scala b/src/library/scala/collection/mutable/Cloneable.scala index e6fbce415a..6daac3094a 100644 --- a/src/library/scala/collection/mutable/Cloneable.scala +++ b/src/library/scala/collection/mutable/Cloneable.scala @@ -17,9 +17,6 @@ package mutable * * @tparam A Type of the elements contained in the collection, covariant and with reference types as upperbound. */ -@cloneable -trait Cloneable[+A <: AnyRef] { - // !!! why doesn't this extend java.lang.Cloneable? - // because neither did @serializable, then we changed it to Serializable +trait Cloneable[+A <: AnyRef] extends scala.Cloneable { override def clone: A = super.clone().asInstanceOf[A] } diff --git a/src/library/scala/collection/mutable/PriorityQueue.scala b/src/library/scala/collection/mutable/PriorityQueue.scala index af55a01ed6..e37cbdc712 100644 --- a/src/library/scala/collection/mutable/PriorityQueue.scala +++ b/src/library/scala/collection/mutable/PriorityQueue.scala @@ -31,7 +31,6 @@ import generic._ * @define mayNotTerminateInf * @define willNotTerminateInf */ -@cloneable class PriorityQueue[A](implicit val ord: Ordering[A]) extends AbstractIterable[A] with Iterable[A] @@ -40,6 +39,7 @@ class PriorityQueue[A](implicit val ord: Ordering[A]) with Growable[A] with Builder[A, PriorityQueue[A]] with Serializable + with scala.Cloneable { import ord._ diff --git a/src/library/scala/collection/mutable/Queue.scala b/src/library/scala/collection/mutable/Queue.scala index 605d37aec6..2aa19d6cb0 100644 --- a/src/library/scala/collection/mutable/Queue.scala +++ b/src/library/scala/collection/mutable/Queue.scala @@ -30,7 +30,6 @@ import generic._ * @define mayNotTerminateInf * @define willNotTerminateInf */ -@cloneable class Queue[A] extends MutableList[A] with GenericTraversableTemplate[A, Queue] diff --git a/src/library/scala/collection/mutable/Stack.scala b/src/library/scala/collection/mutable/Stack.scala index 042eac517a..db9e48d1cf 100644 --- a/src/library/scala/collection/mutable/Stack.scala +++ b/src/library/scala/collection/mutable/Stack.scala @@ -53,7 +53,6 @@ object Stack extends SeqFactory[Stack] { * @define mayNotTerminateInf * @define willNotTerminateInf */ -@cloneable class Stack[A] private (var elems: List[A]) extends AbstractSeq[A] with Seq[A] diff --git a/src/library/scala/package.scala b/src/library/scala/package.scala index 5f90c32e22..a41cdedfa9 100644 --- a/src/library/scala/package.scala +++ b/src/library/scala/package.scala @@ -37,6 +37,9 @@ package object scala { @deprecated("instead of `@serializable class C`, use `class C extends Serializable`", "2.9.0") type serializable = annotation.serializable + @deprecated("instead of `@cloneable class C`, use `class C extends Cloneable`", "2.10.0") + type cloneable = annotation.cloneable + type TraversableOnce[+A] = scala.collection.TraversableOnce[A] type Traversable[+A] = scala.collection.Traversable[A] |