You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def remove[S](a: S | Int, f: Int => S):S = a match {
case a: S => a
case a: Int => f(a)
}
val t: Int | String = 5
val t1 = remove[String](t, _.toString)
This compiles fine, but at runtime, the call to remove will throw a java.lang.ClassCastException (Integer cannot be cast to String)