Skip to content

Commit 1499bdd

Browse files
robstollWojciechMazur
authored andcommitted
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 5212897]
1 parent ed7a0ea commit 1499bdd

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

Diff for: docs/_spec/12-the-scala-standard-library.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,7 @@ abstract class Any {
6868
def isInstanceOf[a]: Boolean
6969

7070
/** Type cast; needs to be inlined to work as given */ */
71-
def asInstanceOf[A]: A = this match {
72-
case x: A => x
73-
case _ => if (this eq null) this
74-
else throw new ClassCastException()
75-
}
71+
def asInstanceOf[A]: A
7672
}
7773

7874
/** The root class of all value types */

0 commit comments

Comments
 (0)