Issue Details (XML | Word | Printable)

Key: GROOVY-2679
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Paul King
Reporter: Peter Niederwieser
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
groovy

Allow to omit square brackets in annotations when list has just one element (similar to Java)

Created: 11/Mar/08 04:00 PM   Updated: 23/Oct/08 06:08 AM   Resolved: 21/Mar/08 07:49 PM
Return to search
Component/s: syntax
Affects Version/s: 1.5.4
Fix Version/s: 1.6-beta-1

Time Tracking:
Not Specified

Issue Links:
Related
 


 Description  « Hide

Let's say we have the following enum declaration (in Java):

@interface Person {
String[] friends();
}

In Java, curly braces may be omitted if a person has just one friend:

@Person(friends="Joe")
class Jane {}

In Groovy, this gives a compile error:
Annotation list attributes must use Groovy notation [el1, el2]

Of course @Person(friends=["Joe"]) still works, but it would be nice if Groovy also supported the abbreviated syntax.



Paul King made changes - 21/Mar/08 07:49 PM
Field Original Value New Value
Assignee Paul King [ paulk ]
Resolution Fixed [ 1 ]
Fix Version/s 1.6-beta-1 [ 14008 ]
Status Open [ 1 ] Resolved [ 5 ]
Paul King made changes - 03/May/08 11:14 PM
Status Resolved [ 5 ] Closed [ 6 ]
Guillaume Laforge made changes - 23/Oct/08 06:08 AM
Link This issue relates to GROOVY-3115 [ GROOVY-3115 ]