Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when add @GrailsCompileStatic annotation to a class with a property called 'attributes' #68

Open
AmaliaMV opened this issue Jan 23, 2018 · 2 comments

Comments

@AmaliaMV
Copy link

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.

Here is the link to the example app

@matero
Copy link

matero commented Jan 15, 2019

Almost a year since this ticket opened, any news on it?

@neilabdev
Copy link

neilabdev commented Mar 6, 2019

+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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants