codeconsole opened a new pull request, #3093:
URL: https://github.com/apache/groovy/pull/3093

   A closure whose return type is an intersection, such as the value of `flag ? 
1 : 'x'`, `this` in a `@SelfType` trait, or a variable narrowed by two 
instanceof checks, is typed `Closure<? extends A & B>`. Calling it through a 
variable, `inner()` or `inner.call()`, was typed as the wildcard's own 
placeholder, named "?". A closure returning that call then got a `doCall` 
declared to return the class "?":
   
   ```groovy
   @CompileStatic
   Object make(boolean flag) { def outer = { def inner = { flag ? 1 : 'x' }; 
inner() }; outer() }
   make(true) // NoClassDefFoundError: ?
   ```
   
   The same held under `@TypeChecked`, in classes and traits, in instance and 
static methods and in field initializers. The type checker now types such a 
call as the wildcard's upper bound, or the intersection of its bounds, which is 
the closure's return type.
   
   ## Tests
   
   `ClosuresSTCTest.testCallOfClosureReturningIntersectionType`, also run 
statically compiled, fails without the change. 11,626 tests in the `groovy`, 
`gls`, `bugs` and STC/SC packages pass, apart from 
`testSelfReferentialTypeParameter5`, the `@Grab` race of GROOVY-12527, which 
fails the same way on master. The Checkstyle and CodeNarc gates pass.
   
   Seen in 4.0.33, 5.0.8 and 6.0.0.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to