在 Scala 3 中,有没有办法在一个区域中禁用 -language:strictEquality(多元平等)?

In Scala 3, is there a way to disable -language:strictEquality (multiversal equality) in a region?

想要这样做的特殊原因是仍然能够对来自超级class 的值使用模式匹配。例如,我希望在查看 Option[Throwable] 类型的值时能够与 case None 匹配,但这似乎不可能,因为 Throwable 不会,而且永远不会将(我想)有一个 CanEqual 实例。

尝试像这样限制给定的范围

  val x: Option[Throwable] = None
  {
    given CanEqual[Option[Throwable], Option[Throwable]] = CanEqual.derived
    x match {
      case Some(v) => v
      case None => new Throwable()
    }
  } // after this brace CanEqual given is out-of-scope

  x match {
    case Some(v) => v
    case None => new Throwable()
  } // compile-time error: Values of types object None and Option[Throwable] cannot be compared with == or !=