Bug 60282

Summary: Extra Parens produces Invalid cast type expression
Product: [Eclipse Project] JDT Reporter: Stephen Gevers <eclipse>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: RESOLVED INVALID QA Contact:
Severity: normal    
Priority: P3    
Version: 3.0   
Target Milestone: 3.0 M9   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Stephen Gevers CLA 2004-04-28 12:57:40 EDT
Description:
public class test {
	public static void main (String args[]) {
		Object foo = null;
		String bar = ((String)) foo;
	}
}

The cast with double parens produces an "Invalid cast type expression" message
in Eclipse 3.0 M8.  No error is reported in 2.1.1.

I realize that this is easy to fix, but I have just imported a ton of code that
has double parens around its casts for some reason.  Although the extra parens
don't help anything, I don't think that they are illegal.
Comment 1 Olivier Thomann CLA 2004-04-28 16:59:24 EDT
You could at least try to compile it using javac.
javac 1.3.1 reports:
Test.java:4: ';' expected
                String bar = ((String)) foo;
                                        ^
Test.java:4: cannot resolve symbol
symbol  : variable String
location: class Test
                String bar = ((String)) foo;
                               ^
2 errors

Jikes 1.18 reports:
Found 1 semantic error compiling "C:/tests_sources/Test.java":

     4.                 String bar = ((String)) foo;
                                      ^------^
*** Semantic Error: Expression found where a type is expected.

javac 1.4.2 reports:
Test.java:4: ';' expected
                String bar = ((String)) foo;
                                        ^
1 error

I think this was a bug in 2.1.1 that has been fixed.

I will check 2.1.3.
Comment 2 Olivier Thomann CLA 2004-04-28 17:08:08 EDT
This is still a problem against 2.1.3.
In 3.0 the problem is fixed.

It looks like another case of bug 38124.
Comment 3 Stephen Gevers CLA 2004-04-28 23:44:29 EDT
You're right, I should have run it through javac.  I've just never seen extra
parenthesis cause a problem.  I did try to find an existing bug first, but bug
38124 doesn't have the word parens or parenthesis anywhere, so it didn't turn up
in my search.  Thanks for the clarification.  I guess the status of this bug
should be INVALID then.
Comment 4 Philipe Mulet CLA 2004-04-29 06:39:47 EDT
Closing