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 -

c++ - Migration from QScriptEngine to QJSEngine -

delphi - Take screenshot in webcam using VFrames in Console Application -