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 {
1470
1470
extends Message (CannotExtendAnyValID ) {
1471
1471
val msg = hl """ $sym cannot extend ${" AnyVal" }"""
1472
1472
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
+ | """
1474
1478
}
1475
1479
1476
1480
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 {
449
449
}
450
450
if (isDerivedValueClass(clazz)) {
451
451
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)
453
453
if (clazz.is(Abstract ))
454
454
ctx.error(" `abstract' modifier cannot be used with value classes" , clazz.pos)
455
455
if (! clazz.isStatic)
You can’t perform that action at this time.
0 commit comments