Sub

object Sub

Our subtyping can be described by a following diagram:

  value kind        ref kind         special kind
  |     \           |    \
  |     |           |      \
  prim  aggr        class  trait
  |     |           |      /
  |     |           |    /
  |     |           null
  |     |           /
  |     |       /
  |     |   /
  nothing

Primitive and aggregate types don't participate in subtyping and they have to be explicitly boxed to become compatible with a reference type.

Reference types form a simple lattice with java.lang.Object at the top and null type at the bottom. Subtyping between traits and classes is based on linearization of the all transitive parents, similarly to scalac.

Nothing is the common bottom type between reference and value types. It represents computations that may never complete normally (either loops forever or throws an exception).

class Object
trait Matchable
class Any
Sub.type

Value members

Concrete methods

def is(l: Type, r: Type)(implicit analysis: Result): Boolean
def is(info: ScopeInfo, ty: RefKind)(implicit analysis: Result): Boolean
def lub(tys: Seq[Type], bound: Option[Type])(implicit analysis: Result): Type
def lub(lty: Type, rty: Type, bound: Option[Type])(implicit analysis: Result): Type
def lub(linfo: ScopeInfo, rinfo: ScopeInfo, boundInfo: Option[ScopeInfo])(implicit analysis: Result): ScopeInfo