| Summary: | [xtend] erroneous wildcard generated | ||
|---|---|---|---|
| Product: | [Modeling] TMF | Reporter: | Knut Wannheden <knut.wannheden> |
| Component: | Xtext | Assignee: | Project Inbox <tmf.xtext-inbox> |
| Status: | CLOSED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | sven.efftinge |
| Version: | 2.0.0 | Flags: | sven.efftinge:
indigo+
|
| Target Milestone: | RC1 | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
We need to validate that wildcards are generally not allowed as type arguments for method or constructor invocations. I have added a check for wildcards being not allowed at that position. Closing all bugs that were set to RESOLVED before Neon.0 Closing all bugs that were set to RESOLVED before Neon.0 |
The following Xtend2 snippet: def foo() { var x = <?> newArrayList('foo', 'bar') x = newArrayList(42) } compiles to: public ArrayList<?> foo() { ArrayList<?> _xblockexpression = null; { ArrayList<?> _newArrayList = CollectionLiterals.<?>newArrayList("foo", "bar"); // COMPILE ERROR ArrayList<?> x = _newArrayList; ArrayList<Integer> _newArrayList_1 = CollectionLiterals.<Integer>newArrayList(((Integer)42)); ArrayList<?> _x = x = _newArrayList_1; _xblockexpression = (_x); } return _xblockexpression; } This results in the Java compile error "Wildcard is not allowed at this location". The same is true for a "more sensible" use case: def foo() { var x = <? extends CharSequence> newArrayList('foo', 'bar') x = newArrayList(new StringBuilder('baz')) } which compiles to: public ArrayList<? extends CharSequence> foo() { ArrayList<? extends CharSequence> _xblockexpression = null; { ArrayList<? extends CharSequence> _newArrayList = CollectionLiterals.<? extends CharSequence>newArrayList("foo", "bar"); ArrayList<? extends CharSequence> x = _newArrayList; StringBuilder _stringBuilder = new StringBuilder("baz"); ArrayList<StringBuilder> _newArrayList_1 = CollectionLiterals.<StringBuilder>newArrayList(_stringBuilder); ArrayList<? extends CharSequence> _x = x = _newArrayList_1; _xblockexpression = (_x); } return _xblockexpression; }