Community
Participate
Working Groups
The following Xtend class: class Other { def <T extends (Object)=>T> T bar(T t) { bar(t).apply(bar(t)) } } compiles to the following illegal Java: import org.eclipse.xtext.xbase.lib.Functions.Function1; @SuppressWarnings("all") public class Other { public <T extends Function1<? super Object,? extends T>> T bar(final T t) { T _bar = this.bar(t); T _bar_1 = this.<Object>bar(t); // <- THIS DOES NOT COMPILE T _apply = _bar.apply(_bar_1); return _apply; } } Basically the "<Object>" is superfluous and wrong. Workaround: Change the Xtend code to: class Other { def <T extends (Object)=>T> T bar(T t) { bar(t).apply(<T>bar(t)) } }
A different example with similar problems: class Other { def <T> bar(T t) { <Integer>bar(t) } } does not have any error markers and is compiled to the illegal code: @SuppressWarnings("all") public class Other { public <T extends Object> Object bar(final T t) { Object _bar = this.<Integer>bar(t); return _bar; } }
(In reply to comment #1) > A different example with similar problems: > > class Other { > def <T> bar(T t) { > <Integer>bar(t) > } > } > > does not have any error markers Seems to be related to bug 341771
Created attachment 227011 [details] StackOverflowError
class Other { def <T extends (Object)=>T> T bar(T t) { bar(t).apply(bar(t)) } } Produces java.lang.StackOverflowError see attachment
class Other { def <T extends (Object)=>T> T bar(T t) { bar(t).apply(<T>bar(t)) } } Still wont work
(In reply to comment #5) > class Other { > def <T extends (Object)=>T> T bar(T t) { > bar(t).apply(<T>bar(t)) > } > } > > Still wont work Tests add (Ignore): org.eclipse.xtend.core.tests.compiler.CompilerTest.testGenericsBug362240() org.eclipse.xtend.core.tests.compiler.CompilerTest.testGenericsBug362240_1()
Changing to critical, because eclipse would not start any more, if the last workbench state has an open Xtend editor that contains following code: def <T extends (Object)=>T> T bar(T t) { bar(t).apply(bar(t)) }
Tests seem to work like a charm with latest. Please reopen if I missed something.
(In reply to comment #8) > Tests seem to work like a charm with latest. Please reopen if I missed > something. Was it fixed in the meantime? I've tested it with: Xtend SDK 2.4.0.v201302121845 org.eclipse.xtend.sdk.feature.group
Requested via bug 522520. -M.