Shadow-Devil opened a new pull request, #1785:
URL: https://github.com/apache/groovy/pull/1785

   Consider the following:
   ```
   @groovy.transform.TypeChecked
   void test(int[] ints) {
     ints.eachWithIndex { value, index ->
       println "$index: ${value.doubleValue()}"
     }
   }
   test(0,1,2,3,4,5)
   Compiler reports "[Static type checking] - Cannot find matching method 
java.lang.Object#doubleValue()"
   ```
   `eachWithIndex` is only provided for reference types, so "value" is seen as 
Object by the type checker.
   
   Currently, only a draft for int arrays. Should probably also be implemented 
for other primitive types.
   There are three different approaches to do this:
   1. Copy-paste the implementation for each overload
   2. Delegate to `eachWithIndex(Iterable<T> self, Closure closure)` 
   3. Delegate to `eachWithIndex(Iterator<T> self, Closure closure)` 
   
   I found option three most appealing since option 1 adds unnecessary code 
duplication and option 2 just calls option 3 with the iterator of `self` which 
would add unnecessary overhead.
   
   https://issues.apache.org/jira/browse/GROOVY-10682


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