asInstanceOf
in generic code simply promises the compiler that you know that one thing is actually something else. Whenever you get out of generic code and rely upon this behavior, false promises will blow up in your face.
This is how the JVM works: you need a specific class to test instanceof
.