Bug 79844 - [1.5][annot] when int value can be contained in a short, the cast is not required
Summary: [1.5][annot] when int value can be contained in a short, the cast is not requ...
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 M4   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-30 21:49 EST by Olivier Thomann CLA
Modified: 2004-12-14 22:47 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2004-11-30 21:49:33 EST
This code should compile fine, but latest reports a error.

@interface I {
    short value() default 0;
}

public class X {
    @I(2) void foo() {
    }
}

----------
1. ERROR in c:\tests_sources\X.java (at line 2)
	short value() default 0;
	                      ^
Type mismatch: cannot convert from int to short
----------
2. ERROR in c:\tests_sources\X.java (at line 6)
	@I(2) void foo() {
	   ^
Type mismatch: cannot convert from int to short
----------
2 problems (2 errors)

Adding a cast fixes the problem.
Comment 1 Philipe Mulet CLA 2004-12-01 06:04:18 EST
Enabled assignment compatibility rules (with constant narrowing).
Added AnnotationTest#test066-067
Comment 2 Philipe Mulet CLA 2004-12-01 06:09:06 EST
Fixed
Comment 3 Olivier Thomann CLA 2004-12-14 22:47:11 EST
Verified in 200412140800