Bug 417776 - Unbounded wildcard code generation changed
Summary: Unbounded wildcard code generation changed
Status: NEW
Alias: None
Product: Xtend
Classification: Tools
Component: Core (show other bugs)
Version: 2.4.3   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-22 17:18 EDT by Karsten Becker CLA
Modified: 2013-11-28 05:15 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Karsten Becker CLA 2013-09-22 17:18:43 EDT
The code:
 result = new ArrayElement<Name<?>>(name, indices)
previously resulted in the working code:
 ArrayElement<Name<? extends Object>> _arrayElement_1 = new ArrayElement<Name<? extends Object>>(result, _vHDL_1);

but with 2.4.3 it generates:
 ArrayElement<Name<? extends Object>> _arrayElement_1 = new ArrayElement<Name<?>>(result, _vHDL_1);

Which is not correct: Type mismatch: cannot convert from ArrayElement<Name<?>> to ArrayElement<Name<? extends Object>>
Comment 1 Sebastian Zarnekow CLA 2013-09-22 17:27:07 EDT
Does the class Name declare an upper bound constraint for the type parameter?
Comment 2 Karsten Becker CLA 2013-09-22 17:32:00 EDT
Name is declared as:
 public abstract class Name<T extends Name<?>> extends Primary {
and primary as:
 public abstract class Primary<T extends Primary<?>> extends Expression<T> {

(They fucked up the library here so that you can not do the Primary parametrization correctly... It is thus a raw type)

The result type is forced from the parameter list:
	def private Name<?> getRef(Name<?> name, HDLVariableRef ref) {
		var result = name

If I remove the wildcard at the parameter, as well as the constructtor invocation, then it compiles..
Comment 3 Karsten Becker CLA 2013-09-22 17:38:01 EDT
Here is a minimal working example:
import java.util.List
import java.util.LinkedList

class A<T extends A<?>> {
	
}
class B<T extends B<?>> extends A {
	
}
class Bug417776 {
	def test(List<A<?>> t){
		var a=t
		a=new LinkedList<A<?>>
	}
}