[ 
https://issues.apache.org/jira/browse/GROOVY-10682?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17611743#comment-17611743
 ] 

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_r984915270


##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -11693,108 +11299,44 @@ public static boolean asBoolean(Object[] array) {
         return array != null && array.length > 0;
     }
 
-    /**
-     * Coerces a byte array to a boolean value.
-     * A byte array is false if the array is of length 0,
-     * and true otherwise.
-     *
-     * @param array an array
-     * @return the array's boolean value
-     * @since 1.7.4
-     */
+    @Deprecated
     public static boolean asBoolean(byte[] array) {
-        return array != null && array.length > 0;
+        return ArrayGroovyMethods.asBoolean(array);
     }
 
-    /**
-     * Coerces a short array to a boolean value.
-     * A short array is false if the array is of length 0,
-     * and true otherwise.
-     *
-     * @param array an array
-     * @return the array's boolean value
-     * @since 1.7.4
-     */
+    @Deprecated
     public static boolean asBoolean(short[] array) {
-        return array != null && array.length > 0;
+        return ArrayGroovyMethods.asBoolean(array);
     }
 
-    /**
-     * Coerces an int array to a boolean value.
-     * An int array is false if the array is of length 0,
-     * and true otherwise.
-     *
-     * @param array an array
-     * @return the array's boolean value
-     * @since 1.7.4
-     */
+    @Deprecated
     public static boolean asBoolean(int[] array) {
-        return array != null && array.length > 0;
+        return ArrayGroovyMethods.asBoolean(array);
     }
 
-    /**
-     * Coerces a long array to a boolean value.
-     * A long array is false if the array is of length 0,
-     * and true otherwise.
-     *
-     * @param array an array
-     * @return the array's boolean value
-     * @since 1.7.4
-     */
+    @Deprecated
     public static boolean asBoolean(long[] array) {
-        return array != null && array.length > 0;
+        return ArrayGroovyMethods.asBoolean(array);
     }
 
-    /**
-     * Coerces a float array to a boolean value.
-     * A float array is false if the array is of length 0,
-     * and true otherwise.
-     *
-     * @param array an array
-     * @return the array's boolean value
-     * @since 1.7.4
-     */
+    @Deprecated
     public static boolean asBoolean(float[] array) {
-        return array != null && array.length > 0;
+        return ArrayGroovyMethods.asBoolean(array);
     }
 
-    /**
-     * Coerces a double array to a boolean value.
-     * A double array is false if the array is of length 0,
-     * and true otherwise.
-     *
-     * @param array an array
-     * @return the array's boolean value
-     * @since 1.7.4
-     */
+    @Deprecated
     public static boolean asBoolean(double[] array) {

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.asBoolean(array)", 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)

Reply via email to