grails-core
grails-core copied to clipboard
`@CacheEvict` & CompileStatic errors for key closures
Issue description
The following code worked in Grails 6 on a class annotated with @CompileStatic
@CacheEvict(value = "apiTokens", key = { token })
void deleteByToken(String token) {
In Grails 7, this fails with:
[Static type checking] - The variable [token] is undeclared.
As a work around @CompileDynamic can be added and this will work...
I think I ran into the same issue, had to use arg# instead of parameter name:
- @Cacheable(cacheNames = ES_CACHE_NAME, key = "{#request.myField, #request.SsomeOtherField}")
+ @Cacheable(cacheNames = ES_CACHE_NAME, key = "{#a0.myField, #a0.someOtherField}")