Skip to content

Commit 2dfe4db

Browse files
committed
TyperState refactoring.
Need to export just uncommittedAncestor, can hide isCommitted and parent.
1 parent a438d3e commit 2dfe4db

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

src/dotty/tools/dotc/core/TyperState.scala

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,10 @@ class TyperState(r: Reporter) extends DotClass with Showable {
5959
/** Commit state so that it gets propagated to enclosing context */
6060
def commit()(implicit ctx: Context): Unit = unsupported("commit")
6161

62-
/** The typer state has already been committed */
63-
def isCommitted: Boolean = false
64-
65-
/** Optionally, if this is a mutable typerstate, it's creator state */
66-
def parent: Option[TyperState] = None
67-
6862
/** The closest ancestor of this typer state (including possibly this typer state itself)
6963
* which is not yet committed, or which does not have a parent.
7064
*/
71-
def uncommittedAncestor: TyperState =
72-
if (!isCommitted || !parent.isDefined) this
73-
else parent.get.uncommittedAncestor
65+
def uncommittedAncestor: TyperState = this
7466

7567
/** Make type variable instances permanent by assigning to `inst` field if
7668
* type variable instantiation cannot be retracted anymore. Then, remove
@@ -110,7 +102,6 @@ extends TyperState(r) {
110102
override def ephemeral = myEphemeral
111103
override def ephemeral_=(x: Boolean): Unit = { myEphemeral = x }
112104

113-
114105
override def fresh(isCommittable: Boolean): TyperState =
115106
new MutableTyperState(this, new StoreReporter(reporter), isCommittable)
116107

@@ -121,6 +112,11 @@ extends TyperState(r) {
121112
isCommittable &&
122113
(!previous.isInstanceOf[MutableTyperState] || previous.isGlobalCommittable)
123114

115+
private var isCommitted = false
116+
117+
override def uncommittedAncestor: TyperState =
118+
if (isCommitted) previous.uncommittedAncestor else this
119+
124120
/** Commit typer state so that its information is copied into current typer state
125121
* In addition (1) the owning state of undetermined or temporarily instantiated
126122
* type variables changes from this typer state to the current one. (2) Variables
@@ -140,15 +136,9 @@ extends TyperState(r) {
140136
targetState.ephemeral |= ephemeral
141137
targetState.gc()
142138
reporter.flush()
143-
myIsCommitted = true
139+
isCommitted = true
144140
}
145141

146-
private var myIsCommitted = false
147-
148-
override def isCommitted: Boolean = myIsCommitted
149-
150-
override def parent = Some(previous)
151-
152142
override def gc()(implicit ctx: Context): Unit = {
153143
val toCollect = new mutable.ListBuffer[GenericType]
154144
constraint foreachTypeVar { tvar =>

0 commit comments

Comments
 (0)