Summary: | [compiler] CastExpression type should be changed to be a type reference and not an expression | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Olivier Thomann <Olivier_Thomann> | ||||||
Component: | Core | Assignee: | Olivier Thomann <Olivier_Thomann> | ||||||
Status: | VERIFIED FIXED | QA Contact: | |||||||
Severity: | normal | ||||||||
Priority: | P3 | CC: | deepakazad, srikanth_sankaran, stephan.herrmann | ||||||
Version: | 3.7 | Flags: | stephan.herrmann:
review+
|
||||||
Target Milestone: | 3.7 M6 | ||||||||
Hardware: | PC | ||||||||
OS: | Windows 7 | ||||||||
Whiteboard: | |||||||||
Attachments: |
|
Description
Olivier Thomann
2011-02-24 11:36:51 EST
That cleanup would be great, but in my understanding the parser can NOT guarantee that the type is actually a type (that's how I read consumeCastExpressionLL1()). Are you thinking of making the grammar smarter or of converting the expression into a type reference inside CastExpression(Expression,Expression) ? Excuse my curiosity :) This is what I thought initially as well, but in order to get into consumeCastExpressionLL1(), it means that the rule InsideCastExpressionLL1 was called. And this rule calls: org.eclipse.jdt.internal.compiler.parser.Parser.consumeInsideCastExpressionLL1() where the name is actually converted to a type reference. So I believe that the parser can make sure that it is always a type reference. So there is no need to change the existing grammar. (In reply to comment #2) cool! Created attachment 189730 [details]
Possible fix
First draft.
Another good reason to fix this is that this is actually mandatory to support jsr 308 (annotations on type). Srikanth, I let you review the patch. Thanks. Created attachment 189740 [details]
Proposed fix
Same as before with some additional cleanup.
Olivier, is this the same issue discussed here: http://dev.eclipse.org/mhonarc/lists/jdt-core-dev/msg01909.html or a different one ? May be not, as that issue was resolved under https://bugs.eclipse.org/bugs/show_bug.cgi?id=292364. I'll take a look. (In reply to comment #7) > Olivier, is this the same issue discussed here: > http://dev.eclipse.org/mhonarc/lists/jdt-core-dev/msg01909.html > or a different one ? yes, but to the difference that the fix for bug 292364 didn't go as far as this one does which means that the corresponding field inside the CastExpression class should be a type refererence and not a name reference. Released for 3.7M6. Srikanth, this will be verified in the verification phase. For the records: For a minute I was puzzled about the additional casts to TypeReference inside CompletionParser. It turns out these are safe based on the assumption that consumeInsideCastExpression() has been called before, which in the case of the CompletionParser indeed pushes a type reference onto the expression stack. Verified for 3.7 M6 via code inspection. |