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 @@ -486,6 +486,15 @@ object JavaParsers {
486486 case SEALED =>
487487 flags |= Flags .Sealed
488488 in.nextToken()
489+ // JEP-409: Special trick for the 'non-sealed' java keyword
490+ case IDENTIFIER if in.name.toString == " non" =>
491+ val lookahead = in.LookaheadScanner ()
492+ ({lookahead.nextToken(); lookahead.token}, {lookahead.nextToken(); lookahead.name.toString}) match
493+ case (MINUS , " sealed" ) =>
494+ in.nextToken(); in.nextToken() // skip '-' and 'sealed'. Nothing more to do
495+ case _ =>
496+ syntaxError(em " Identifier ' ${in.name}' is not allowed here " )
497+ in.nextToken()
489498 case _ =>
490499 val privateWithin : TypeName =
491500 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