[
https://issues.apache.org/jira/browse/GROOVY-10682?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17611739#comment-17611739
]
ASF GitHub Bot commented on GROOVY-10682:
-----------------------------------------
sonatype-lift[bot] commented on code in PR #1785:
URL: https://github.com/apache/groovy/pull/1785#discussion_r984914687
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -3178,116 +3179,44 @@ public static <T> Number count(T[] self,
@ClosureParams(FirstParam.Component.cla
return count(Arrays.asList(self), closure);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(int[] self, Object value) {
- return count(InvokerHelper.asIterator(self), value);
+ return ArrayGroovyMethods.count(self, value);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(long[] self, Object value) {
- return count(InvokerHelper.asIterator(self), value);
+ return ArrayGroovyMethods.count(self, value);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(short[] self, Object value) {
- return count(InvokerHelper.asIterator(self), value);
+ return ArrayGroovyMethods.count(self, value);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(char[] self, Object value) {
- return count(InvokerHelper.asIterator(self), value);
+ return ArrayGroovyMethods.count(self, value);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(boolean[] self, Object value) {
- return count(InvokerHelper.asIterator(self), value);
+ return ArrayGroovyMethods.count(self, value);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(double[] self, Object value) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):*
This deprecated API looks inlineable. If you'd like the body of the API to be
inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.count(self, value)", imports
= "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>ℹ️ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with
***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| -----------
> 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)