Community
Participate
Working Groups
Build Identifier: Closures don't get type information from a cast. This works: var Function<Integer,Integer> s = [x|x * 2] but this doesn't: var s = [x|x * 2] as Function<Integer,Integer> Reproducible: Always Steps to Reproduce: 1. try to compile this declaraion: var s = [x|x * 2] as Function<Integer,Integer>
*** Bug 370173 has been marked as a duplicate of this bug. ***
Casts are generally not used in expected type inference. See also : http://groups.google.com/group/xtend-lang/browse_thread/thread/63a2181439fef757
This becomes more important when closures can coerce to abstract classes, because you may have several abstract classes implementing the same interface. With your patch to allow casts to work for this, I can now choose an abstract class by casting a literal closure. I have a closure-compatible abstract class (given my patch), called SimpleSelectionAdapter, that implements SWT's SelectionListener interface and leaves only widgetSelected() abstract and I can use a closure for it, like this: menuItem.addSelectionListener([e|...] as SimpleSelectionAdapter) If the cast doesn't work, I need to declare a new variable for this, which seems counter to Xtend's focus on programmer convenience.
Something we should look at while reworking the linking / type system
Is an enhancement.
see also bug 403032
*** Bug 403032 has been marked as a duplicate of this bug. ***