Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 111733

Summary: Invalid assignment operators detected
Product: [Eclipse Project] JDT Reporter: Robbert Jan Grootjans <eclipsebugs>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED INVALID QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Robbert Jan Grootjans CLA 2005-10-06 02:37:35 EDT
The following incorrect assignment operator is not detected:

long var1= 1;
double var2 = 1;
var1 += var2; 

this is:

long var1= 1;
double var2 = 1;
var1 = var1 + var2;
Comment 1 Philipe Mulet CLA 2005-10-06 04:32:09 EDT
This code is legite in Java.
Comment 2 Robbert Jan Grootjans CLA 2005-10-06 10:01:08 EDT
as seen in the arithmetic operator tutorial of sun
(http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arithmetic.html ) The
addition of any primative type with a double type results in a double. This
therefore not be assigned to a double

(In reply to comment #1)
> This code is legite in Java.

Comment 3 Philipe Mulet CLA 2005-10-06 12:56:20 EDT
Pls read JLS 15.26.2. The tutorial doesn't mention special rules for compound
assignments.
Comment 4 Robbert Jan Grootjans CLA 2005-10-06 13:41:06 EDT
It's a lot of fun to see the sun compiler struggle with it's own specification.
Thanks for your time