How to avoid calling asInstanceOf in Scala
问题 Here is a simplified version of my code. How can I avoid to call asInstanceOf (because it is a smell for a poorly design solution) ? sealed trait Location final case class Single(bucket: String) extends Location final case class Multi(buckets: Seq[String]) extends Location @SuppressWarnings(Array("org.wartremover.warts.AsInstanceOf")) class Log[L <: Location](location: L, path: String) { // I prefer composition over inheritance // I don't want to pass location to this method because it's a