Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.6.3
-
Fix Version/s: 1.6.4, 1.7-beta-1
-
Component/s: Compiler
-
Labels:None
-
Environment:eclipse 3.5M7 + mac os x jdk 1.6 + groovy eclipse 1.6.3.20090514
-
Testcase included:yes
-
Number of attachments :
Description
The following sample does not work :
@Category(Tet)
class TestCategory {
//String getName() {return "hello"}
String getSuperName() {
String myname = "" // CENTRAL POINT
return myname + " yeah"
}
}
interface Tet {
String getName()
}
class MyTest implements Tet {
String getName() {return "hi"}
}
def onetest = new MyTest()
println onetest.getName()
use(TestCategory) {
println onetest.getSuperName()
}
The stack trace of the error compiling this code with groovy 1.6.3 is :
BUG! exception in phase 'canonicalization' in source unit '/eclipses/workspaces/geny-runtime/groovy.generator.uml2/src/test.groovy' illegal left expression for declaration: org.codehaus.groovy.ast.expr.PropertyExpression@14956342[object: org.codehaus.groovy.ast.expr.VariableExpression@4a1bf766[variable: $this] property: ConstantExpression[myname]] at org.codehaus.groovy.ast.expr.DeclarationExpression.check(DeclarationExpression.java:48) at org.codehaus.groovy.ast.expr.DeclarationExpression.<init>(DeclarationExpression.java:37) at org.codehaus.groovy.ast.expr.DeclarationExpression.transformExpression(DeclarationExpression.java:72) at org.codehaus.groovy.ast.ClassCodeExpressionTransformer.transform(ClassCodeExpressionTransformer.java:90) at org.codehaus.groovy.transform.CategoryASTTransformation$1.transform(CategoryASTTransformation.java:115)
When using 'name' for assignment at the CENTRAL POINT of the code the error is the same.
When using 'this.name' for assignment at the CENTRAL POINT of the code the error is (a bit more explicit) :
BUG! exception in phase 'canonicalization' in source unit '/eclipses/workspaces/geny-runtime/groovy.generator.uml2/src/test.groovy' illegal left expression for declaration: org.codehaus.groovy.ast.expr.PropertyExpression@292bf0be[object: org.codehaus.groovy.ast.expr.VariableExpression@4a1bf766[variable: $this] property: ConstantExpression[myname]]