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

Bug 342434

Summary: [Xtend / Xbase] [compiler] usage of wildcards
Product: [Modeling] TMF Reporter: Sven Efftinge <sven.efftinge>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: sebastian.zarnekow
Version: 2.0.0Flags: sven.efftinge: indigo+
Target Milestone: SR1   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Bug Depends on: 341770    
Bug Blocks:    

Description Sven Efftinge CLA 2011-04-11 09:19:59 EDT

    
Comment 1 Sven Efftinge CLA 2011-04-11 09:21:16 EDT
For the following code :

anArrayIsAListIsAnArray() {
	val x = newArrayList('foo','bar','baz').toArray
	val arrayAccess = new ArrayAccess(x)
	arrayAccess.set(1,arrayAccess.get(0))
	return arrayAccess.get(2)
}

non compilable code is generated (wrong usage if wildcards)


// the referenced Java class for completeness :

public class ArrayAccess<T> {
	private T[] internal;
	
	public ArrayAccess(T[] internal) {
		super();
		this.internal = internal;
	}
	
	public T get(int index) {
		return internal[index];
	}
	
	public T set(int index, T value) {
		return internal[index] = value;
	}
	
	public <X> ArrayAccess<X> access(X[] val) {
		return new ArrayAccess<X>(val);
	}
	
}
Comment 2 Sebastian Zarnekow CLA 2011-04-11 09:22:56 EDT
Does it compile if you pass the type arguments to the constructor invocation? IIRC we don't have type inference for constructor args and an open issue regarding the validation of type arguments.
Comment 3 Sebastian Zarnekow CLA 2011-05-04 06:11:30 EDT
Preliminary scheduled for 2.0RC1
Comment 4 Sven Efftinge CLA 2011-05-04 09:59:04 EDT
postponed to SR1
Comment 5 Sebastian Zarnekow CLA 2011-07-18 15:54:22 EDT
Pushed to master.
Comment 6 Karsten Thoms CLA 2017-09-19 16:57:01 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 7 Karsten Thoms CLA 2017-09-19 17:08:16 EDT
Closing all bugs that were set to RESOLVED before Neon.0