@@ -655,12 +655,14 @@ object RefChecks {
655
655
}
656
656
657
657
/** Verify classes extending AnyVal meet the requirements */
658
- private def checkAnyValSubclass (clazz : Symbol )(implicit ctx : Context ) =
658
+ private def checkDerivedValueClass (clazz : Symbol )(implicit ctx : Context ) =
659
659
if (isDerivedValueClass(clazz)) {
660
660
if (clazz.is(Trait ))
661
661
ctx.error(" Only classes (not traits) are allowed to extend AnyVal" , clazz.pos)
662
- else if (clazz.is(Abstract ))
662
+ if (clazz.is(Abstract ))
663
663
ctx.error(" `abstract' modifier cannot be used with value classes" , clazz.pos)
664
+ if (! clazz.isStatic)
665
+ ctx.error(" value class cannot be an inner class" , clazz.pos)
664
666
}
665
667
666
668
type LevelAndIndex = immutable.Map [Symbol , (LevelInfo , Int )]
@@ -708,7 +710,7 @@ import RefChecks._
708
710
* - only one overloaded alternative defines default arguments
709
711
* - applyDynamic methods are not overloaded
710
712
* - all overrides conform to rules laid down by `checkAllOverrides`.
711
- * - any value classes conform to rules laid down by `checkAnyValSubClass `.
713
+ * - any value classes conform to rules laid down by `checkDerivedValueClass `.
712
714
* - this(...) constructor calls do not forward reference other definitions in their block (not even lazy vals).
713
715
* - no forward reference in a local block jumps over a non-lazy val definition.
714
716
* - a class and its companion object do not both define a class or module with the same name.
@@ -778,7 +780,7 @@ class RefChecks extends MiniPhase { thisTransformer =>
778
780
checkParents(cls)
779
781
checkCompanionNameClashes(cls)
780
782
checkAllOverrides(cls)
781
- checkAnyValSubclass (cls)
783
+ checkDerivedValueClass (cls)
782
784
tree
783
785
}
784
786
0 commit comments