object unsound { trait LowerBound[T] { type M >: T; } trait UpperBound[U] { type M <: U; } def coerce[T,U](t : T) : U = { def upcast(ub : LowerBound[T], t : T) : ub.M = t val bounded : LowerBound[T] with UpperBound[U] = null return upcast(bounded, t) } def main(args : Array[String]) : Unit = { val zero : String = coerce[Integer,String](0) } }