[ https://issues.apache.org/jira/browse/GROOVY-10082?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles resolved GROOVY-10082. ---------------------------------- Fix Version/s: 4.0.0-beta-1 Resolution: Fixed I allowed for simple covariance ({{A}} vs {{B}} in your example or {{CharSequence}} vs {{String}} for example). If the return type contains generics it will be kept as is. So {{Collection<String>}} vs {{List<String>}} may produce an error so I don't have to also check for {{Collection<String>}} vs {{List<Integer>}} just yet. > Incompatible generic argument types when combining subtyping and closures > ------------------------------------------------------------------------- > > Key: GROOVY-10082 > URL: https://issues.apache.org/jira/browse/GROOVY-10082 > Project: Groovy > Issue Type: Bug > Components: Static Type Checker > Reporter: Thodoris Sotiropoulos > Assignee: Eric Milles > Priority: Major > Fix For: 4.0.0-beta-1 > > > I have the following program > > {code:java} > class A {} > class B extends A {} > class Main { > public static void main(String[] args) { > Closure<A> cls = { -> { > final A x = new B() > x > }} > } > } > {code} > > h3. Actual Behaviour > {code:java} > org.codehaus.groovy.control.MultipleCompilationErrorsException: startup > failed: > test.groovy: 7: [Static type checking] - Incompatible generic argument types. > Cannot assign groovy.lang.Closure<B> to: groovy.lang.Closure<A> > @ line 7, column 22. > Closure cls = { -> { > ^ > 1 error > {code} > h3. Expected Behaviour > Compile successfully > > I don't know if this behaviour is intended due to flow typing. > Tested against master > ([https://github.com/apache/groovy/commit/8830e47c3dbd5914e52330d4263c34bcfd05752d]) > -- This message was sent by Atlassian Jira (v8.3.4#803005)