Community
Participate
Working Groups
Build Identifier: I20110310-1119 Xtend2 SDK: 2.0.0.v201105191503 The IterableExtensions contains many methods for Iterable-Operations. If in the .xtend-File a Set<? extends Extension> is defined, it is translated to IterableExtensions.<Extension>forEach(...). This leads to Iterable<Extension> as first required parameter, but it is a <? extends Extension>. The methods in IterablesExtension should be defined like public static final <T> void forEach(Iterable<? extends T> iterable, Function1<? super T, ?> function) { Reproducible: Always Steps to Reproduce: 1. Add this code to one xtend-File: > var List<? extends String> v = null; > v.forEach(e|e.toString()) 2. Save and let it be compiled 3. The generated Java-File contains an error
This is a bug in the compiler / validation and not in the iterable extensions.
The generated code should look like this if the parameters' type is something with a wildcard extends: List<? extends String> list = null; IterableExtensions.forEach(list, new Functions.Function1<Object, String>() { public String apply(Object p) { return null; } });
The same problem exists for the ListExtensions.map function. Here the function must be of the correct type to call methods on the elements. var List<MyDslGenerator> v = new ArrayList<MyDslGenerator>(); v.add(new MyDslGenerator()); var List<? extends IGenerator> v2 = v; var m2 = v2.map(e|e.toString())
The issues are sill reproducable
Pushed to master.
Closing all bugs that were set to RESOLVED before Neon.0