Scott Murphy Heiberg created GROOVY-12564:
---------------------------------------------

             Summary: STC: calling a closure of intersection type is typed as 
"?", giving NoClassDefFoundError: ?
                 Key: GROOVY-12564
                 URL: https://issues.apache.org/jira/browse/GROOVY-12564
             Project: Groovy
          Issue Type: Bug
          Components: Static Type Checker
    Affects Versions: 5.0.8, 4.0.33, 6.0.0
            Reporter: Scott Murphy Heiberg


A closure whose return type is an intersection, such as the value of {{flag ? 1 
: 'x'}}, is typed {{Closure<? extends A & B>}}. A call of such a closure 
through a variable is typed as the wildcard's placeholder class, named "?". A 
closure returning that call gets a {{doCall}} declared to return class "?":

{code:groovy}
@groovy.transform.CompileStatic
Object make(boolean flag) { def outer = { def inner = { flag ? 1 : 'x' }; 
inner() }; outer() }
make(true) // NoClassDefFoundError: ?
{code}

The same under {{@TypeChecked}}, in traits, and in static methods and field 
initializers.

Expected: the call is typed as the wildcard's upper bound (the closure's return 
type).



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to