Type information can get lost
This snippet
List<String> x = Lists.newArrayList();
is converted to
var x = Lists.newArrayList
and the type of x is lost.
I'm not sure about this one. It's lost alright, but aren't you converting to Xtend because you do not what to explicitly define the types everywhere.
Differenting theses cases from
ArrayList<String> x = Lists.newArrayList();
would only be possible when j2x converter be called by an eclipse plugin (that has access to all the type information). In text only mode the return type of List.newArrayList() is unknown, so it's impossible to detect that it's different that the declared List<String>
That's true, but the field/variable has a type declaration in Java and it can be used as it is, I think.
I will try to disambiguate a little:
- Lists.newArrayList is a generic method whose return type depends on the type of the variable it is assitgned to.
- "var x = Lists.newArrayList" is the same as "List x = Lists.newArrayList();" where we get a generic (and mostly unusable list)
- in normal xtend usage, one would write "var List<String> x = Lists.newArrayList", which is what I think the converter should output too