Thodoris Sotiropoulos created GROOVY-10082:
----------------------------------------------

             Summary: 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


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 to: groovy.lang.Closure
 @ line 7, column 22.
       Closure cls = { -> {
                        ^

1 error
{code}
h3. Expected Behaviour

Compile successfully

 

This bug is probably a regression. Tested against master 
(https://github.com/apache/groovy/commit/8830e47c3dbd5914e52330d4263c34bcfd05752d)

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to