| Summary: | [xtend] illegal Java code generated for closure call | ||
|---|---|---|---|
| Product: | [Tools] Xtend | Reporter: | Knut Wannheden <knut.wannheden> |
| Component: | Core | Assignee: | Project Inbox <xtend-inbox> |
| Status: | CLOSED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | dennis.huebner, sebastian.zarnekow |
| Version: | 2.2.0 | Flags: | sven.efftinge:
kepler+
|
| Target Milestone: | M6 | ||
| Hardware: | PC | ||
| OS: | Mac OS X - Carbon (unsup.) | ||
| Whiteboard: | |||
| Bug Depends on: | 376037 | ||
| Bug Blocks: | |||
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".
Fixed in the meantime Requested via bug 522520. -M. Requested via bug 522520. -M. |
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.