aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Namer.scala
diff options
context:
space:
mode:
authorodersky <odersky@gmail.com>2016-11-16 14:54:27 +0100
committerGitHub <noreply@github.com>2016-11-16 14:54:27 +0100
commit443f93f38e3e4bbc346ff945eb0fa51939f3d3a9 (patch)
tree53460dd13c2026f5a02f0567db0cec4d47261ca5 /src/dotty/tools/dotc/typer/Namer.scala
parent6990bb37ee070ad4ffea21eb7557c4b438f1b295 (diff)
parentd5656f51972f6a8cc122f47abf144bee29fcf022 (diff)
downloaddotty-443f93f38e3e4bbc346ff945eb0fa51939f3d3a9.tar.gz
dotty-443f93f38e3e4bbc346ff945eb0fa51939f3d3a9.tar.bz2
dotty-443f93f38e3e4bbc346ff945eb0fa51939f3d3a9.zip
Merge pull request #1666 from dotty-staging/fix-#1653
Fix #1653: Check "no inherit from final" earlier.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Namer.scala')
-rw-r--r--src/dotty/tools/dotc/typer/Namer.scala11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala
index dd7326fae..687de1e7a 100644
--- a/src/dotty/tools/dotc/typer/Namer.scala
+++ b/src/dotty/tools/dotc/typer/Namer.scala
@@ -656,6 +656,8 @@ class Namer { typer: Typer =>
* (1) It must be a class type with a stable prefix (@see checkClassTypeWithStablePrefix)
* (2) If may not derive from itself
* (3) Overriding type parameters must be correctly forwarded. (@see checkTypeParamOverride)
+ * (4) The class is not final
+ * (5) If the class is sealed, it is defined in the same compilation unit as the current class
*/
def checkedParentType(parent: untpd.Tree, paramAccessors: List[Symbol]): Type = {
val ptype = parentType(parent)(ctx.superCallContext)
@@ -674,7 +676,14 @@ class Namer { typer: Typer =>
}
else if (!paramAccessors.forall(checkTypeParamOverride(pt, _)))
defn.ObjectType
- else pt
+ else {
+ val pclazz = pt.typeSymbol
+ 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)
+ pt
+ }
}
}