Cannot suppress unchecked cast to external interface

I can’t remove an unchecked cast warning when casting to an external interface even though I try to suppress it.

@Suppress(“UNCHECKED_CAST”)
val response = error.asDynamic().response as AxiosResponse<*>

Compile warning: “Unchecked cast to external interface: dynamic to AxiosResponse<*>”

Checking with “is” doesn’t work either.

if (error.asDynamic().response is AxiosResponse<*>)

Compile error: “Cannot check for external interface: AxiosResponse<*>”

This is a different diagnostic UNCHECKED_CAST_TO_EXTERNAL_INTERFACE. How are you suppressing it? It should work automatically in Intellij IDEA from the popup menu → Right arrow → Suppress for statement.

I was using @Suppress(“UNCHECKED_CAST”) because that’s what any documentation said to use (couldn’t find anything about external interfaces).
For some reason my IntelliJ does not pop up with an inspection when I right click the warning.

        @Suppress("UNCHECKED_CAST_TO_EXTERNAL_INTERFACE")
        val response: AxiosResponse<String> = error.asDynamic().response

The above did not work (tried AxiosResponse< String > and AxiosResponse<*>)

        @Suppress("UNCHECKED_CAST_TO_EXTERNAL_INTERFACE")
        val response = error.asDynamic().response as AxiosResponse<String>

However, the above did work.

Thanks.

Currently it doesn’t work with right click. Try this: position your cursor somewhere on the warning text and press Alt+Enter to get the inspections popup.

As of IDEA 2019.2 EAP you can indeed right-click on the warning and then click on the first item “Show context actions” to get the inspections popup.

Also, I agree that the different warning is a little confusing. Maybe it’s worth to document, I created an issue here: https://youtrack.jetbrains.com/issue/KT-31845