Using the sbt dotty plugin:
addSbtPlugin("com.felixmulder" % "sbt-dotty" % "0.1.9")
And running sbt console
, I try out the new union type feature:
Starting dotty interpreter...
Welcome to Scala.next (pre-alpha, git-hash: 606e36b) (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_112).
Type in expressions to have them evaluated.
Type :help for more information.
scala> case class A(val x: Int, y: Double)
defined class A
scala> case class B(val x: Int, y: String)
defined class B
scala> def getX(o: A | B): Int = o.x
-- [E008] Member Not Found Error: <console> ------------------------------------
8 |def getX(o: A | B): Int = o.x
| ^^^
| value `x` is not a member of (A | B)(o)
Why doesn't this work? Am I using union types wrong? Is this just not working yet?