| Summary: | [Xtend / Xbase] [compiler] usage of wildcards | ||
|---|---|---|---|
| Product: | [Modeling] TMF | Reporter: | Sven Efftinge <sven.efftinge> |
| Component: | Xtext | Assignee: | Project Inbox <tmf.xtext-inbox> |
| Status: | CLOSED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | sebastian.zarnekow |
| Version: | 2.0.0 | Flags: | sven.efftinge:
indigo+
|
| Target Milestone: | SR1 | ||
| Hardware: | PC | ||
| OS: | Mac OS X - Carbon (unsup.) | ||
| Whiteboard: | |||
| Bug Depends on: | 341770 | ||
| Bug Blocks: | |||
|
Description
Sven Efftinge
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);
}
}
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. Preliminary scheduled for 2.0RC1 postponed to SR1 Pushed to master. Closing all bugs that were set to RESOLVED before Neon.0 Closing all bugs that were set to RESOLVED before Neon.0 |