| Summary: | [encapsulate field] refactoring causes compilation error with generic methods | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Jan Wloka <jan.wloka> |
| Component: | UI | Assignee: | JDT-UI-Inbox <jdt-ui-inbox> |
| Status: | CLOSED WONTFIX | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | markus.kell.r |
| Version: | 3.4.1 | ||
| Target Milestone: | --- | ||
| Hardware: | Macintosh | ||
| OS: | Mac OS X - Carbon (unsup.) | ||
| Whiteboard: | stalebug | ||
Move to JDT/UI Whether explicit method type arguments are necessary can be determined using Invocations.isResolvedTypeInferredFromExpectedType(Expression). This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. |
Build ID: M20080911-1700 Steps To Reproduce: The bug can be reproduced with the following example. Perform the "Encapsulate Field..." refactoring on field "elements". public class Foo { static Collection<Boolean> elements; static { elements = Factory.make(); elements.add(true); elements.add(false); } } class Factory { static <T> Collection<T> make() { return new HashSet<T>(); } } The refactoring transforms the assignment in the static initializer block as follows static { setElements(Factory.make()); ... } The compiler complains about the type of the actual parameter of method setElements(). More information: I guess type inference for generics in too complicated here, so that the correct transformation should result in: static { setElements(Factory.<Boolean>make()); ... } I suppose to resolve the issue class AccessAnalyzer should instead of simply copying the right-hand side of a field assignment whenever - it is a method invocation - of a static and parameterized method - with no specified type arguments copy the method invocation and add all type arguments of the method's return type to it.