aboutsummaryrefslogtreecommitdiff
path: root/tests/run/generic/Color.scala
diff options
context:
space:
mode:
authorodersky <odersky@gmail.com>2017-04-06 13:12:05 +0200
committerGitHub <noreply@github.com>2017-04-06 13:12:05 +0200
commit62c2a1e2d6265cf7f096e4c4e51e4e883bce1514 (patch)
tree5cd2f9018b4a5ed5fcd1ebe6a6aed392d3fd00b4 /tests/run/generic/Color.scala
parent2556c83a04af1baf9dd69f6139e9ea61d39e7c6a (diff)
parent30d8d878118c537ff82c88ef7ade8780b390bfae (diff)
downloaddotty-62c2a1e2d6265cf7f096e4c4e51e4e883bce1514.tar.gz
dotty-62c2a1e2d6265cf7f096e4c4e51e4e883bce1514.tar.bz2
dotty-62c2a1e2d6265cf7f096e4c4e51e4e883bce1514.zip
Merge pull request #1958 from dotty-staging/add-enum
Add "enum" construct
Diffstat (limited to 'tests/run/generic/Color.scala')
-rw-r--r--tests/run/generic/Color.scala13
1 files changed, 9 insertions, 4 deletions
diff --git a/tests/run/generic/Color.scala b/tests/run/generic/Color.scala
index ed248295d..7f2a8818c 100644
--- a/tests/run/generic/Color.scala
+++ b/tests/run/generic/Color.scala
@@ -10,12 +10,17 @@ import Shapes._
*/
sealed trait Color extends Enum
-object Color extends EnumValues[Color](3) {
+object Color {
+
+ private val $values = new runtime.EnumValues[Color]
+ def valueOf = $values.fromInt
+ def withName = $values.fromName
+ def values = $values.values
private def $new(tag: Int, name: String) = new Color {
def enumTag = tag
override def toString = name
- registerEnumValue(this)
+ $values.register(this)
}
val Red: Color = $new(0, "Red")
@@ -25,6 +30,6 @@ object Color extends EnumValues[Color](3) {
implicit val ColorShape: Color `shaped` EnumValue[Color] =
new (Color `shaped` EnumValue[Color]) {
def toShape(x: Color) = EnumValue(x.enumTag)
- def fromShape(x: EnumValue[Color]) = Color.value(x.tag)
+ def fromShape(x: EnumValue[Color]) = Color.valueOf(x.tag)
}
-} \ No newline at end of file
+}