Skip to content

Commit 009a1e6

Browse files
committed
Made gadt map better encapsulated.
1 parent 16554c0 commit 009a1e6

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,12 @@ object Contexts {
601601
implicit val ctx: Context = initctx
602602
}
603603

604-
class GADTMap(var bounds: SimpleMap[Symbol, TypeBounds])
604+
class GADTMap(initBounds: SimpleMap[Symbol, TypeBounds]) {
605+
private var myBounds = initBounds
606+
def setBounds(sym: Symbol, b: TypeBounds): Unit =
607+
myBounds = myBounds.updated(sym, b)
608+
def bounds = myBounds
609+
}
605610

606611
/** Initial size of superId table */
607612
private final val InitialSuperIdsSize = 4096

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ class TypeComparer(initctx: Context) extends DotClass {
919919

920920
def narrowGADTBounds(tr: NamedType, bounds: TypeBounds): Boolean =
921921
isSubType(bounds.lo, bounds.hi) &&
922-
{ ctx.gadt.bounds = ctx.gadt.bounds.updated(tr.symbol, bounds); true }
922+
{ ctx.gadt.setBounds(tr.symbol, bounds); true }
923923

924924
// Tests around `matches`
925925

src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
675675
val c = ctx.fresh.setFreshGADTBounds
676676
for (sym <- gadtSyms)
677677
if (!c.gadt.bounds.contains(sym))
678-
c.gadt.bounds = c.gadt.bounds.updated(sym, TypeBounds.empty)
678+
c.gadt.setBounds(sym, TypeBounds.empty)
679679
c
680680
}
681681
val pat1 = typedPattern(tree.pat, selType)(gadtCtx)

0 commit comments

Comments
 (0)