diff options
author | Martin Odersky <odersky@gmail.com> | 2015-10-22 17:05:47 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-10-22 17:05:47 +0200 |
commit | 746889b4ed0f53e433c123ddb2b90dece1298fff (patch) | |
tree | 97ace638167e1a3c568b2b8ec151f1febae95347 /src/dotty/tools/dotc/typer/Namer.scala | |
parent | b927f66d4b90bc34cc864f596b8d1dc97fdc3ebe (diff) | |
download | dotty-746889b4ed0f53e433c123ddb2b90dece1298fff.tar.gz dotty-746889b4ed0f53e433c123ddb2b90dece1298fff.tar.bz2 dotty-746889b4ed0f53e433c123ddb2b90dece1298fff.zip |
Check for cyclic inheritance.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Namer.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/Namer.scala | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala index 3f732f80c..3c491fa7a 100644 --- a/src/dotty/tools/dotc/typer/Namer.scala +++ b/src/dotty/tools/dotc/typer/Namer.scala @@ -575,7 +575,14 @@ class Namer { typer: Typer => def checkedParentType(parent: untpd.Tree): Type = { val ptype = parentType(parent)(ctx.superCallContext) if (cls.isRefinementClass) ptype - else checkClassTypeWithStablePrefix(ptype, parent.pos, traitReq = parent ne parents.head) + 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) + defn.ObjectClass.typeRef + } + else pt + } } val selfInfo = |