gorm-neo4j
gorm-neo4j copied to clipboard
Error when add @GrailsCompileStatic annotation to a class with a property called 'attributes'
When I have a class with a property called 'attributes' and add @GrailsCompileStatic annotation, I have a compile error.
Here is the example class
package neo4jSampleApp.core
import grails.compiler.GrailsCompileStatic
@GrailsCompileStatic
class Player extends BaseGraphDomain {
String name
Integer number
List attributes
static belongsTo = [club: Club]
static constraints = {
name nullable: false, blank: false, unique: true
number nullable: false, validator: { (Integer) it > 0 }
attributes nullable: true
}
}
This is the error:
[Static type checking] - Cannot call neo4jSampleApp.core.Player#attributes(java.util.Map <java.lang.String, java.lang.Object>) with arguments [java.util.LinkedHashMap <java.lang.String, java.lang.Boolean>]
@ line 18, column 9.
attributes nullable: true
^
1 error
FAILURE: Build failed with an exception.
Apparently, the compiler try use attributes() method from DynamicAttributes trait.
Almost a year since this ticket opened, any news on it?
+1
My issue is a litte different:
class TestService {
MyObject method(Map params=[:], String value ){} // e.g. method("string",option1:value, option2:value
}
@GrailsCompileStatic
class TestController {
def testService
def controllerMethod() {
testService.method("value",option1:"this",option2:"cuases error")
}
}
Would cause compile error:
[Static type checking] - Cannot find matching method java.lang.Object#method(java.util.LinkedHashMap <java.lang.String, java.lang.String>, java.lang.String). Please check if the declared type is correct and if the method exists.
Just realized after posting this is for NEO4J. This I'm not using, just plain old GrailsCompileStatic, in a controller which may suggest its not a NEO4J issue.