summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library/scala/Enumeration.scala5
-rw-r--r--test/files/run/enums.scala24
2 files changed, 27 insertions, 2 deletions
diff --git a/src/library/scala/Enumeration.scala b/src/library/scala/Enumeration.scala
index 5889bea0e9..c967a48abc 100644
--- a/src/library/scala/Enumeration.scala
+++ b/src/library/scala/Enumeration.scala
@@ -253,10 +253,11 @@ abstract class Enumeration(initial: Int,
* @param nnIds The set of ids of values (adjusted so that the lowest value does
* not fall below zero), organized as a `BitSet`.
*/
- class ValueSet private[ValueSet] (val nnIds: immutable.BitSet)
+ class ValueSet private[ValueSet] (private[this] var nnIds: immutable.BitSet)
extends AbstractSet[Value]
with immutable.SortedSet[Value]
- with SortedSetLike[Value, ValueSet] {
+ with SortedSetLike[Value, ValueSet]
+ with Serializable {
implicit def ordering: Ordering[Value] = ValueOrdering
def rangeImpl(from: Option[Value], until: Option[Value]): ValueSet =
diff --git a/test/files/run/enums.scala b/test/files/run/enums.scala
index 8c6c88ea07..9cdeed2691 100644
--- a/test/files/run/enums.scala
+++ b/test/files/run/enums.scala
@@ -94,6 +94,29 @@ object Test5 {
}
}
+object SerializationTest {
+ object Types extends Enumeration { val X, Y = Value }
+ class A extends java.io.Serializable { val types = Types.values }
+ class B extends java.io.Serializable { val types = Set(Types.X, Types.Y) }
+
+ def serialize(obj: AnyRef) = {
+ val baos = new java.io.ByteArrayOutputStream()
+ val oos = new java.io.ObjectOutputStream(baos)
+ oos.writeObject(obj)
+ oos.close()
+ val bais = new java.io.ByteArrayInputStream(baos.toByteArray)
+ val ois = new java.io.ObjectInputStream(bais)
+ val prime = ois.readObject()
+ ois.close()
+ prime
+ }
+
+ def run {
+ serialize(new B())
+ serialize(new A())
+ }
+}
+
//############################################################################
// Test code
@@ -125,6 +148,7 @@ object Test {
Console.println;
Test5.run;
Console.println;
+ SerializationTest.run;
}
}