Summary: | [1.5][compiler] M2: Unnecessary cast is necessary | ||||||
---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | David Saff <david> | ||||
Component: | Core | Assignee: | Philipe Mulet <philippe_mulet> | ||||
Status: | VERIFIED FIXED | QA Contact: | |||||
Severity: | normal | ||||||
Priority: | P3 | CC: | jcsahnwaldt, zorzella | ||||
Version: | 3.3 | ||||||
Target Milestone: | 3.3 M3 | ||||||
Hardware: | PC | ||||||
OS: | Windows XP | ||||||
Whiteboard: | |||||||
Attachments: |
|
Description
David Saff
2006-10-03 11:52:22 EDT
Which build ID are you using ? I20060922-0010 Reproduced. class X { void addChildren(Widget w) { if (w instanceof Composite) { Composite composite = (Composite) w; addAll((Widget[]) composite.getChildren()); addAll(composite.getChildren()); } } void addAll(Widget... widgets) { } } class Widget {} class Control extends Widget {} class Composite extends Control { Control[] getChildren() { return null; } } We perform ok in following direct case: class X { void addChildren(Widget w) { if (w instanceof Composite) { Composite composite = (Composite) w; addAll((Control[]) composite.getChildren()); addAll(composite.getChildren()); } } void addAll(Control... widgets) { } } class Widget {} class Control extends Widget {} class Composite extends Control { Control[] getChildren() { return null; } } I would expect the offending cast to be unnecessary. And when unnecessary cast is removed, no varargs warning should occur either. Created attachment 51397 [details]
Proposed patch
Fixed in HEAD Released for 3.3M3 Added VarargsTest#test052-053 Verified for 3.3 M3 using build I20061030-0010 *** Bug 163889 has been marked as a duplicate of this bug. *** *** Bug 170765 has been marked as a duplicate of this bug. *** |