diff options
author | Martin Odersky <odersky@gmail.com> | 2015-12-11 09:03:12 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-12-14 14:30:10 +0100 |
commit | 3bbc2bf62cebcf6fd7cb22d6b3e1227095e7964a (patch) | |
tree | 645bc5b3ef68ef7f0870622f488d8756e13912db /tests | |
parent | 82f59af99df93e198b31b14a854fc22af97f04a9 (diff) | |
download | dotty-3bbc2bf62cebcf6fd7cb22d6b3e1227095e7964a.tar.gz dotty-3bbc2bf62cebcf6fd7cb22d6b3e1227095e7964a.tar.bz2 dotty-3bbc2bf62cebcf6fd7cb22d6b3e1227095e7964a.zip |
Better diagnosis for cyclic references caused by class clashes.
We now get a cyclic reference when inheriting from an inner class
with the same name in an outer supertype. Since this was legal
in Scala2 it's good to explain that particular case. Test case
in overrideClass.scala
Diffstat (limited to 'tests')
-rw-r--r-- | tests/neg/overrideClass.scala | 20 | ||||
-rw-r--r-- | tests/neg/overrides.scala | 19 |
2 files changed, 20 insertions, 19 deletions
diff --git a/tests/neg/overrideClass.scala b/tests/neg/overrideClass.scala new file mode 100644 index 000000000..803d97dd9 --- /dev/null +++ b/tests/neg/overrideClass.scala @@ -0,0 +1,20 @@ + abstract class FooA { + type A <: Ax; + abstract class Ax; + abstract class InnerA { + type B <: A; + def doB : B; + } + } + trait FooB extends FooA { + type A <: Ax; + trait Ax extends super.Ax { def xxx : Int; } // error: cyclic inheritance: trait Ax extends itself + // (Note that inheriting a class of the same name is no longer allowed) + abstract class InnerB extends InnerA { + // type B <: A; + val a : A = doB; + a.xxx; + doB.xxx; + } + } + diff --git a/tests/neg/overrides.scala b/tests/neg/overrides.scala index 727759e3c..b7e598184 100644 --- a/tests/neg/overrides.scala +++ b/tests/neg/overrides.scala @@ -1,22 +1,3 @@ - abstract class FooA { - type A <: Ax; - abstract class Ax; - abstract class InnerA { - type B <: A; - def doB : B; - } - } - trait FooB extends FooA { - type A <: Ax; - trait Ax extends super.Ax { def xxx : Int; } // error: classes cannot be overridden - abstract class InnerB extends InnerA { - // type B <: A; - val a : A = doB; - a.xxx; - doB.xxx; - } - } - package p1 { abstract class T1 { protected def bug(p: Int = 1): Int // without 'protected' compiles fine |