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

Bug 361785

Summary: [xtend] Compiler generates bogus casts in dispatch method body
Product: [Modeling] TMF Reporter: Sebastian Zarnekow <sebastian.zarnekow>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 Flags: sebastian.zarnekow: indigo+
Version: 2.1.0   
Target Milestone: SR2   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Sebastian Zarnekow CLA 2011-10-24 05:34:03 EDT
Try to implement a type provider with xtend:

def dispatch type(XBinaryOperation bo, JvmTypeReference r, boolean b) {
	.. some impl ..
}

the generated code looks like this (formatting is applied manually in this bug report):

public JvmTypeReference type(
	final XExpression binaryOperation,
	final JvmTypeReference rawExpectation,
	final boolean rawType) {
  if ((binaryOperation instanceof XBinaryOperation)) { <-- unnecessary parenthesis
    return _type(
	(XBinaryOperation)binaryOperation, <-- expected cast
	(JvmTypeReference)rawExpectation, <-- unexpected cast
	(Boolean)rawType <-- unnecessary boxing and unboxing due to cast
	); 
  }
..
Comment 1 Sebastian Zarnekow CLA 2011-10-24 16:55:31 EDT
Pushed to master.
Comment 2 Karsten Thoms CLA 2017-09-19 17:23:33 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 3 Karsten Thoms CLA 2017-09-19 17:34:53 EDT
Closing all bugs that were set to RESOLVED before Neon.0