[
https://issues.apache.org/jira/browse/GROOVY-12089?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18089054#comment-18089054
]
ASF GitHub Bot commented on GROOVY-12089:
-----------------------------------------
testlens-app[bot] commented on PR #2611:
URL: https://github.com/apache/groovy/pull/2611#issuecomment-4706000712
## 🚨 TestLens detected 1 failed test 🚨
Here is what you can do:
1) Inspect the test failures carefully.
2) If you are convinced that some of the tests are flaky, you can mute them
below.
3) Finally, trigger a rerun by checking the rerun checkbox.
### Test Summary
| Check | Project/Task | Test | Runs |
|---|---|---|---|
| [Build and test / lts \(17, windows-latest,
1\)](https://github.com/apache/groovy/actions/runs/27532610630/job/81374124607?pr=2611)
| :test | GenericsSTCTest > testReturnTypeInferenceWithMethodGenerics18\(\) |
❌ |
🏷️ Commit: 62805bc96261c9b718c327b09f6dd2f408da6963
▶️ Tests: 75873 executed
🟡 Checks: 14/28 completed
### Test Failures
<details>
<summary><strong>GenericsSTCTest >
testReturnTypeInferenceWithMethodGenerics18()</strong> (:test in <a
href="https://github.com/apache/groovy/actions/runs/27532610630/job/81374124607?pr=2611">Build
and test / lts (17, windows-latest, 1)</a>)</summary>
```
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup
failed:
TestScriptea21fcc7572f40578dae33eb42be4157.groovy: 5: unable to resolve
class ListMultimap<java.lang.String, java.lang.Integer>
@ line 5, column 43.
ListMultimap<String, Integer> mmap =
ArrayListMultimap.create()
^
1 error
at
org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:333)
at
org.codehaus.groovy.control.CompilationUnit$ISourceUnitOperation.doPhaseOperation(CompilationUnit.java:989)
at
org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:749)
at
org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:723)
at
groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:423)
at
groovy.lang.GroovyClassLoader.lambda$parseClass$3(GroovyClassLoader.java:364)
at
org.codehaus.groovy.runtime.memoize.ConcurrentCommonCache.getAndPut(ConcurrentCommonCache.java:143)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:364)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:665)
at groovy.lang.GroovyShell.parse(GroovyShell.java:678)
at groovy.lang.GroovyShell.parse(GroovyShell.java:690)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:552)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:588)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:572)
at
groovy.transform.stc.StaticTypeCheckingTestCase.assertScript(StaticTypeCheckingTestCase.groovy:78)
at
groovy.transform.stc.GenericsSTCTest.testReturnTypeInferenceWithMethodGenerics18(GenericsSTCTest.groovy:701)
```
</details>
### Muted Tests
> [!NOTE]
> Checks are currently running using the configuration below.
Select tests to mute in this pull request:
🔲 GenericsSTCTest > testReturnTypeInferenceWithMethodGenerics18\(\) <!
> Groovy 5 ClassNode.getGetterMethod() can clone a getter with a null
> exceptions array when @Entity and @Sortable are combined
> ----------------------------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-12089
> URL: https://issues.apache.org/jira/browse/GROOVY-12089
> Project: Groovy
> Issue Type: Bug
> Components: AST Transforms
> Affects Versions: 5.0.6
> Reporter: Mattias Reichel
> Assignee: Paul King
> Priority: Major
>
> With Groovy 5, a Grails domain class annotated with both {{@Entity}} and
> {{@Sortable}} can fail during canonicalization with:
> {code:java}
> BUG! exception in phase 'canonicalization' in source unit '...' unexpected
> NullPointerException
> Caused by: java.lang.NullPointerException: Cannot read the array length
> because "<local3>" is null
> at
> org.codehaus.groovy.classgen.VariableScopeVisitor.visitConstructorOrMethod(...)
> at
> org.codehaus.groovy.transform.SortableASTTransformation.createSortable(...){code}
> A minimal reproducer is:
> {code:java}
> import grails.persistence.Entity
> import groovy.transform.Sortable
> @Entity
> @Sortable(includes = ['a'])
> class Repro {
> String a
> }{code}
> {{@Sortable}} by itself compiles, and {{@Entity}} by itself compiles. The
> failure only appears when they are combined.
> According to GPT, the Groovy-side branch that introduces the null exceptions
> array is in
> {{{}org.codehaus.groovy.ast.ClassNode#getGetterMethod(String){}}},
> specifically the default-argument getter synthesis branch:
> {code:java}
> } else if (method.hasDefaultValue() &&
> Stream.of(method.getParameters()).allMatch(Parameter::hasInitialExpression)) {
> // GROOVY-11380: getter generated later by default arguments
> if (isNullOrSynthetic.test(getterMethod)) {
> getterMethod = new MethodNode(method.getName(), method.getModifiers()
> & ~ACC_ABSTRACT, method.getReturnType(), Parameter.EMPTY_ARRAY,
> method.getExceptions(), null);
> getterMethod.setSynthetic(true);
> getterMethod.setDeclaringClass(this);
> getterMethod.addAnnotations(method.getAnnotations());
> AnnotatedNodeUtils.markAsGenerated(this, getterMethod);
> getterMethod.setGenericsTypes(method.getGenericsTypes());
> }
> }
> {code}
> If the source method carries a null exceptions array, that null is preserved
> on the synthesized getter and later blows up in
> {{{}VariableScopeVisitor.visitConstructorOrMethod(...){}}}.
> I can also add, that historically, Grails often created methods in AST with a
> null exceptions parameter. With Groovy 5 this blew up in the same way. We
> have therefore changed to consistently pass ClassNode.EMPTY_ARRAY to remedy
> that situation. However, it feels like there should be a guard on the Groovy
> side for this instead of blowing up.
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)