summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala7
-rw-r--r--test/files/neg/t5882.check15
-rw-r--r--test/files/neg/t5882.scala5
3 files changed, 26 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
diff --git a/test/files/neg/t5882.check b/test/files/neg/t5882.check
new file mode 100644
index 0000000000..df01c7bc0a
--- /dev/null
+++ b/test/files/neg/t5882.check
@@ -0,0 +1,15 @@
+t5882.scala:2: warning: case classes without a parameter list have been deprecated;
+use either case objects or case classes with `()' as parameter list.
+ case class Scope
+ ^
+t5882.scala:2: error: value class may not have nested class definitions
+ case class Scope
+ ^
+t5882.scala:3: error: value class may not have nested class definitions
+ class Foo
+ ^
+t5882.scala:4: error: value class may not have nested module definitions
+ object Bar
+ ^
+one warning found
+three errors found
diff --git a/test/files/neg/t5882.scala b/test/files/neg/t5882.scala
new file mode 100644
index 0000000000..1233eb636f
--- /dev/null
+++ b/test/files/neg/t5882.scala
@@ -0,0 +1,5 @@
+class NodeOps(val n: Any) extends AnyVal {
+ case class Scope
+ class Foo
+ object Bar
+}