Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 362237 - [xtend] illegal Java code generated for closure call
Summary: [xtend] illegal Java code generated for closure call
Status: CLOSED FIXED
Alias: None
Product: Xtend
Classification: Tools
Component: Core (show other bugs)
Version: 2.2.0   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: M6   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 376037
Blocks:
  Show dependency tree
 
Reported: 2011-10-27 15:53 EDT by Knut Wannheden CLA
Modified: 2017-10-31 11:18 EDT (History)
2 users (show)

See Also:
sven.efftinge: kepler+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Knut Wannheden CLA 2011-10-27 15:53:21 EDT
For the following Xtend2 class:

class Other<T> {
	def bar((T)=>Object o) {
		o.apply(42) // <- obviously wrong
	}
}

the following illegal Java is generated:

import org.eclipse.xtext.xbase.lib.Functions.Function1;

@SuppressWarnings("all")
public class Other<T extends Object>  {
  public Object bar(final Function1<? super T,? extends Object> o) {
    Object _apply = o.apply(((Integer)42));
    return _apply;
  }
}


There is no corresponding Xtend2 marker.
Comment 1 Knut Wannheden CLA 2012-10-12 02:34:03 EDT
Interestingly enough Xtend properly reports an error marker by moving the generic type parameter to the method level:

class Other {
	def <T> bar((T)=>Object o) {
		o.apply(new Integer(42)) // <- obviously wrong
	}
}

The error is then: "Incompatible types. Expected T but was java.lang.Integer".
Comment 2 Dennis Huebner CLA 2013-02-13 06:11:53 EST
Fixed in the meantime
Comment 3 Eclipse Webmaster CLA 2017-10-31 11:06:50 EDT
Requested via bug 522520.

-M.
Comment 4 Eclipse Webmaster CLA 2017-10-31 11:18:15 EDT
Requested via bug 522520.

-M.