summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Typers.scala
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2012-09-13 23:53:24 +0200
committerJason Zaugg <jzaugg@gmail.com>2012-09-14 00:04:59 +0200
commit41dfb1612126c3b5763da25f4c3bdd73d605f12b (patch)
tree60e2ad8109bbe6b51a7d967f8d40f06e51ee53ce /src/compiler/scala/tools/nsc/typechecker/Typers.scala
parentea651e6fe187920d207aa5fe3c645d294e72e627 (diff)
downloadscala-41dfb1612126c3b5763da25f4c3bdd73d605f12b.tar.gz
scala-41dfb1612126c3b5763da25f4c3bdd73d605f12b.tar.bz2
scala-41dfb1612126c3b5763da25f4c3bdd73d605f12b.zip
SI-6359 Deep prohibition of templates in value class
This seems to have been the intent of 95d532 / SI-5882.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index d90141b732..e96f2f75c7 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -1405,14 +1405,15 @@ trait Typers extends Modes with Adaptations with Tags {
unit.error(clazz.pos, "value class needs to have exactly one public val parameter")
}
}
- body foreach {
- case md: ModuleDef =>
- unit.error(md.pos, "value class may not have nested module definitions")
- case cd: ClassDef =>
- unit.error(cd.pos, "value class may not have nested class definitions")
- case md: DefDef if md.symbol.isConstructor && !md.symbol.isPrimaryConstructor =>
- unit.error(md.pos, "value class may not have secondary constructors")
- case _ =>
+
+ def valueClassMayNotHave(at: Tree, what: String) = unit.error(at.pos, s"value class may not have $what")
+ body.foreach {
+ case dd: DefDef if dd.symbol.isAuxiliaryConstructor => valueClassMayNotHave(dd, "secondary constructors")
+ case t => t.foreach {
+ case md: ModuleDef => valueClassMayNotHave(md, "nested module definitions")
+ case cd: ClassDef => valueClassMayNotHave(cd, "nested class definitions")
+ case _ =>
+ }
}
for (tparam <- clazz.typeParams)
if (tparam hasAnnotation definitions.SpecializedClass)