Dotty Documentation


class TyperState
extends Object

[-] Constructors

TyperState ( previous: TyperState )

[-] Members

[+] val id : Int
[+] private var isCommitted : Boolean
[+] private var isShared : Boolean
[+] private var myConstraint : Constraint
[+] private var myIsCommittable : Boolean
[+] private var myOwnedVars : TypeVars

The set of uninstantiated type variables which have this state as their owning state

[+] private var myReporter : Reporter
[+] private val previousConstraint : Constraint
[+] private var testReporter : TestReporter
[+] def commit ( ) ( implicit ctx: Context ) : Unit

Commit typer state so that its information is copied into current typer state In addition (1) the owning state of undetermined or temporarily instantiated type variables changes from this typer state to the current one. (2) Variables that were temporarily instantiated in the current typer state are permanently instantiated instead.

A note on merging: An interesting test case is isApplicableSafe.scala. It turns out that this requires a context merge using the new `&' operator. Sequence of actions: 1) Typecheck argument in typerstate 1. 2) Cache argument. 3) Evolve same typer state (to typecheck other arguments, say) leading to a different constraint. 4) Take typechecked argument in same state.

It turns out that the merge is needed not just for isApplicableSafe but also for (e.g. erased-lubs.scala) as well as many parts of dotty itself.

[+] def constraint : Constraint
[+] def constraint_= ( c: Constraint ) ( implicit ctx: Context ) : Unit
[+] def fresh ( ) : TyperState

A fresh typer state with the same constraint as this one.

[+] def gc ( ) ( implicit ctx: Context ) : Unit

Make type variable instances permanent by assigning to inst field if type variable instantiation cannot be retracted anymore. Then, remove no-longer needed constraint entries.

[+] def isCommittable : Boolean
[+] def isGlobalCommittable : Boolean
[+] def markShared ( ) : Unit

Mark typer state as shared (typically because it is the typer state of the creation context of a source definition that potentially still needs to be completed). Members of shared typer states are never overwritten in test.

[+] def ownedVars : TypeVars
[+] def ownedVars_= ( vs: TypeVars ) : Unit
[+] def reporter : Reporter
[+] def resetConstraintTo ( c: Constraint ) : Unit

Reset constraint to c and mark current constraint as retracted if it differs from c

[+] def setCommittable ( committable: Boolean ) : TyperState
[+] def setReporter ( reporter: Reporter ) : TyperState

A fresh type state with the same constraint as this one and the given reporter

[+] def stateChainStr : String
[+] def test ( op: Context => T ) ( implicit ctx: Context ) : T

Test using op. If current typerstate is shared, run op in a fresh exploration typerstate. If it is unshared, run op in current typerState, restoring typerState to previous state afterwards.

[+] override def toString : String
[+] def uncommittedAncestor : TyperState

The closest ancestor of this typer state (including possibly this typer state itself) which is not yet committed, or which does not have a parent.

[+] def uninstVars : Seq [ TypeVar ]

The uninstantiated variables