Comments (3)
Just in case you are wondering how I found such a weird example: In AspectJ, an old regression test ensuring compatibility between AJC and ECJ started to fail, because ECJ now behaves differently than before.
from eclipse.jdt.core.
This is a tricky one.
First observation: our grammar lacks suitable /:$compliance 22:/
declarations for this feature, but even with that, the example is parsed as an implicitly declared class. Only DiagnoseParser uses that information in order to produce suitable error messages (see usage of Parser.rules_compliance
).
The core problem is: syntactically blahblahpackage pack;
leaves no doubt that this is a variable declaration, and since we are not in a method context it must be a field declaration, which can only happen in a type declaration, explicit or implicit.
some ideas:
(1) should Parser.parse()
directly check act
similar to how DiagnoseParser does it? But then what?
(2) should we insert an empty token to the grammar, like:
ImplicitlyDeclaredClassBodyDeclarations ::= ClassMemberDeclaration StartImplicitType ImplicitlyDeclaredClassBodyDeclarations
Then we could let StartImplicitType
trigger a consume method that does - what?
- discard the previously parsed ClassMemberDeclaration?
- reset stacks? which? how to ensure a consistent state?
(3) perhaps it's enough to make Parser.consumeInternalCompilationUnitWithPotentialImplicitlyDeclaredClass()
conditional like this:
- if the feature is not enabled, then
- if we find exactly one type declaration, we could promote this to the toplevel of the CU, and then
- report all fields and methods found outside the class as misplaced constructs
- if we find exactly one type declaration, we could promote this to the toplevel of the CU, and then
@mickaelistria as the author of Parser.consumeInternalCompilationUnitWithPotentialImplicitlyDeclaredClass()
, do you want to follow up along the lines of idea (3)?
from eclipse.jdt.core.
Sorry, I don't plan to work on it on short term.
from eclipse.jdt.core.
Related Issues (20)
- Various tests are failing on master HEAD
- [Sealed Types] Failure to cast an Object to a generic sealed interface type HOT 5
- Generic inferral is not correctly performed when using wildcard HOT 3
- Comparator Errors HOT 3
- [Sealed Types] Strange error from ECJ: Syntax error on token "permits", permits expected HOT 11
- JDT Core throws ClassCastException: NullTypeBinding cannot be cast to class ArrayBinding HOT 4
- Bug 533327 - [9] Implement JEP 211 HOT 2
- ClasspathMultiReleaseJar no longer finds non module-info class files
- Statically importing a class confuses ECJ HOT 1
- Clean build: SourceFile(s) read twice HOT 20
- In some nestings, autocomplete stops working
- ArrayIndexOutOfBoundsException in org.eclipse.jdt.internal.compiler.parser.Scanner.internalScanIdentifierOrKeyword HOT 5
- [Sealed types] ECJ allows a class to be declared as both sealed and non-sealed HOT 4
- Error in JDT Core during AST creation when using exhaustive switch statement and @NotNull HOT 1
- [Sealed types] Disjointness behavior difference vis a vis javac HOT 2
- [Sealed types + switch expression] Internal inconsistency warning at compile time and verify error at runtime HOT 5
- ClasspathTests / JavaModelTests seem to be unstable HOT 1
- [Switch expression + Sealed Types] Suspect diagnostic about switch expression being inexhaustive HOT 2
- [Sealed Types + Enhanced Switch] Incorrect diagnostic about switch not being exhaustive
- Switch pattern matching accepts invalid case HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eclipse.jdt.core.