Dotty Documentation

0.5.0-bin-SNAPSHOT

class SpaceEngine
extends Object with SpaceLogic

Scala implementation of space logic

[-] Constructors

SpaceEngine ( )
SpaceEngine ( implicit ctx: Context )

[-] Members

[+] private implicit val ctx : Context
[+] private val scalaConsType : TypeRef
[+] private val scalaListType : TypeRef
[+] private val scalaNilType : TermRef
[+] private val scalaSeqFactoryClass : ClassSymbol
[+] private val scalaSomeClass : ClassSymbol
[+] def canDecompose ( tp: Type ) : Boolean

Abstract sealed types, or-types, Boolean and Java enums can be decomposed

[+] def checkExhaustivity ( _match: Match ) : Unit
[+] def checkRedundancy ( _match: Match ) : Unit
[+] def checkable ( tree: Match ) : Boolean
[+] def decompose ( tp: Type ) : List [ Space ]

Decompose a type into subspaces -- assume the type can be decomposed

[+] def erase ( tp: Type ) ( implicit warn: String => Unit ) : Type
[+] def expose ( tp: Type , refineCtx: Boolean , up: Boolean ) : Type

Eliminate reference to type parameters in refinements

A <: X :> Y B <: U :> V M { type T <: A :> B } ~~> M { type T <: X :> V }

[+] private def implementability ( tp: Type ) : Implementability

Checks if it's possible to create a trait/class which is a subtype of tp.

  • doesn't handle member collisions (will not declare a type unimplementable because of one)
  • expects that neither Any nor Object reach it (this is currently true due to both isSubType and and/or type simplification)

See [[intersectUnrelatedAtomicTypes]].

[+] def instantiate ( tp1: Type , tp2: Type ) ( implicit ctx: Context ) : Type

Instantiate type tp1 to be a subtype of tp2

Return the instantiated type if type parameters and this type in tp1 can be instantiated such that tp1 <:< tp2.

Otherwise, return NoType.

[+] override def intersectUnrelatedAtomicTypes ( tp1: Type , tp2: Type ) : Space

Return a space containing the values of both types.

The types should be atomic (non-decomposable) and unrelated (neither should be a subtype of the other).

[+] def irrefutable ( unapp: Tree ) : Boolean
[+] def isEqualType ( tp1: Type , tp2: Type ) : Boolean

Is tp1 the same type as tp2?

[+] def isSubType ( tp1: Type , tp2: Type ) : Boolean

Is tp1 a subtype of tp2?

[+] def project ( pat: Tree ) : Space

Return the space that represents the pattern pat

[+] def projectSeq ( pats: List [ Tree ] ) : Space

Space of the pattern: unapplySeq(a, b, c: _*)

[+] def refine ( parent: Type , child: Symbol ) : Type

Refine child based on parent

In child class definition, we have:

class Child[Ts] extends path.Parent[Us] with Es
object Child extends path.Parent[Us] with Es
val child = new path.Parent[Us] with Es           // enum values

Given a parent type parent and a child symbol child, we infer the prefix and type parameters for the child:

prefix.child[Vs] <:< parent

where Vs are fresh type variables and prefix is the symbol prefix with all non-module and non-package ThisType replaced by fresh type variables.

If the subtyping is true, the instantiated type p.child[Vs] is returned. Otherwise, NoType is returned.

[+] def show ( s: Space ) : String

Display spaces

[+] def showType ( tp: Type ) : String

Show friendly type name with current scope in mind

E.g. C.this.B --> B if current owner is C C.this.x.T --> x.T if current owner is C X[T] --> X C --> C if current owner is C !!!

[+] def signature ( unapp: Type , unappSym: Symbol , argLen: Int ) : List [ Type ]

Parameter types of the case class type tp. Adapted from unapplyPlan in patternMatcher