File tree 6 files changed +26
-2
lines changed
compiler/src/dotty/tools/dotc/parsing
6 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -492,6 +492,15 @@ object JavaParsers {
492
492
case SEALED =>
493
493
flags |= Flags .Sealed
494
494
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()
495
504
case _ =>
496
505
val privateWithin : TypeName =
497
506
if (isPackageAccess && ! inInterface) thisPackageName
Original file line number Diff line number Diff line change 2
2
3 |class Pet permits Cat { // error
3
3
| ^^^^^^^
4
4
| 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 1
1
package i18533 ;
2
2
3
- public class Cat extends Pet {
3
+ public final class Cat extends Pet {
4
4
5
5
}
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 1
1
package i18533 ;
2
2
3
- public sealed class Pet permits Cat {
3
+ public sealed class Pet permits Cat , Dog {
4
4
5
5
}
You can’t perform that action at this time.
0 commit comments