[
https://issues.apache.org/jira/browse/GROOVY-11817?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18045236#comment-18045236
]
ASF GitHub Bot commented on GROOVY-11817:
-----------------------------------------
eric-milles opened a new pull request, #2357:
URL: https://github.com/apache/groovy/pull/2357
A gap exists between the invocation writer and call site writer selection
for a statically-compiled method that includes `makeDynamic` usage and binary
operations that map to methods, that are implemented at the end of the chain by
[`StaticTypesCallSiteWriter#makeSingleArgumentCall`](https://github.com/apache/groovy/blob/c46a124e6bfd64ff511f85411c1a7dd751a6fd22/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java#L552).
1) Drop setting and checking `DYNAMIC_RESOLUTION` on closure and method.
2) Re-implement `CallSiteWriter` selection within
`AsmClassGenerate#visitArrtibuteOrProperty`.
- I opted to introduce `WriterController#getCallSiteWriterFor(Expression)`
to check for `DYNAMIC_RESOLUTION` node metadata.
- An alternative would be to have ACG perform direct check, like:
```java
CallSiteWriter callSiteWriter = controller.getCallSiteWriter();
if (pexp.getNodeMetaData(DYNAMIC_RESOLUTION) != null
&& controller instanceof StaticTypesWriterController scController) {
callSiteWriter = scController.getRegularCallSiteWriter(); //
GROOVY-6232, GROOVY-11817
}
```
> Various CompileStatic issues when switching to invokedynamic
> ------------------------------------------------------------
>
> Key: GROOVY-11817
> URL: https://issues.apache.org/jira/browse/GROOVY-11817
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 4.0.29
> Environment: mac os
> jdk 17
> Reporter: James Daugherty
> Assignee: Eric Milles
> Priority: Major
>
> I'm trying to switch a rather large Grails 7 project to invoke dynamic, and
> when enabling indy options, I'm seeing compile issues when CompileStatic &
> invokedynamic are used. Some of these issues are seen when a compile static
> extension is used, but they do work when indy is disabled.
>
> I generated a basic Grails application & created reproducers at this GitHub
> repo: [https://github.com/jdaugherty/groovy-grails-compile-static-issues]
> Each reproducer has it's own branch, so please ignore the code at the root of
> main other than the README.md file.
>
> At a high level, here are the issues:
> # Where books is a list of domain objects, calling books[0] errors
> # A second example is provided similar to #1, but after calling the sort()
> call and using `[0]` to get the result
> # a long multiplication issue exists where you can't do `holder.created *
> 1000L`, where created is a property that returns a Long
> # this may be related, but a similar long addition issue exists
>
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)