# This trick enables overloading \`==\` for opaque types

**URL:** <https://contributors.scala-lang.org/t/this-trick-enables-overloading-for-opaque-types/6560>\
**Category:** Language Design\
**Created:** [February 19, 2024, 9:57pm UTC](https://contributors.scala-lang.org/t/this-trick-enables-overloading-for-opaque-types/6560 "2024-02-19T21:57:03Z")\
**Posts on this page:** 1\
**Showing post:** 17

<div class="post-metadata">

**Author:** ![sjrd](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/sjrd/32/24_2.png) [@sjrd](https://contributors.scala-lang.org/u/sjrd)\
**Post date:** [February 20, 2024, 4:29pm UTC](https://contributors.scala-lang.org/t/this-trick-enables-overloading-for-opaque-types/6560/17 "2024-02-20T16:29:38Z")

</div>

The spec of `asInstanceOf`, as written there, has been wrong for more than a decade. I haven’t gotten around to update it yet. There are much simpler cases that show how broken it is, like

```auto
val x: List[Int] = 1 :: Nil
val y: List[String] = x.asInstanceOf[List[Int]] // "succeeds", against the spec

```

---

_[View the full topic](https://contributors.scala-lang.org/t/this-trick-enables-overloading-for-opaque-types/6560)._
