We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3367591 commit 5017f8bCopy full SHA for 5017f8b
tests/pos/i4867.scala
@@ -0,0 +1,16 @@
1
+object UnionMapping {
2
+ private def parse(string: String): Int | Double = {
3
+ if(string.contains("."))
4
+ string.toDouble
5
+ else
6
+ string.toInt
7
+ }
8
+
9
+ def test_number = {
10
+ val strings: Seq[String] = Seq("123", "2.0", "42")
11
+ // Works
12
+ val asdf: Seq[AnyVal] = strings.map(parse(_))
13
+ // Fails to compile
14
+ val union: Seq[Int | Double] = strings.map(parse(_))
15
16
+}
0 commit comments