Bug 437561 - newArrayList doesn't work with type parameter
Summary: newArrayList doesn't work with type parameter
Status: NEW
Alias: None
Product: Xtend
Classification: Tools
Component: Backlog (show other bugs)
Version: 2.6.0   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: 2014-06-16 16:33 EDT by Sven Efftinge CLA
Modified: 2014-06-16 16:33 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sven Efftinge CLA 2014-06-16 16:33:52 EDT
def <T extends Number> m() {
  val T[] t = newArrayOfSize(5)
}

generates wrong Java code.

It could be compiled to something like

T[] t = (T[]) new Number[5]

Alternatively we an error marker could be added.

Workaround add an explicit cast:

def <T extends Number> m() {
  val T[] t = newArrayOfSize(5) as T[]
}