aboutsummaryrefslogtreecommitdiff
path: root/tests/neg/t7278.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-02-02 12:34:14 +0100
committerMartin Odersky <odersky@gmail.com>2016-02-09 09:43:08 +0100
commit187c241d7b2b3698a5773463c17fd26c8294d0f7 (patch)
tree7a3d752dec79c4d75ce1f766e563f226be08e398 /tests/neg/t7278.scala
parenteaa157860fd278f7d1404bb2aa495547277fd311 (diff)
downloaddotty-187c241d7b2b3698a5773463c17fd26c8294d0f7.tar.gz
dotty-187c241d7b2b3698a5773463c17fd26c8294d0f7.tar.bz2
dotty-187c241d7b2b3698a5773463c17fd26c8294d0f7.zip
New test files from SI 7278.
Diffstat (limited to 'tests/neg/t7278.scala')
-rw-r--r--tests/neg/t7278.scala42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/neg/t7278.scala b/tests/neg/t7278.scala
new file mode 100644
index 000000000..9a8292409
--- /dev/null
+++ b/tests/neg/t7278.scala
@@ -0,0 +1,42 @@
+class A { class E }
+class B extends A { class E }
+trait C { type E = Int }
+trait D { type E = String }
+trait EC { type E }
+
+object Test {
+ // should not compile (?)
+ // martin says "I'd argue about that"
+ // martin retracts his statement: this should not compile
+ type EE[+X <: EC] = X#E
+ type EE2[+X <: EC] = X#E // repeat to get error count to 2
+
+ def fail1(): Unit = {
+ val b = new B
+ var x1: EE[A] = null
+ var x2: EE[B] = new b.E // error: found: B#E, required: A#E
+// x1 = x2 // gives a prior type error: B#E, required: A#E, masked to get at the real thing.
+ }
+
+/* Not representable in dotty as there are no existential types
+ def fail2(): Unit = {
+ val b = new B
+ var x1: p.E forSome { val p: A } = new b.E // should not compile
+ var x2: p.E forSome { val p: B } = new b.E
+ x1 = x2 // should not compile
+ }
+*/
+ def fail3(): Unit = {
+ var x1: EE[C] = 5
+ var x2: EE[C & D] = ""
+ x1 = x2
+ }
+
+ def wrap(label: String)(op: => Unit): Unit =
+ try { op } catch { case x: ClassCastException => println("%30s %s".format(label, x)) }
+
+ def main(args: Array[String]): Unit = {
+ wrap("Variance and inner classes")(fail1())
+ wrap("Linearization and type aliases")(fail3())
+ }
+}