File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -1470,7 +1470,11 @@ object messages {
14701470 extends Message (CannotExtendAnyValID ) {
14711471 val msg = hl """ $sym cannot extend ${" AnyVal" }"""
14721472 val kind = " Syntax"
1473- val explanation = " "
1473+ val explanation =
1474+ hl """ Only classes (not traits) are allowed to extend ${" AnyVal" }, but traits may extend
1475+ | ${" Any" } to become ${Green (" \" universal traits\" " )} which may only have ${" def" } members.
1476+ |Universal traits can be mixed into classes that extend ${" AnyVal" }.
1477+ | """
14741478 }
14751479
14761480 case class CannotHaveSameNameAs (sym : Symbol , cls : Symbol )(implicit ctx : Context )
Original file line number Diff line number Diff line change @@ -449,7 +449,7 @@ object Checking {
449449 }
450450 if (isDerivedValueClass(clazz)) {
451451 if (clazz.is(Trait ))
452- ctx.error(" Only classes (not traits) are allowed to extend AnyVal " , clazz.pos)
452+ ctx.error(CannotExtendAnyVal (clazz) , clazz.pos)
453453 if (clazz.is(Abstract ))
454454 ctx.error(" `abstract' modifier cannot be used with value classes" , clazz.pos)
455455 if (! clazz.isStatic)
You can’t perform that action at this time.
0 commit comments