summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library/scala/Enumeration.scala12
-rw-r--r--test/files/pos/t342.scala8
-rw-r--r--test/files/run/enums.scala14
-rw-r--r--test/files/run/t1505.scala13
4 files changed, 20 insertions, 27 deletions
diff --git a/src/library/scala/Enumeration.scala b/src/library/scala/Enumeration.scala
index 47d7840e27..21f0c8fd3e 100644
--- a/src/library/scala/Enumeration.scala
+++ b/src/library/scala/Enumeration.scala
@@ -56,14 +56,6 @@ abstract class Enumeration (initial: Int) extends Serializable {
def this() = this(0)
- @deprecated("Names should be specified individually or discovered via reflection", "2.10.0")
- def this(initial: Int, names: String*) = {
- this(initial)
- this.nextName = names.iterator
- }
- @deprecated("Names should be specified individually or discovered via reflection", "2.10.0")
- def this(names: String*) = this(0, names: _*)
-
/* Note that `readResolve` cannot be private, since otherwise
the JVM does not invoke it when deserializing subclasses. */
protected def readResolve(): AnyRef = thisenum.getClass.getField(MODULE_INSTANCE_NAME).get(null)
@@ -71,7 +63,7 @@ abstract class Enumeration (initial: Int) extends Serializable {
/** The name of this enumeration.
*/
override def toString =
- ((getClass.getName stripSuffix MODULE_SUFFIX_STRING split '.').last split
+ ((getClass.getName stripSuffix MODULE_SUFFIX_STRING split '.').last split
Pattern.quote(NAME_JOIN_STRING)).last
/** The mapping from the integer used to identify values to the actual
@@ -126,7 +118,7 @@ abstract class Enumeration (initial: Int) extends Serializable {
*
* @param s an `Enumeration` name
* @return the `Value` of this `Enumeration` if its name matches `s`
- * @throws java.util.NoSuchElementException if no `Value` with a matching
+ * @throws NoSuchElementException if no `Value` with a matching
* name is in this `Enumeration`
*/
final def withName(s: String): Value = values.find(_.toString == s).get
diff --git a/test/files/pos/t342.scala b/test/files/pos/t342.scala
deleted file mode 100644
index 752b24d2ba..0000000000
--- a/test/files/pos/t342.scala
+++ /dev/null
@@ -1,8 +0,0 @@
-object Main extends App {
-
- object Foo extends Enumeration(0, "Bar") { // 2
- val Bar = Value
- }
- import Foo._;
- Console.println(Bar)
-}
diff --git a/test/files/run/enums.scala b/test/files/run/enums.scala
index 9cdeed2691..3aad7ec320 100644
--- a/test/files/run/enums.scala
+++ b/test/files/run/enums.scala
@@ -36,8 +36,11 @@ object Test2 {
object Test3 {
- object Direction extends Enumeration("North", "South", "East", "West") {
- val North, South, East, West = Value;
+ object Direction extends Enumeration {
+ val North = Value("North")
+ val South = Value("South")
+ val East = Value("East")
+ val West = Value("West")
}
def run: Int = {
@@ -48,8 +51,11 @@ object Test3 {
object Test4 {
- object Direction extends Enumeration("North", "South", "East", "West") {
- val North, South, East, West = Value;
+ object Direction extends Enumeration {
+ val North = Value("North")
+ val South = Value("South")
+ val East = Value("East")
+ val West = Value("West")
}
def run: Int = {
diff --git a/test/files/run/t1505.scala b/test/files/run/t1505.scala
index a246e8a35b..d7feb30ce3 100644
--- a/test/files/run/t1505.scala
+++ b/test/files/run/t1505.scala
@@ -1,5 +1,3 @@
-object P extends Enumeration(0, "A", "B", "C") { val A, B, C = Value }
-
object Q extends Enumeration {
val A = Value("A")
val B = Value("B")
@@ -11,9 +9,14 @@ object R extends Enumeration {
}
object Test extends App {
- assert(P(0) == P.withName("A"))
- assert(P.C == P.withName("C"))
-
assert(Q(0) == Q.withName("A"))
assert(Q.C == Q.withName("C"))
+
+ assert(R(0) == R.withName("A"))
+ assert(R.C == R.withName("C"))
+
+ var failed = false
+ try { Q.withName("x") } catch { case _: NoSuchElementException => failed = true }
+ assert(failed)
+
}