File tree Expand file tree Collapse file tree 3 files changed +8
-1
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 3 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -117,6 +117,7 @@ public enum ErrorMessageID {
117117 UnapplyInvalidNumberOfArgumentsID ,
118118 StaticFieldsOnlyAllowedInObjectsID ,
119119 CyclicInheritanceID ,
120+ UnableToExtendSealedClassID ,
120121 ;
121122
122123 public int errorNumber () {
Original file line number Diff line number Diff line change @@ -1966,4 +1966,10 @@ object messages {
19661966 |impossible to instantiate an object of this class """
19671967 }
19681968 }
1969+
1970+ case class UnableToExtendSealedClass (pclazz : Symbol )(implicit ctx : Context ) extends Message (UnableToExtendSealedClassID ) {
1971+ val kind = " Syntax"
1972+ val msg = hl " Cannot extend ${" sealed" } $pclazz in a different source file "
1973+ val explanation = " A sealed class or trait can only be extended in the same file as its declaration"
1974+ }
19691975}
Original file line number Diff line number Diff line change @@ -877,7 +877,7 @@ class Namer { typer: Typer =>
877877 if (pclazz.is(Final ))
878878 ctx.error(ExtendFinalClass (cls, pclazz), cls.pos)
879879 if (pclazz.is(Sealed ) && pclazz.associatedFile != cls.associatedFile)
880- ctx.error(em " cannot extend sealed $ pclazz in different compilation unit " , cls.pos)
880+ ctx.error(UnableToExtendSealedClass ( pclazz) , cls.pos)
881881 pt
882882 }
883883 }
You can’t perform that action at this time.
0 commit comments