AislingHPE opened a new issue, #14088:
URL: https://github.com/apache/grails-core/issues/14088
### Expected Behavior
The following code compiles successfully when running `./gradlew
compileGroovy` in a Grials project
grails-app/init/mypackage/Application.grooy
```
package mypackage
import grails.boot.config.GrailsAutoConfiguration
import groovy.transform.CompileStatic
@CompileStatic(extensions = [
'org.grails.compiler.DynamicFinderTypeCheckingExtension'
])
class Application extends GrailsAutoConfiguration {
static void main(String[] args) {
def someMap = [a:"B"]
def value = someMap["my key"]
println("some other code")
def myStatType = StatType.listOrderByDescription()
}
}
```
### Actual Behaviour
The build failed with a Groovy bug message.
```
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileGroovy'.
> BUG! exception in phase 'class generation' in source unit
'/home/aisling/dev/hpe-cds/central-services-poc/grails-app/init/com/morpheus/cs/Application.groovy'
At line 12 column 21
On receiver: someMap with message: getAt and arguments: my key
This method should not have been called. Please try to create a simple
example reproducing this error and file a bug report at
https://issues.apache.org/jira/browse/GROOVY
```
### Steps To Reproduce
On Grails version 7.0.0-M3, I've encountered an issue when using GORM
functions with GrailsCompileStatic and accessing Map values with this notation:
`def value = someMap["key"]`. Here, `StatType` is a domain class in this
applications, and therefore has all the GORM functions associated with that,
which are supplied by `DynamicFinderTypeCheckingExtension` in this case.
This only seems to occur when I use a GORM function on a domain class in the
same function as preforming a map access with `a["b"]` syntax. Doing `a.b` or
`a.getAt("b")` do not trigger this issue.
Other things I've tried:
- Compiling with TypeChecked or no annotation instead of CompileStatic does
not trigger this issue.
- Removing the GORM function invocation from the function makes the issue
disappear.
- Moving the GORM function invocation to before the map access still causes
the same issue on the line with the map access (ie code order does not matter
so long as they are in the same function).
- Moving either statement inside an `if` statement does not fix the issue.
### Environment Information
Jdk 17.0.14-jbr
Groovy 4.0.24
Gradle 8.11.1
### Example Application
_No response_
### Version
7.0.0-M3
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]