Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 352849

Summary: [xtend] Generic Type and method parameters
Product: [Modeling] TMF Reporter: Benjamin Schwertfeger <benjamin.schwertfeger>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: christian.dietrich.opensource, mail, sebastian.zarnekow
Version: 2.0.0Flags: sebastian.zarnekow: indigo+
Target Milestone: SR2   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

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