Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 405025 - [1.8][ast rewrite] Add rewrite support for cast with intersection types
Summary: [1.8][ast rewrite] Add rewrite support for cast with intersection types
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.3   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: BETA J8   Edit
Assignee: Jay Arthanareeswaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-04-05 13:57 EDT by Jay Arthanareeswaran CLA
Modified: 2013-05-09 12:33 EDT (History)
2 users (show)

See Also:
markus.kell.r: review+


Attachments
Proposed fix (8.16 KB, patch)
2013-04-24 00:25 EDT, Jay Arthanareeswaran CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jay Arthanareeswaran CLA 2013-04-05 13:57:53 EDT
After bug 399792 is released, AST rewrite support should be added to casts with intersection types.
Comment 1 Jay Arthanareeswaran CLA 2013-04-24 00:25:23 EDT
Created attachment 230058 [details]
Proposed fix

Patch with changes to ASTRewriteAnalyzer and new test. The patch also include a fix to DefaultASTVisitor.

Markus, this is a straight forward fix. Could you glance over the patch, please?

Note: The new test is disabled as this is also affected by the formatter bug 401848.
Comment 2 Jay Arthanareeswaran CLA 2013-04-24 00:26:54 EDT
(In reply to comment #1)
> Note: The new test is disabled as this is also affected by the formatter bug
> 401848.

I meant to say, the test is currently failing and has to be disabled if bug 401848 is still open at the time of releasing.
Comment 3 Markus Keller CLA 2013-05-08 12:43:46 EDT
I've already fixed the ASTRewriteAnalyzer with bug 399792 comment 15. That fix inserted the visit(IntersectionType) method at the right position.

I copied my implementation from the structurally equivalent visit(UnionType). However, your implementation that unconditionally calls rewriteNodeList(..) is better, since rewriteNodeList already calls doVisit if there's no change.

We should also remove the same redundant condition check from visit(UnionType), visit(TypeParameter), rewriteExtraDimensionsInfo(..), visit(ExtraDimension), and visit(MethodDeclaration). Basically everywhere where "if (isChanged(" is called and we don't have to scan for a start position.

I think we should not disable the test, but adapt the expected result to the current reality and add a link to the pending formatter bug. It's easy to fix a few failing tests when the formatter fix is ready. But if you disable the test, then we don't have any regression test at all.
Comment 4 Jay Arthanareeswaran CLA 2013-05-09 12:33:00 EDT
Released the fix with changed suggested by Markus via commit:

http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?h=BETA_JAVA8&id=51c6ca3e4dfed3078a1640da7a2ab7f26c899e0a