I cant get the following code to compile with the latest dotty (0.9.0-RC1), and at first glance it looks like it should...
object UnionMapping {
private def parse(string: String): Int | Double = {
if(string.contains("."))
string.toDouble
else
string.toInt
}
def test_number = {
val strings: Seq[String] = Seq("123", "2.0", "42")
// Works
val asdf: Seq[AnyVal] = strings.map(parse(_))
// Fails to compile
val union: Seq[Int | Double] = strings.map(parse(_))
}
}
does anyone have any insight into why its failing and whether its expected to work?