diff options
author | Martin Odersky <odersky@gmail.com> | 2012-07-28 18:35:49 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2012-07-28 18:35:59 +0200 |
commit | 95d53235834ab650ded6768958697d2901fd4dd3 (patch) | |
tree | e712179c1b975aa880746ef82d581353a5480931 /src | |
parent | 1f95d356ee69a442f98aedc024a1aa7e4672d20a (diff) | |
download | scala-95d53235834ab650ded6768958697d2901fd4dd3.tar.gz scala-95d53235834ab650ded6768958697d2901fd4dd3.tar.bz2 scala-95d53235834ab650ded6768958697d2901fd4dd3.zip |
Closes SI-5882
I have added a restriction that value classes may not contain inner classes or objects. This makes sense as the "outer" field of any such classes or objects would be ephemeral, with surprising results. SIP-15 has been changed accordingly.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 269ab9611a..393cbadc6a 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1385,6 +1385,11 @@ 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 _ => + } for (tparam <- clazz.typeParams) if (tparam hasAnnotation definitions.SpecializedClass) unit.error(tparam.pos, "type parameter of value class may not be specialized") @@ -4531,7 +4536,7 @@ trait Typers extends Modes with Adaptations with Tags { assert(errorContainer == null, "Cannot set ambiguous error twice for identifier") errorContainer = tree } - + val fingerPrint: Long = name.fingerPrint var defSym: Symbol = tree.symbol // the directly found symbol |