[ https://issues.apache.org/jira/browse/GROOVY-7742?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
John Wagenleitner updated GROOVY-7742: -------------------------------------- Priority: Major (was: Blocker) > CompileStatic stackoverflow with generic method with different placeholder as > type argument > ------------------------------------------------------------------------------------------- > > Key: GROOVY-7742 > URL: https://issues.apache.org/jira/browse/GROOVY-7742 > Project: Groovy > Issue Type: Bug > Components: Static compilation > Affects Versions: 2.4.6, 2.5.0-beta-1 > Reporter: John Wagenleitner > > The fix in [commit > fae29119a|https://github.com/apache/groovy/commit/fae29119a1102393ae5d1645c3fc1e06547b0ad8] > for master and [commit > 197472cb|https://github.com/apache/groovy/commit/197472cb626bdada5e079c7f0cd145b85502f034] > for 2.4 branch corrected behavior that as a result can create a > stackoverflow: > To reproduce compile the following: > {code} > @groovy.transform.CompileStatic > class Foo { > public <T> Class<T> firstClass(List<Class<T>> classes) { > return classes.first() > } > } > {code} > If you change the placeholder from {{T}} to {{E}} (the placeholder used by > List) it compiles successfully. The > [{{StaticTypeCheckingSupport#applyGenericConnections}} method > |https://github.com/apache/groovy/blob/d6bb5b8ff84b57c2c337c3db5008103b7c6d13d5/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java#L1509] > receives both {{E}} and {{T}} in the {{resolvePlaceholders}} map and because > there is no connection and with the fix to {{equalIncludingGenerics}} a > stackoverflow results. > Stacktrace produced: > {code} > java.lang.StackOverflowError > at > org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext(StaticTypeCheckingSupport.java:1722) > at > org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext(StaticTypeCheckingSupport.java:1750) > at > org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext(StaticTypeCheckingSupport.java:1722) > at > org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext(StaticTypeCheckingSupport.java:1750) > {code} > Found as a result of testing master against a Grails build and noticing a > stackoverflow when compiling [a method within > GparsPromiseFactory|https://github.com/jwagenleitner/grails-core/blob/69e7bb967fb8e8e331927cf2521b48cea93ee059/grails-async/src/main/groovy/org/grails/async/factory/gpars/GparsPromiseFactory.groovy#L106-L109] -- This message was sent by Atlassian JIRA (v6.3.4#6332)