File tree Expand file tree Collapse file tree 2 files changed +6
-5
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import printing.{Showable, Printer}
11
11
import printing .Texts ._
12
12
import config .Config
13
13
import collection .mutable
14
+ import java .lang .ref .WeakReference
14
15
15
16
class TyperState (r : Reporter ) extends DotClass with Showable {
16
17
@@ -143,8 +144,7 @@ extends TyperState(r) {
143
144
if (targetState.constraint eq previousConstraint) constraint
144
145
else targetState.constraint & constraint
145
146
constraint foreachTypeVar { tvar =>
146
- if (tvar.owningState eq this )
147
- tvar.owningState = targetState
147
+ if (tvar.owningState.get eq this ) tvar.owningState = new WeakReference (targetState)
148
148
}
149
149
targetState.ephemeral |= ephemeral
150
150
targetState.gc()
@@ -157,7 +157,7 @@ extends TyperState(r) {
157
157
constraint foreachTypeVar { tvar =>
158
158
if (! tvar.inst.exists) {
159
159
val inst = instType(tvar)
160
- if (inst.exists && (tvar.owningState eq this )) {
160
+ if (inst.exists && (tvar.owningState.get eq this )) {
161
161
tvar.inst = inst
162
162
val lam = tvar.origin.binder
163
163
if (constraint.isRemovable(lam)) toCollect += lam
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ import Flags.FlagSet
36
36
import language .implicitConversions
37
37
import scala .util .hashing .{ MurmurHash3 => hashing }
38
38
import config .Printers .{core , typr , cyclicErrors }
39
+ import java .lang .ref .WeakReference
39
40
40
41
object Types {
41
42
@@ -3186,7 +3187,7 @@ object Types {
3186
3187
/** The state owning the variable. This is at first `creatorState`, but it can
3187
3188
* be changed to an enclosing state on a commit.
3188
3189
*/
3189
- private [core] var owningState = creatorState
3190
+ private [core] var owningState = new WeakReference ( creatorState)
3190
3191
3191
3192
/** The instance type of this variable, or NoType if the variable is currently
3192
3193
* uninstantiated
@@ -3204,7 +3205,7 @@ object Types {
3204
3205
private def instantiateWith (tp : Type )(implicit ctx : Context ): Type = {
3205
3206
assert(tp ne this , s " self instantiation of ${tp.show}, constraint = ${ctx.typerState.constraint.show}" )
3206
3207
typr.println(s " instantiating ${this .show} with ${tp.show}" )
3207
- if ((ctx.typerState eq owningState) && ! ctx.typeComparer.subtypeCheckInProgress)
3208
+ if ((ctx.typerState eq owningState.get ) && ! ctx.typeComparer.subtypeCheckInProgress)
3208
3209
inst = tp
3209
3210
ctx.typerState.constraint = ctx.typerState.constraint.replace(origin, tp)
3210
3211
tp
You can’t perform that action at this time.
0 commit comments