Bug 28824

Summary: Quick Fix: Type Mismatch -> Cast bug [quick fix]
Product: [Eclipse Project] JDT Reporter: Paul Raby <praby>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P2    
Version: 2.1   
Target Milestone: 2.1 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Paul Raby CLA 2002-12-23 06:03:38 EST
When using code assist to apply a cast to the following statement:

DefaultMutableTreeNode root = getParentContainer().treeMapperTree.getModel
().getRoot();

You get:

DefaultMutableTreeNode root = getParentContainer().(DefaultMutableTreeNode) 
treeMapperTree.getModel().getRoot();

When you should get:

DefaultMutableTreeNode root = (DefaultMutableTreeNode) getParentContainer
().treeMapperTree.getModel().getRoot();

Seems to be getting confused about where the cast statement should go because 
the treeMapperTree isn't using getters (i.e. getTreeMapperTree()).  When using 
getters then the cast works fine...

Should also work without getters, hence bug.
Comment 1 Paul Raby CLA 2002-12-23 06:04:31 EST
Affected version: M4 and previous of 2.1
Comment 2 David Audel CLA 2003-01-08 10:00:36 EST
This is not a code assist bug but a quick fix bug

Move to JDTUI
Comment 3 Martin Aeschlimann CLA 2003-01-09 11:45:51 EST
The bug comes from wrong offsets in the AST.
Created test case ASTRewritingExpressionsTest.testCastExpression_bug28824.

Moving to Olivier.
Comment 4 Olivier Thomann CLA 2003-01-09 12:48:58 EST
I am investigating.
Comment 5 Olivier Thomann CLA 2003-01-09 13:33:18 EST
Reproduced. I am working on a fix.
Comment 6 Olivier Thomann CLA 2003-01-09 14:12:01 EST
Fixed and released in 2.1 stream.
Regression test added.
Comment 7 Olivier Thomann CLA 2003-01-09 14:15:43 EST
Fixed.
Comment 8 David Audel CLA 2003-02-06 05:33:21 EST
Verified.