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

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -