aboutsummaryrefslogtreecommitdiff
path: root/tests/neg/unions.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-10-01 21:51:34 +0200
committerGuillaume Martres <smarter@ubuntu.com>2016-10-11 19:21:02 +0200
commit25c0398b6f07df2449652e66cef8b6a6d3d4c7ce (patch)
tree75124ba8ba9d7663b7c6f2b739c55f828406386e /tests/neg/unions.scala
parent3d74bfa72bdc794cfb11b6afe15c77a5357617d1 (diff)
downloaddotty-25c0398b6f07df2449652e66cef8b6a6d3d4c7ce.tar.gz
dotty-25c0398b6f07df2449652e66cef8b6a6d3d4c7ce.tar.bz2
dotty-25c0398b6f07df2449652e66cef8b6a6d3d4c7ce.zip
Adapt tests
Diffstat (limited to 'tests/neg/unions.scala')
-rw-r--r--tests/neg/unions.scala32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/neg/unions.scala b/tests/neg/unions.scala
new file mode 100644
index 000000000..099a628c9
--- /dev/null
+++ b/tests/neg/unions.scala
@@ -0,0 +1,32 @@
+object unions {
+
+ class A {
+ def f: String = "abc"
+
+ def g(x: Int): Int = x
+ def g(x: Double): Double = x
+ }
+
+ class B {
+ def f: String = "bcd"
+
+ def g(x: Int) = -x
+ def g(x: Double): Double = -x
+ }
+
+ val x: A | B = if (true) new A else new B
+ def y: B | A = if (true) new A else new B
+ println(x.f) // error
+ println(x.g(2)) // error
+ println(y.f) // error
+ println(y.g(1.0)) // error
+
+ class C {
+ private def foo = 0
+ class D extends C {
+ private def foo = 1
+ def test(cd: C | D, dc: D | C) = (cd.foo, dc.foo)
+ }
+ }
+
+}