diff options
author | Simon Ochsenreither <simon@ochsenreither.de> | 2013-01-17 20:05:30 +0100 |
---|---|---|
committer | Simon Ochsenreither <simon@ochsenreither.de> | 2013-01-17 20:52:24 +0100 |
commit | 2ee85683cdd2f8f41508fef0880edb31c1d97a4c (patch) | |
tree | bba4b392fd016508538949978ad6cecdc9173aa9 | |
parent | 167fc0acb9bc75f3f378d2bfbabd61a2782a3568 (diff) | |
download | scala-2ee85683cdd2f8f41508fef0880edb31c1d97a4c.tar.gz scala-2ee85683cdd2f8f41508fef0880edb31c1d97a4c.tar.bz2 scala-2ee85683cdd2f8f41508fef0880edb31c1d97a4c.zip |
SI-6811 Remove deprecated constructors
-rw-r--r-- | src/library/scala/Enumeration.scala | 12 | ||||
-rw-r--r-- | test/files/pos/t342.scala | 8 | ||||
-rw-r--r-- | test/files/run/enums.scala | 14 | ||||
-rw-r--r-- | test/files/run/t1505.scala | 13 |
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) + } |