Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 346763 - IterableExtensions should support Iterable<? extends T>
Summary: IterableExtensions should support Iterable<? extends T>
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.0.0   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: SR2   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-20 16:15 EDT by Benjamin Schwertfeger CLA
Modified: 2017-09-19 18:11 EDT (History)
2 users (show)

See Also:
sebastian.zarnekow: indigo+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Schwertfeger CLA 2011-05-20 16:15:13 EDT
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
Comment 1 Sebastian Zarnekow CLA 2011-05-20 16:19:31 EDT
This is a bug in the compiler / validation and not in the iterable extensions.
Comment 2 Sebastian Zarnekow CLA 2011-05-20 16:26:53 EDT
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;
	}
});
Comment 3 Benjamin Schwertfeger CLA 2011-05-20 16:53:43 EDT
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())
Comment 4 Sebastian Zarnekow CLA 2011-08-28 12:48:16 EDT
The issues are sill reproducable
Comment 5 Sebastian Zarnekow CLA 2011-09-29 09:43:17 EDT
Pushed to master.
Comment 6 Karsten Thoms CLA 2017-09-19 18:01:24 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 7 Karsten Thoms CLA 2017-09-19 18:11:45 EDT
Closing all bugs that were set to RESOLVED before Neon.0