File tree Expand file tree Collapse file tree 6 files changed +26
-2
lines changed
compiler/src/dotty/tools/dotc/parsing Expand file tree Collapse file tree 6 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -492,6 +492,15 @@ object JavaParsers {
492492 case SEALED =>
493493 flags |= Flags .Sealed
494494 in.nextToken()
495+ // JEP-409: Special trick for the 'non-sealed' java keyword
496+ case IDENTIFIER if in.name.toString == " non" =>
497+ val lookahead = in.LookaheadScanner ()
498+ ({lookahead.nextToken(); lookahead.token}, {lookahead.nextToken(); lookahead.name.toString}) match
499+ case (MINUS , " sealed" ) =>
500+ in.nextToken(); in.nextToken() // skip '-' and 'sealed'. Nothing more to do
501+ case _ =>
502+ syntaxError(em " Identifier ' ${in.name}' is not allowed here " )
503+ in.nextToken()
495504 case _ =>
496505 val privateWithin : TypeName =
497506 if (isPackageAccess && ! inInterface) thisPackageName
Original file line number Diff line number Diff line change 223 |class Pet permits Cat { // error
33 | ^^^^^^^
44 | A type declaration that has a permits clause should have a sealed modifier
5+ -- Error: tests/neg/i18533/non-SCALA_ONLY.java:4:7 ---------------------------------------------------------------------
6+ 4 |public non class Test { // error
7+ | ^^^
8+ | Identifier 'non' is not allowed here
Original file line number Diff line number Diff line change 11package i18533 ;
22
3- public class Cat extends Pet {
3+ public final class Cat extends Pet {
44
55}
Original file line number Diff line number Diff line change 1+ package i18533 ;
2+
3+ // Special test for the non-sealed trick (See JavaParsers.scala::modifiers)
4+ public non class Test { // error
5+
6+ }
Original file line number Diff line number Diff line change 1+ package i18533 ;
2+
3+ public non-sealed class Dog extends Pet {
4+
5+ }
Original file line number Diff line number Diff line change 11package i18533 ;
22
3- public sealed class Pet permits Cat {
3+ public sealed class Pet permits Cat , Dog {
44
55}
You can’t perform that action at this time.
0 commit comments