Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 352849 - [xtend] Generic Type and method parameters
Summary: [xtend] Generic Type and method parameters
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-07-22 07:45 EDT by Benjamin Schwertfeger CLA
Modified: 2017-09-19 17:46 EDT (History)
3 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-07-22 07:45:22 EDT
The method
def <T> Collection<T> addAll2(Collection<T> collection, Iterable<? extends T> elements){
	collection.addAll(elements) //ERROR HERE
	collection
}

shows an error, that elements should be an Iterable<? extends T>. If it's written with another generic type instead of ? extends T at the signature the editor shows no bug, but...

def <T, U extends T> Collection<T> addAll2(Collection<T> collection, Iterable<U> elements){
	collection.addAll(elements)
	collection
}

The generated code contains
      CollectionExtensions.<?>addAll(collection, elements);
which is a bug at the method call with type <?>. If you change xtend to 
      collection.<T>addAll(elements)
this works again.
Comment 1 Sebastian Zarnekow CLA 2011-07-23 10:06:56 EDT
The tests for this issue revealed some other problems in the type computation. However, the issue itself was 'mostly' fixed.

The following problem remains:

def <T, U extends T> Collection<T> addAll2(Collection<T> collection,
Iterable<U> elements){
    collection.<T>addAll(elements) <<- for now, this expression requires an explicit type arg
    
}
Comment 2 Sebastian Zarnekow CLA 2011-09-28 11:32:39 EDT
Pushed to master.
Comment 3 Karsten Thoms CLA 2017-09-19 17:35:41 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 4 Karsten Thoms CLA 2017-09-19 17:46:38 EDT
Closing all bugs that were set to RESOLVED before Neon.0