aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/core/TyperState.scala24
1 files changed, 7 insertions, 17 deletions
diff --git a/src/dotty/tools/dotc/core/TyperState.scala b/src/dotty/tools/dotc/core/TyperState.scala
index a7ad6824f..7b8867ccc 100644
--- a/src/dotty/tools/dotc/core/TyperState.scala
+++ b/src/dotty/tools/dotc/core/TyperState.scala
@@ -59,18 +59,10 @@ class TyperState(r: Reporter) extends DotClass with Showable {
/** Commit state so that it gets propagated to enclosing context */
def commit()(implicit ctx: Context): Unit = unsupported("commit")
- /** The typer state has already been committed */
- def isCommitted: Boolean = false
-
- /** Optionally, if this is a mutable typerstate, it's creator state */
- def parent: Option[TyperState] = None
-
/** 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 uncommittedAncestor: TyperState =
- if (!isCommitted || !parent.isDefined) this
- else parent.get.uncommittedAncestor
+ def uncommittedAncestor: TyperState = this
/** Make type variable instances permanent by assigning to `inst` field if
* type variable instantiation cannot be retracted anymore. Then, remove
@@ -110,7 +102,6 @@ extends TyperState(r) {
override def ephemeral = myEphemeral
override def ephemeral_=(x: Boolean): Unit = { myEphemeral = x }
-
override def fresh(isCommittable: Boolean): TyperState =
new MutableTyperState(this, new StoreReporter(reporter), isCommittable)
@@ -121,6 +112,11 @@ extends TyperState(r) {
isCommittable &&
(!previous.isInstanceOf[MutableTyperState] || previous.isGlobalCommittable)
+ private var isCommitted = false
+
+ override def uncommittedAncestor: TyperState =
+ if (isCommitted) previous.uncommittedAncestor else this
+
/** 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
@@ -140,15 +136,9 @@ extends TyperState(r) {
targetState.ephemeral |= ephemeral
targetState.gc()
reporter.flush()
- myIsCommitted = true
+ isCommitted = true
}
- private var myIsCommitted = false
-
- override def isCommitted: Boolean = myIsCommitted
-
- override def parent = Some(previous)
-
override def gc()(implicit ctx: Context): Unit = {
val toCollect = new mutable.ListBuffer[GenericType]
constraint foreachTypeVar { tvar =>