diff options
author | Martin Odersky <odersky@gmail.com> | 2016-11-06 09:28:44 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-11-06 09:32:49 +0100 |
commit | c8f54cf0a1438f3a17341eb3458d8eaa76b8293d (patch) | |
tree | f24f83bf69d7738cd48accd4ef5c0b95b6ee0c2d /src/dotty/tools/dotc/typer/RefChecks.scala | |
parent | a55a2607c7376ed81141ef958d6a8eeaeea8fd72 (diff) | |
download | dotty-c8f54cf0a1438f3a17341eb3458d8eaa76b8293d.tar.gz dotty-c8f54cf0a1438f3a17341eb3458d8eaa76b8293d.tar.bz2 dotty-c8f54cf0a1438f3a17341eb3458d8eaa76b8293d.zip |
Fix #1653: Check "no inherit from final" earlier.
The test case is an illegal inheritance from a primitive value class,
which makes this an illegal value class. Previously, the error was
detected by refchecks, but crashes occured earlier (when generating
synthesized methods) or at the same phase block (in extension methods).
The problem is avoided by moving the test to Namer.
Review by @smarter.
Diffstat (limited to 'src/dotty/tools/dotc/typer/RefChecks.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/RefChecks.scala | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/src/dotty/tools/dotc/typer/RefChecks.scala b/src/dotty/tools/dotc/typer/RefChecks.scala index 026015d1d..46bdbf3b3 100644 --- a/src/dotty/tools/dotc/typer/RefChecks.scala +++ b/src/dotty/tools/dotc/typer/RefChecks.scala @@ -72,8 +72,7 @@ object RefChecks { } } - /** Check that final and sealed restrictions on class parents - * and that self type of this class conforms to self types of parents. + /** Check that self type of this class conforms to self types of parents. * and required classes. */ private def checkParents(cls: Symbol)(implicit ctx: Context): Unit = cls.info match { @@ -83,14 +82,8 @@ object RefChecks { if (otherSelf.exists && !(cinfo.selfType <:< otherSelf)) ctx.error(ex"$category: self type ${cinfo.selfType} of $cls does not conform to self type $otherSelf of $relation ${other.classSymbol}", cls.pos) } - for (parent <- cinfo.classParents) { - val pclazz = parent.classSymbol - if (pclazz.is(Final)) - ctx.error(em"cannot extend final $pclazz", cls.pos) - if (pclazz.is(Sealed) && pclazz.associatedFile != cls.associatedFile) - ctx.error(em"cannot extend sealed $pclazz in different compilation unit", cls.pos) + for (parent <- cinfo.classParents) checkSelfConforms(parent, "illegal inheritance", "parent") - } for (reqd <- cinfo.givenSelfType.classSymbols) checkSelfConforms(reqd.typeRef, "missing requirement", "required") case _ => |