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 {
117
117
UnapplyInvalidNumberOfArgumentsID ,
118
118
StaticFieldsOnlyAllowedInObjectsID ,
119
119
CyclicInheritanceID ,
120
+ UnableToExtendSealedClassID ,
120
121
;
121
122
122
123
public int errorNumber () {
Original file line number Diff line number Diff line change @@ -1966,4 +1966,10 @@ object messages {
1966
1966
|impossible to instantiate an object of this class """
1967
1967
}
1968
1968
}
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
+ }
1969
1975
}
Original file line number Diff line number Diff line change @@ -877,7 +877,7 @@ class Namer { typer: Typer =>
877
877
if (pclazz.is(Final ))
878
878
ctx.error(ExtendFinalClass (cls, pclazz), cls.pos)
879
879
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)
881
881
pt
882
882
}
883
883
}
You can’t perform that action at this time.
0 commit comments