You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Thodoris Sotiropoulos (Jira)" <ji...@apache.org> on 2021/09/10 12:19:00 UTC

[jira] [Created] (GROOVY-10221) Unexpected compile-time error when combining closures and bounded type parameters

Thodoris Sotiropoulos created GROOVY-10221:
----------------------------------------------

             Summary: Unexpected compile-time error when combining closures and bounded type parameters
                 Key: GROOVY-10221
                 URL: https://issues.apache.org/jira/browse/GROOVY-10221
             Project: Groovy
          Issue Type: Bug
          Components: Static Type Checker
            Reporter: Thodoris Sotiropoulos


Program

 
{code:java}
class A<T1, T2 extends T1> {
  void foo() {
    def cls1 = { T2 x -> "" }
    Closure<T2> cls2 = { T2 x -> x }
    cls1(cls2((T2) null))
  }
}
{code}
h3. Actual Behavior
{code:java}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
test.groovy: 5: [Static type checking] - Cannot call closure that accepts [T2] with [T1]
 @ line 5, column 9.
       cls1(cls2((T2) null))
           ^1 error

{code}
h3. Expected Behavior

Compile successfully

 



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