Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.5.7
-
Fix Version/s: 1.6.1, 1.5.8, 1.7-beta-1
-
Component/s: Compiler
-
Labels:None
-
Environment:Windows XP, JDK 1.6.0_03
-
Number of attachments :
Description
When I run the following (Groovy 1.5.7):
class BoolTest {
boolean success
boolean isSuccess() {
return success ?: true
}
static void main(args) {
def test = new BoolTest()
}
}
I get this compilation error:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed,
D:\work\temp\BoolTest.groovy: 4: Repetitive method name/signature for method 'boolean isSuccess()' in class 'BoolTest'.
@ line 4, column 5.
boolean isSuccess() {
^
D:\work\temp\BoolTest.groovy: -1: Repetitive method name/signature for method 'boolean isSuccess()' in class 'BoolTest'.
@ line -1, column -1.
2 errors
While the following is fine:
class BoolTest {
String success
String getSuccess() {
return success ?: ""
}
static void main(args) {
def test = new BoolTest()
}
}
Roshan:
I looked into the code where groovy creates getters and setters for the properties if not already provided by the user and for boolean properties, the check to see if a getter is provided is only using get<PropName>. It should check both get<PropName> and is<PropName> if the type of the property is boolean/Boolean.
Activity
| Field | Original Value | New Value |
|---|---|---|
| Fix Version/s | 1.6.1 [ 14852 ] | |
| Fix Version/s | 1.5.8 [ 14630 ] | |
| Fix Version/s | 1.7-beta-1 [ 14014 ] | |
| Description |
When I run the following (Groovy 1.5.7): class BoolTest { boolean success boolean isSuccess() { return success ?: true } static void main(args) { def test = new BoolTest() } } I get this compilation error: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, D:\work\temp\BoolTest.groovy: 4: Repetitive method name/signature for method 'boolean isSuccess()' in class 'BoolTest'. @ line 4, column 5. boolean isSuccess() { ^ D:\work\temp\BoolTest.groovy: -1: Repetitive method name/signature for method 'boolean isSuccess()' in class 'BoolTest'. @ line -1, column -1. 2 errors While the following is fine: class BoolTest { String success String getSuccess() { return success ?: "" } static void main(args) { def test = new BoolTest() } } Roshan: I looked into the code where groovy creates getters and setters for the properties if not already provided by the user and for boolean properties, the check to see if a getter is provided is only using get<PropName>. It should check both get<PropName> and is<PropName> if the type of the property is boolean/Boolean. |
When I run the following (Groovy 1.5.7): {code} class BoolTest { boolean success boolean isSuccess() { return success ?: true } static void main(args) { def test = new BoolTest() } } {code} I get this compilation error: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, D:\work\temp\BoolTest.groovy: 4: Repetitive method name/signature for method 'boolean isSuccess()' in class 'BoolTest'. @ line 4, column 5. boolean isSuccess() { ^ D:\work\temp\BoolTest.groovy: -1: Repetitive method name/signature for method 'boolean isSuccess()' in class 'BoolTest'. @ line -1, column -1. 2 errors While the following is fine: {code} class BoolTest { String success String getSuccess() { return success ?: "" } static void main(args) { def test = new BoolTest() } } {code} Roshan: I looked into the code where groovy creates getters and setters for the properties if not already provided by the user and for boolean properties, the check to see if a getter is provided is only using get<PropName>. It should check both get<PropName> and is<PropName> if the type of the property is boolean/Boolean. |
| Assignee | Roshan Dawrani [ roshandawrani ] |
| Resolution | Fixed [ 1 ] | |
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Status | Resolved [ 5 ] | Closed [ 6 ] |