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 /src/dotty/tools/dotc/typer/Namer.scala | |
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 'src/dotty/tools/dotc/typer/Namer.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/Namer.scala | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala index 7f85badf5..b24916be8 100644 --- a/src/dotty/tools/dotc/typer/Namer.scala +++ b/src/dotty/tools/dotc/typer/Namer.scala @@ -579,7 +579,12 @@ class Namer { typer: Typer => else { val pt = checkClassTypeWithStablePrefix(ptype, parent.pos, traitReq = parent ne parents.head) if (pt.derivesFrom(cls)) { - ctx.error(i"cyclic inheritance: $cls extends itself", parent.pos) + val addendum = parent match { + case Select(qual: Super, _) if ctx.scala2Mode => + "\n(Note that inheriting a class of the same name is no longer allowed)" + case _ => "" + } + ctx.error(i"cyclic inheritance: $cls extends itself$addendum", parent.pos) defn.ObjectType } else pt |