[
https://issues.apache.org/jira/browse/GROOVY-10682?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17609059#comment-17609059
]
ASF GitHub Bot commented on GROOVY-10682:
-----------------------------------------
Shadow-Devil commented on code in PR #1785:
URL: https://github.com/apache/groovy/pull/1785#discussion_r979319778
##########
src/spec/test/typing/TypeCheckingTest.groovy:
##########
@@ -44,6 +44,23 @@ class TypeCheckingTest extends StaticTypeCheckingTestCase {
'''
}
+ void testTypeCheckedEachWithIndex(){
+ //TODO: tags?
Review Comment:
Thank you very much for your help. I think I will add a simple test case
here
https://github.com/apache/groovy/blob/master/src/spec/test/gdk/WorkingWithArraysTest.groovy
that also works without my extension
and one with stc into here
https://github.com/apache/groovy/blob/master/src/test/groovy/transform/stc/DefaultGroovyMethodsSTCTest.groovy#L28-L40
that only works if we add the extension. Otherwise, I think it would be quite
weird for the reader of the doco to see a method annotated with
`@groovy.transform.TypeChecked`.
One small note: I thought the doco file should be about arrays, but in the
second paragraph you are talking about "Iterating on a list". Is this a maybe
typo?
> Provide eachWithIndex for primitive arrays
> ------------------------------------------
>
> Key: GROOVY-10682
> URL: https://issues.apache.org/jira/browse/GROOVY-10682
> Project: Groovy
> Issue Type: Improvement
> Components: groovy-jdk
> Reporter: Eric Milles
> Assignee: Eric Milles
> Priority: Minor
>
> Consider the following:
> {code:groovy}
> @groovy.transform.TypeChecked
> void test(int[] ints) {
> ints.eachWithIndex { value, index ->
> println "$index: ${value.doubleValue()}"
> }
> }
> test(0,1,2,3,4,5)
> {code}
> 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.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)