groovy

support inner classes (or at least nested classes)

Details

  • Type: Sub-task Sub-task
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 1.7-rc-1
  • Component/s: None
  • Labels:
    None
  • Number of attachments :
    0

Description

This causes OutOfMemoryException...

class A {
class B {}
}

we should fix it

Issue Links

Activity

Hide
Chris Poirier added a comment -

The parser now does support inner classes, but ASTs (and classes) are not being generated from the CSTs....

Show
Chris Poirier added a comment - The parser now does support inner classes, but ASTs (and classes) are not being generated from the CSTs....
Hide
blackdrag blackdrag added a comment -

support for inner classes

Show
blackdrag blackdrag added a comment - support for inner classes
Hide
Daniel.Sun added a comment -

If possible, please support the anonymous inner class too.

Thanks.

Show
Daniel.Sun added a comment - If possible, please support the anonymous inner class too. Thanks.
Hide
David Smiley added a comment -

I'm really surprised inner classes (anonymous or not) are not supported in Groovy. I like to think of Groovy as doing what Java does and more but that definitely not true. Inner classes are there for convenience. If anything, Groovy is about convenience to quickly get the job done, often quite succinctly... so it's surprising to see that Groovy still doesn't do this yet. Several times I've wanted to create a quick anonymous class because I've got to override some method or another but instead I have to go create a top level class and throw it at the bottom of the current class. Pretty awkward. It's ironic that Java introduced this convenience back in version 1.1 and somehow Groovy doesn't have this yet.

Show
David Smiley added a comment - I'm really surprised inner classes (anonymous or not) are not supported in Groovy. I like to think of Groovy as doing what Java does and more but that definitely not true. Inner classes are there for convenience. If anything, Groovy is about convenience to quickly get the job done, often quite succinctly... so it's surprising to see that Groovy still doesn't do this yet. Several times I've wanted to create a quick anonymous class because I've got to override some method or another but instead I have to go create a top level class and throw it at the bottom of the current class. Pretty awkward. It's ironic that Java introduced this convenience back in version 1.1 and somehow Groovy doesn't have this yet.
Hide
Guillaume Laforge added a comment -

It's already on the Groovy roadmap.

Show
Guillaume Laforge added a comment - It's already on the Groovy roadmap.
Hide
blackdrag blackdrag added a comment -

for David....

In Groovy it is a bit more difficult to realize inner classes in its full extend, because of the MOP. in most cases you can use closures instead, so it is not that awful. but that does not solve all cases. We are aware of that and inner classes are on the agenda... we just need to define it completely first and do not loose sight of other things we want to have too.

Show
blackdrag blackdrag added a comment - for David.... In Groovy it is a bit more difficult to realize inner classes in its full extend, because of the MOP. in most cases you can use closures instead, so it is not that awful. but that does not solve all cases. We are aware of that and inner classes are on the agenda... we just need to define it completely first and do not loose sight of other things we want to have too.
Hide
Olivier Mengué added a comment -

See GROOVY-1328 which is also about multiple classes defined in one source file (but not inner). Since declaring multiple classes in one script gives an unusable script, one can not even create manually inner classes.
We're back to Java 1.1 days...

Show
Olivier Mengué added a comment - See GROOVY-1328 which is also about multiple classes defined in one source file (but not inner). Since declaring multiple classes in one script gives an unusable script, one can not even create manually inner classes. We're back to Java 1.1 days...
Hide
blackdrag blackdrag added a comment -

Olivier... first, the feature is targeted for 1.8, so just wait a little and it is done. Second, just putting multiple classes in one file doesn't make the file unusable. We are here to discuss the facts if possible.

Show
blackdrag blackdrag added a comment - Olivier... first, the feature is targeted for 1.8, so just wait a little and it is done. Second, just putting multiple classes in one file doesn't make the file unusable. We are here to discuss the facts if possible.
Hide
blackdrag blackdrag added a comment -

fixed

Show
blackdrag blackdrag added a comment - fixed

People

Vote (10)
Watch (6)

Dates

  • Created:
    Updated:
    Resolved: