| Summary: | [Quickfix] "Create Method" quickfix with generic parameter types needs to add type parameter to new method | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Luke Hutchison <luke.hutch> |
| Component: | UI | Assignee: | Jeff Johnston <jjohnstn> |
| Status: | CLOSED MOVED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | gautier.desaintmartinlacaze, jjohnstn, stephan.herrmann |
| Version: | 4.8 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Whiteboard: | stalebug | ||
Another related but different problem: if the destination is already generic, the correct type variable is not used.
Before quickfix:
public class Bug {
private static class Class1<T> {
T t;
Class2<T> c2;
void method() {
c2.useT(t); // Quickfix "Create method 'useT(T)' in Class2"
}
}
private static class Class2<U> {
}
}
After quickfix:
public class Bug {
private static class Class1<T> {
T t;
Class2<T> c2;
void method() {
c2.useT(t);
}
}
private static class Class2<U> {
public void useT(T t) { // Should be (U t), not (T t)
}
}
}
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. If you have further information on the current state of the bug, please add it. 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. Pinging so that this doesn't get closed. 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. If you have further information on the current state of the bug, please add it. 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. (In reply to Luke Hutchison from comment #0) > Given this method > > public static <T> void test(T a) { > test(a, a); // error here > } > > Apply "Quickfix > Create method 'test(T, T)'", which adds this method: > > private static void test(T a, T a2) { > } > > The method is missing its own type parameter <T>. This problem has been opened as issue: https://github.com/eclipse-jdt/eclipse.jdt.ui/issues/322 and fixed for 4.26 M3 (In reply to Luke Hutchison from comment #1) > Another related but different problem: if the destination is already > generic, the correct type variable is not used. > > Before quickfix: > > public class Bug { > > private static class Class1<T> { > T t; > Class2<T> c2; > > void method() { > c2.useT(t); // Quickfix "Create method 'useT(T)' in Class2" > } > } > > private static class Class2<U> { > } > } > > After quickfix: > > public class Bug { > > private static class Class1<T> { > T t; > Class2<T> c2; > > void method() { > c2.useT(t); > } > } > > private static class Class2<U> { > public void useT(T t) { // Should be (U t), not (T t) > } > } > } This has been opened in github as: https://github.com/eclipse-jdt/eclipse.jdt.ui/issues/330 and will be fixed by 4.27 M1 Both issues have been opened in github so closing this bug. |
Given this method public static <T> void test(T a) { test(a, a); // error here } Apply "Quickfix > Create method 'test(T, T)'", which adds this method: private static void test(T a, T a2) { } The method is missing its own type parameter <T>.