Skip to content

Commit 5017f8b

Browse files
committed
Test case #4867
1 parent 3367591 commit 5017f8b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/pos/i4867.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)