diff options
author | Martin Odersky <odersky@gmail.com> | 2014-10-07 14:23:38 +0200 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2014-10-12 10:50:57 +0200 |
commit | fd81127c6255d01237dd98e8296abf6fdfe80741 (patch) | |
tree | c9c6f2f6f17173fb5539c57022f68274e495a281 /tests/pos/t7093.scala | |
parent | fa44d5cd694d76e285ebadcdf297f0d13936a6e9 (diff) | |
download | dotty-fd81127c6255d01237dd98e8296abf6fdfe80741.tar.gz dotty-fd81127c6255d01237dd98e8296abf6fdfe80741.tar.bz2 dotty-fd81127c6255d01237dd98e8296abf6fdfe80741.zip |
New tests
Diffstat (limited to 'tests/pos/t7093.scala')
-rw-r--r-- | tests/pos/t7093.scala | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/pos/t7093.scala b/tests/pos/t7093.scala new file mode 100644 index 000000000..287b7a78c --- /dev/null +++ b/tests/pos/t7093.scala @@ -0,0 +1,27 @@ +object Test { + + trait A[+X] { + protected[this] def f(x: X): X = x + } + + trait B extends A[B] { + def kaboom = f(new B {}) + } + +// protected[this] disables variance checking +// of the signature of `f`. +// +// C's parent list unifies A[B] with A[C] +// +// The protected[this] loophole is widely used +// in the collections, every newBuilder method +// would fail variance checking otherwise. + class C extends B with A[C] { + override protected[this] def f(c: C) = c + } + +// java.lang.ClassCastException: B$$anon$1 cannot be cast to C +// at C.f(<console>:15) + new C().kaboom +} + |