Bug 83965 - [1.5][compiler] Widening conversion is possible when unboxing in a cast expression
Summary: [1.5][compiler] Widening conversion is possible when unboxing in a cast expre...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M5   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-28 15:01 EST by Olivier Thomann CLA
Modified: 2005-02-15 06:41 EST (History)
0 users

See Also:


Attachments
Test case (3.33 KB, text/plain)
2005-01-28 15:02 EST, Olivier Thomann CLA
no flags Details
Apply on HEAD of jdt.core project (1.17 KB, patch)
2005-01-29 18:16 EST, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2005-01-28 15:01:46 EST
The compiler should compile the attached test case. Right now we fail with:

----------
1. ERROR in c:\tests_sources\X.java
 (at line 4)
	short s = (short) _byte;
	          ^^^^^^^^^^^^^
Cannot cast from Byte to short
----------
2. ERROR in c:\tests_sources\X.java
 (at line 5)
	int i = (int) _byte;
	        ^^^^^^^^^^^
Cannot cast from Byte to int
----------
3. ERROR in c:\tests_sources\X.java
 (at line 6)
	long l = (long) _byte;
	         ^^^^^^^^^^^^
Cannot cast from Byte to long
----------
4. ERROR in c:\tests_sources\X.java
 (at line 7)
	float f = (float) _byte;
	          ^^^^^^^^^^^^^
Cannot cast from Byte to float
----------
5. ERROR in c:\tests_sources\X.java
 (at line 8)
	double d = (double) _byte;
	           ^^^^^^^^^^^^^^
Cannot cast from Byte to double
----------
6. ERROR in c:\tests_sources\X.java
 (at line 27)
	int i = (int) _character;
	        ^^^^^^^^^^^^^^^^
Cannot cast from Character to int
----------
7. ERROR in c:\tests_sources\X.java
 (at line 28)
	long l = (long) _character;
	         ^^^^^^^^^^^^^^^^^
Cannot cast from Character to long
----------
8. ERROR in c:\tests_sources\X.java
 (at line 29)
	float f = (float) _character;
	          ^^^^^^^^^^^^^^^^^^
Cannot cast from Character to float
----------
9. ERROR in c:\tests_sources\X.java
 (at line 30)
	double d = (double) _character;
	           ^^^^^^^^^^^^^^^^^^^
Cannot cast from Character to double
----------
10. ERROR in c:\tests_sources\X.java
 (at line 46)
	double d = (double) _float;
	           ^^^^^^^^^^^^^^^
Cannot cast from Float to double
----------
11. ERROR in c:\tests_sources\X.java
 (at line 53)
	long l = (long) _integer;
	         ^^^^^^^^^^^^^^^
Cannot cast from Integer to long
----------
12. ERROR in c:\tests_sources\X.java
 (at line 54)
	float f = (float) _integer;
	          ^^^^^^^^^^^^^^^^
Cannot cast from Integer to float
----------
13. ERROR in c:\tests_sources\X.java
 (at line 55)
	double d = (double) _integer;
	           ^^^^^^^^^^^^^^^^^
Cannot cast from Integer to double
----------
14. ERROR in c:\tests_sources\X.java
 (at line 68)
	int i = (int) _short;
	        ^^^^^^^^^^^^
Cannot cast from Short to int
----------
15. ERROR in c:\tests_sources\X.java
 (at line 69)
	long l = (long) _short;
	         ^^^^^^^^^^^^^
Cannot cast from Short to long
----------
16. ERROR in c:\tests_sources\X.java
 (at line 70)
	float f = (float) _short;
	          ^^^^^^^^^^^^^^
Cannot cast from Short to float
----------
17. ERROR in c:\tests_sources\X.java
 (at line 71)
	double d = (double) _short;
	           ^^^^^^^^^^^^^^^
Cannot cast from Short to double
----------
18. ERROR in c:\tests_sources\X.java
 (at line 87)
	float f = (float) _long;
	          ^^^^^^^^^^^^^
Cannot cast from Long to float
----------
19. ERROR in c:\tests_sources\X.java
 (at line 88)
	double d = (double) _long;
	           ^^^^^^^^^^^^^^
Cannot cast from Long to double
----------
19 problems (19 errors)

The runtime result should be: OK.
Comment 1 Olivier Thomann CLA 2005-01-28 15:02:14 EST
Created attachment 17565 [details]
Test case
Comment 2 Olivier Thomann CLA 2005-01-29 18:16:56 EST
Created attachment 17569 [details]
Apply on HEAD of jdt.core project
Comment 3 Olivier Thomann CLA 2005-01-29 19:28:11 EST
All tests passed with this patch.
The attached test case should be added as a regression test.
Philippe, could you please review the patch?
Comment 4 Philipe Mulet CLA 2005-02-02 18:14:39 EST
Patch is good.
Integrated. Added AutoboxingTest#test085
Fixed
Comment 5 Jerome Lanneluc CLA 2005-02-15 06:41:52 EST
Verified in I20050214