aboutsummaryrefslogtreecommitdiff
path: root/tests/run/enum-Option.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/enum-Option.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/enum-Option.scala')
-rw-r--r--tests/run/enum-Option.scala19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/run/enum-Option.scala b/tests/run/enum-Option.scala
new file mode 100644
index 000000000..76f5641b3
--- /dev/null
+++ b/tests/run/enum-Option.scala
@@ -0,0 +1,19 @@
+enum class Option[+T >: Null] extends Serializable {
+ def isDefined: Boolean
+}
+object Option {
+ def apply[T >: Null](x: T): Option[T] = if (x == null) None else Some(x)
+ case Some(x: T) {
+ def isDefined = true
+ }
+ case None {
+ def isDefined = false
+ }
+}
+
+object Test {
+ def main(args: Array[String]) = {
+ assert(Some(None).isDefined)
+ Option("22") match { case Option.Some(x) => assert(x == "22") }
+ }
+}