From dc8ccbf5ecb9fb5c2fc965d66952413cd0995acb Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Wed, 21 Feb 2024 17:11:34 +0100 Subject: [PATCH] remove implementation from asInstanceOf it only adds to the confusion about asInstanceOf introducing type checks. See https://contributors.scala-lang.org/t/this-trick-enables-overloading-for-opaque-types/6560/17 and https://contributors.scala-lang.org/t/pre-sip-deprecate-asinstanceof-introduce-unsafeasinstanceof/6568 [Cherry-picked 5212897ed9938ee0908c4bdb3048d5f93797233a] --- docs/_spec/12-the-scala-standard-library.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/docs/_spec/12-the-scala-standard-library.md b/docs/_spec/12-the-scala-standard-library.md index df8626b5119c..40c136085528 100644 --- a/docs/_spec/12-the-scala-standard-library.md +++ b/docs/_spec/12-the-scala-standard-library.md @@ -68,11 +68,7 @@ abstract class Any { def isInstanceOf[a]: Boolean /** Type cast; needs to be inlined to work as given */ */ - def asInstanceOf[A]: A = this match { - case x: A => x - case _ => if (this eq null) this - else throw new ClassCastException() - } + def asInstanceOf[A]: A } /** The root class of all value types */