Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 355754 - Using the ** operator doesn't do an implicit conversion to int
Summary: Using the ** operator doesn't do an implicit conversion to int
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: EDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 356249 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-08-24 14:47 EDT by Kathy Carroll CLA
Modified: 2017-02-23 14:19 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kathy Carroll CLA 2011-08-24 14:47:01 EDT
I get these this Java error

Cannot cast from Double to int

not these lines of java
  intActual = (int)((org.eclipse.edt.runtime.java.egl.lang.ESmallint.power((short) 5, (short) 3)))
  intActual2 = (int)((EInt.power(int1, int2)))


when generating this program:

program driver type BasicProgram {}
	
	intExpect int = 125;
	
	function main()
		try1();
		try2();
		try3();
	end
	
	function try1()
		intActual int = 5 ** 3;
	end
	
	function try2()
		int1 int = 5;
		int2 int = 3;
		intActual2 int = int1 ** int2;
	end
	
	function try3()
		int1 int = 5;
		int2 int = 3;
		result float = int1 ** int2;
		intActual int = result;
	end
	
end
Comment 1 Matt Heitz CLA 2011-08-29 10:26:31 EDT
I believe the way to fix the bad cast is to generate expr.intValue() not (int)expr when the expr is nullable.  In place of casts to other types, use shortValue, longValue, floatValue, or doubleValue.
Comment 2 Matt Heitz CLA 2011-08-30 16:13:18 EDT
*** Bug 356249 has been marked as a duplicate of this bug. ***
Comment 3 Matt Heitz CLA 2011-08-30 16:13:58 EDT
See the testcase in Bug 355754 for another case where this problem shows up.  (The same solution ought to work for it.)
Comment 4 Matt Heitz CLA 2011-08-30 16:14:45 EDT
Whoops, I should've written "See the testcase in Bug 356249" in that last comment.
Comment 5 Jeff Douglas CLA 2011-09-09 15:48:51 EDT
This will be fixed once Paul fixes the problem of getting the right type of a binary expression.
Comment 6 Jeff Douglas CLA 2011-09-09 16:07:35 EDT
Paul and I investigated further and it is not a type return problem in his code, but it's because the EGL definition files don't match the runtime w.r.t. using objects or primitives. Once these match up, this error goes away.
Comment 7 Jeff Douglas CLA 2011-09-14 12:42:06 EDT
this was fixed by a combination of other bug reports and fixing the runtime definitions
Comment 8 Kathy Carroll CLA 2011-09-16 14:13:15 EDT
works in 201109161325
Comment 9 Lisa Lasher CLA 2011-10-11 16:10:40 EDT
Closing this defect.