File tree Expand file tree Collapse file tree 2 files changed +10
-9
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -526,9 +526,11 @@ object Contexts {
526526 final def withOwner (owner : Symbol ): Context =
527527 if (owner ne this .owner) fresh.setOwner(owner) else this
528528
529+ final def withTyperState (typerState : TyperState ): Context =
530+ if typerState ne this .typerState then fresh.setTyperState(typerState) else this
531+
529532 final def withUncommittedTyperState : Context =
530- val ts = typerState.uncommittedAncestor
531- if ts ne typerState then fresh.setTyperState(ts) else this
533+ withTyperState(typerState.uncommittedAncestor)
532534
533535 final def withProperty [T ](key : Key [T ], value : Option [T ]): Context =
534536 if (property(key) == value) this
@@ -599,8 +601,8 @@ object Contexts {
599601 this .scope = newScope
600602 this
601603 def setTyperState (typerState : TyperState ): this .type = { this .typerState = typerState; this }
602- def setNewTyperState (): this .type = setTyperState(typerState.fresh().setCommittable( true ))
603- def setExploreTyperState (): this .type = setTyperState(typerState.fresh().setCommittable( false ))
604+ def setNewTyperState (): this .type = setTyperState(typerState.fresh(committable = true ))
605+ def setExploreTyperState (): this .type = setTyperState(typerState.fresh(committable = false ))
604606 def setReporter (reporter : Reporter ): this .type = setTyperState(typerState.fresh().setReporter(reporter))
605607 def setTyper (typer : Typer ): this .type = { this .scope = typer.scope; setTypeAssigner(typer) }
606608 def setGadt (gadt : GadtConstraint ): this .type =
Original file line number Diff line number Diff line change @@ -103,11 +103,12 @@ class TyperState() {
103103 this
104104
105105 /** A fresh typer state with the same constraint as this one. */
106- def fresh (reporter : Reporter = StoreReporter (this .reporter)): TyperState =
106+ def fresh (reporter : Reporter = StoreReporter (this .reporter),
107+ committable : Boolean = this .isCommittable): TyperState =
107108 util.Stats .record(" TyperState.fresh" )
108109 TyperState ().init(this , this .constraint)
109110 .setReporter(reporter)
110- .setCommittable(this .isCommittable )
111+ .setCommittable(committable )
111112
112113 /** The uninstantiated variables */
113114 def uninstVars : collection.Seq [TypeVar ] = constraint.uninstVars
@@ -189,9 +190,7 @@ class TyperState() {
189190 def mergeConstraintWith (that : TyperState )(using Context ): Unit =
190191 that.ensureNotConflicting(constraint)
191192
192- val comparingCtx =
193- if ctx.typerState == this then ctx
194- else ctx.fresh.setTyperState(this )
193+ val comparingCtx = ctx.withTyperState(this )
195194
196195 comparing(typeComparer =>
197196 val other = that.constraint
You can’t perform that action at this time.
0 commit comments