Union type subtyping in Scala -
i can following dotty:
trait ex {type t <: int | seq[int]; def f:t} trait ex2 extends ex {override type t = seq[int]; override def f = seq(2)} trait ex3 extends ex {override type t = int; override def f = 2}
how can union type subtyping without dotty?
the simple solution upper bound type:
trait ex {type t >: int seq[int]; def f:t} trait ex2 extends ex {override type t = seq[int]; override def f = seq(2)} trait ex3 extends ex {override type t = int; override def f = 2}
Comments
Post a Comment