Skip to content

Conversation

@jonnybot0
Copy link
Contributor

@jonnybot0 jonnybot0 commented Jul 21, 2025

It looks like a subtle compilation bug was introduced in 3306448.

Under the hood, the root cause seemed to be this:

Caused by: java.lang.UnsupportedOperationException
at java.base/java.util.AbstractMap.put(AbstractMap.java:209)
at org.codehaus.groovy.control.ResolveVisitor.resolveGenericsHeader(ResolveVisitor.java:1452)
at org.codehaus.groovy.control.ResolveVisitor.resolveGenericsHeader(ResolveVisitor.java:1409)

Based on a look in the debugger, without the change in this PR, the genericParameterNames field will be a Collections$EmptyMap, which is immutable and therefore doesn't support PUT operations, leading to the above exception.

This is the same issue I raised on the release thread for 4.0.28.

Under the hood, the root cause seemed to be this:

Caused by: java.lang.UnsupportedOperationException
	at java.base/java.util.AbstractMap.put(AbstractMap.java:209)
	at org.codehaus.groovy.control.ResolveVisitor.resolveGenericsHeader(ResolveVisitor.java:1452)
	at org.codehaus.groovy.control.ResolveVisitor.resolveGenericsHeader(ResolveVisitor.java:1409)

Based on a look in the debugger, without this change, the
genericParameterNames field will be a Collections$EmptyMap, which is
immutable and therefore doesn't support PUT operations.
@jonnybot0 jonnybot0 changed the title Fix generics handling error GROOVY-11719 - Fix generics handling error Jul 21, 2025
@jonnybot0 jonnybot0 closed this Jul 22, 2025
@eric-milles eric-milles deleted the GROOVY-9526-regression-semantic-analysis-exception branch July 31, 2025 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant