-
Notifications
You must be signed in to change notification settings - Fork 320
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
Adding a field to an anonymous class in a method produces invalid Java code #2330
Comments
is this a problem with 2.27 or 2.26 ?!? it i a regression or just not working |
might also be related to #2256 |
@szarnekow any idea why the type inference in XtendJvmModelInferrer.inferLocalClass(AnonymousClass) not working? can it be we dont handle generics at all there? |
I've just upgraded to 2.27 and have the issue in both 2.26 and 2.27. |
so it is not a regression |
The compile strategy for anon inner classes makes a deliberate named class as a basetype since Xtend allows to write code like
Without the abstract base class being emitted it wouldn't be valid Java source. |
The 2.26.0.v20220228-0901 compiler produced invalid Java for this by defining a constructor with a
final ? object
argument:It's also a bit odd that it's creating a local named class inside the method only to leave all of the initialisation and override logic in an anonymous subclass of that class it has just defined anyway. Maybe this is related, but I can live with it if it's not.
I'm sure that I've defined a field inside an anonymous class elsewhere, so I can only assume that there's something specific about
AbstractTreeIterator
that breaks it.new AbstractTreeIterator<Object>(new Object()) { ... }
doesn't avoid the issue.It's easy enough to define the field as a local variable outside the anonymous class, but that's a bit naff.
The text was updated successfully, but these errors were encountered: