summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJosh Suereth <Joshua.Suereth@gmail.com>2012-09-13 16:37:42 -0700
committerJosh Suereth <Joshua.Suereth@gmail.com>2012-09-13 16:37:42 -0700
commit255e096f1ac0f0c8f19d599404ef668af0f28341 (patch)
treedb51e80110d392be38f879fd8ee58d706218a20e /src
parent62c1dffe4f72a3fb3bd04631c0b392843d97ee5b (diff)
parent41dfb1612126c3b5763da25f4c3bdd73d605f12b (diff)
downloadscala-255e096f1ac0f0c8f19d599404ef668af0f28341.tar.gz
scala-255e096f1ac0f0c8f19d599404ef668af0f28341.tar.bz2
scala-255e096f1ac0f0c8f19d599404ef668af0f28341.zip
Merge pull request #1300 from retronym/ticket/6359
SI-6359 Deep prohibition of templates in value class
Diffstat (limited to 'src')
-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 73ccdeec2c..738dde7895 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)