[
https://issues.apache.org/jira/browse/GROOVY-11711?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18009925#comment-18009925
]
Saravanan commented on GROOVY-11711:
------------------------------------
Hi Eric,
I am not sure if this change is causing a different issue. Now when I compile,
I get an UnsupportedOperationException thrown because this line
[https://github.com/apache/groovy/blob/2847eea28df9cb777142e00239b0d81c07004da3/src/main/java/org/codehaus/groovy/control/ResolveVisitor.java#L1459|http://example.com/]
is trying to put an entry in an immutable empty map that was either created
[here|https://github.com/apache/groovy/blob/2847eea28df9cb777142e00239b0d81c07004da3/src/main/java/org/codehaus/groovy/control/ResolveVisitor.java#L272]
or
[here|https://github.com/apache/groovy/blob/2847eea28df9cb777142e00239b0d81c07004da3/src/main/java/org/codehaus/groovy/control/ResolveVisitor.java#L288]
If I just change that code to create new HashMap<>() instead of
Collections.emptyMap(), then things work
> Templates not recognized for inner classes in certain scenarios
> ---------------------------------------------------------------
>
> Key: GROOVY-11711
> URL: https://issues.apache.org/jira/browse/GROOVY-11711
> Project: Groovy
> Issue Type: Bug
> Components: Compiler
> Affects Versions: 5.0.0-beta-1
> Reporter: Saravanan
> Assignee: Eric Milles
> Priority: Minor
> Fix For: 4.0.28, 5.0.0-beta-2, 3.0.26
>
>
> Compiling this code
> {code:java}
> public class RecordTesting<MyTemplate1> {
> static class Blah {
> }
> class InnerClass implements List<MyTemplate1> {
> }
> }
> {code}
> results in this compile error
> {code:java}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup
> failed:
> testdata/plugins/records/RecordTesting.java: 11: unable to resolve class
> MyTemplate1
> @ line 11, column 38.
> class InnerClass implements List<MyTemplate1> {
>
> ^testdata/plugins/records/RecordTesting.java: 11: unable to resolve class
> MyTemplate1
> @ line 11, column 38.
> class InnerClass implements List<MyTemplate1> {
> ^ {code}
> If I remove the static in front of class Blah, it will work fine. I narrowed
> this down to how the resolvevisitor tracks genericParameterNames. Without the
> static, it keeps the outer class generics in this map, but when it sees the
> static on class Blah, it clears it out. Now all inner nodes after Blah will
> see an error whenever MyTemplate1 is used. Didnt dig deeper
--
This message was sent by Atlassian Jira
(v8.20.10#820010)