File tree 2 files changed +10
-9
lines changed
compiler/src/dotty/tools/dotc/core
2 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -526,9 +526,11 @@ object Contexts {
526
526
final def withOwner (owner : Symbol ): Context =
527
527
if (owner ne this .owner) fresh.setOwner(owner) else this
528
528
529
+ final def withTyperState (typerState : TyperState ): Context =
530
+ if typerState ne this .typerState then fresh.setTyperState(typerState) else this
531
+
529
532
final def withUncommittedTyperState : Context =
530
- val ts = typerState.uncommittedAncestor
531
- if ts ne typerState then fresh.setTyperState(ts) else this
533
+ withTyperState(typerState.uncommittedAncestor)
532
534
533
535
final def withProperty [T ](key : Key [T ], value : Option [T ]): Context =
534
536
if (property(key) == value) this
@@ -599,8 +601,8 @@ object Contexts {
599
601
this .scope = newScope
600
602
this
601
603
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 ))
604
606
def setReporter (reporter : Reporter ): this .type = setTyperState(typerState.fresh().setReporter(reporter))
605
607
def setTyper (typer : Typer ): this .type = { this .scope = typer.scope; setTypeAssigner(typer) }
606
608
def setGadt (gadt : GadtConstraint ): this .type =
Original file line number Diff line number Diff line change @@ -103,11 +103,12 @@ class TyperState() {
103
103
this
104
104
105
105
/** 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 =
107
108
util.Stats .record(" TyperState.fresh" )
108
109
TyperState ().init(this , this .constraint)
109
110
.setReporter(reporter)
110
- .setCommittable(this .isCommittable )
111
+ .setCommittable(committable )
111
112
112
113
/** The uninstantiated variables */
113
114
def uninstVars : collection.Seq [TypeVar ] = constraint.uninstVars
@@ -189,9 +190,7 @@ class TyperState() {
189
190
def mergeConstraintWith (that : TyperState )(using Context ): Unit =
190
191
that.ensureNotConflicting(constraint)
191
192
192
- val comparingCtx =
193
- if ctx.typerState == this then ctx
194
- else ctx.fresh.setTyperState(this )
193
+ val comparingCtx = ctx.withTyperState(this )
195
194
196
195
comparing(typeComparer =>
197
196
val other = that.constraint
You can’t perform that action at this time.
0 commit comments