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.