-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] @With generates non-compiling code under Eclipse #2571
Comments
You are right, it does not work. Actually this one is quite interesting, even the delomboked result fails in eclipse while it works in Delomboked code: public class WithInnerGeneric<Z> {
class Inner {
final String x;
@java.lang.SuppressWarnings("all")
public Inner(final String x) {
this.x = x;
}
@java.lang.SuppressWarnings("all")
public WithInnerGeneric<Z>.Inner withX(final String x) {
return this.x == x ? this : new WithInnerGeneric<Z>.Inner(x);
}
}
}
} |
It should be possible to always call the constructor using the nested class name instead of also adding the parent class. This seems to work in all cases I tried. I will change the behaviour and add test cases to cover all the different cases. |
new Outer.Inner() -> new Inner()
We can't generate just |
Note that javac goes out of its way to allow you to have generics on each 'element' in a dotted type name, even though in common java you just never encounter generics anywhere except on the final element. This makes the code of javac considerably more convoluted, and ecj has this as well, which is a very light indication that in this particular instance, ecj's got it wrong, and this IS proper java syntax after all. Not that the slam dunk case is then 'eh, whatever, ecj's problem, we shall ignore it' - but we're still just gathering info. |
Uh, I totally missed that bug, sorry about that. I'm courious why all test cases still pass, I guess I have to understand #2268 completly but I'm to tired for that right now. One thing I noticed is that I only changed the constructor call to use the simple name and the returned type is still |
Yes, I added one and think that I found a solution, I need some more time to properly test all the different cases. |
new Outer<String>.Inner<Integer>() -> new new Outer.Inner()
Describe the bug
Note that the entire issue is about compilation in Eclipse; I am not able to reproduce the issue via Maven.
@With
cannot be used on an inner class where the outer class is generic (I think). An error message such as this is generated when compiled with a recent Java version (used to work on 8):Cannot allocate the member type TestCase<T>.Inner using a parameterized compound name; use its simple name and an enclosing instance of type TestCase<T>
To Reproduce
The following code, compiled with Java 11, generates the above error:
Expected behavior
I expect this to compile under Eclipse, as it used to when running with JDK 8.
Version info (please complete the following information):
The text was updated successfully, but these errors were encountered: