联合类型 LUB 和超类型 LUB 的区别

Mar*_*lic 7 scala dotty subtyping

形状列表推断,List[Shape]但盒装形状列表推断List[Box[Square | Circle]]

scala> sealed trait Shape
     | case class Square() extends Shape
     | case class Circle() extends Shape
     | case class Box[+T <: Shape](t: T)
     | List(Square(), Circle())
     | List(Box(Square()), Box(Circle()))
val res0: List[Shape & Product & Serializable] = List(Square(), Circle())
val res1: List[Box[Square | Circle]] = List(Box(Square()), Box(Circle()))
Run Code Online (Sandbox Code Playgroud)

为什么res0不与List[Square | Circle]对称输入List[Box[Square | Circle]],反之亦然?

Dotty根据联合类型定义最小上限

一组类型的最小上限 (lub) 是这些类型的并集。这取代了Scala 2 规范中最小上限定义。

与此更改相关的统一规则是什么?