Bug in InputEvent.getDevice() method return type

There is a bug in the Kotlin’s signature of

getDevice() method in android.view.InputEvent package.

According to this reference page it is
fun getDevice(): InputDevice!
and thus should always return a non-nullable InputDevice instance.

However the Return section reads
InputDevice!: The device, or null if unknown.
which is a contradiction.

The method signature should be changed to
fun getDevice(): InputDevice?

I don’t know how to make this method to return null but I have an app and many java.lang.IllegalStateException: device must not be null crash reports proving that my users were able to do that.

Can you check the platform type documentation, please?

I am not sure I understand your question.
If by platform you mean Java then according to this reference manual page the return type is InputDevice which is a reference type and thus nullable in Java.
And also here the documentation explicitly states that the method can return a null reference. (Returns: The device, or null if unknown.)

It was not a question, but an offer. You are using wrong syntax for non-nullable types. I can add that you probably should run a few koans to familiarize yourself with the language.

For clarity, by documentation of platform types, you can refer to this page: https://kotlinlang.org/docs/reference/java-interop.html#null-safety-and-platform-types

In particular, T! doesn’t mean that it is non-nullable, but it can be either nullable or non-nullable, because it’s a value coming from Java world and the compiler cannot infer the nullability.