Pre-SIP: deprecate asInstanceOf, introduce unsafeAsInstanceOf

There is little effective documentation for asInstanceOf.

  1. Most people won’t look at the spec (which is wrong anyways).
  2. My version of IntelliJ, which is up to date and working otherwise, does not provide any documentation for asInstanceOf, and I can imagine that many other Scala developers don’t have immediate access to it, and might not even be aware that it exists, given how hard it is to find online.
  3. Googling ‘scala asinstanceof’ does not return any official documentation in the top results.

I can imagine that a dedicated documentation page, with several examples and pitfalls, could be quite helpful to many people.

4 Likes