Conflicting inspections on passing primitive arrays to Object vararg methods

Answered

Problem description:

If I pass a primitive array to a method that accepts `Object…`, IntelliJ IDEA will suggest casting the argument to `Object`. However, if I do that, the IDE will highlight the cast as redundant. I simply can't make the IDE happy.

Steps to reproduce:

```java

import org.junit.jupiter.api.Test;

public class GenericTest {

   @Test
   public void varargTest() {
      int[] ints = new int[]{1, 2, 3};
      doSomething(ints); // inspection shown with and without cast to Object
   }
   
   void doSomething(Object... args) {}
}
```

Environment:

Windows 10

0
3 comments

Hi Nad,
I reproduced the problem and filed it as https://youtrack.jetbrains.com/issue/IDEA-370702  
Please follow the progress in the ticket.

0

Do I have permission to view the issue? It doesn't seem so

0

Sorry, the link was broken for some reason.  I fixed it, please check again.

0

Please sign in to leave a comment.