Skip to content

Commit 9ff3203

Browse files
committed
Smaller tweaks
1 parent d14a42c commit 9ff3203

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3828,18 +3828,14 @@ object Types {
38283828

38293829
private var validSuper: Period = Nowhere
38303830
private var cachedSuper: Type = _
3831-
private var myStableHash: Byte = 0
38323831

3833-
private var isGroundKnown: Boolean = false
3834-
private var isGroundCache: Boolean = _
3832+
// Boolean caches: 0 = uninitialized, -1 = false, 1 = true
3833+
private var myStableHash: Byte = 0
3834+
private var myGround: Byte = 0
38353835

3836-
def isGround(acc: TypeAccumulator[Boolean])(using Context): Boolean = {
3837-
if (!isGroundKnown) {
3838-
isGroundCache = acc.foldOver(true, this)
3839-
isGroundKnown = true
3840-
}
3841-
isGroundCache
3842-
}
3836+
def isGround(acc: TypeAccumulator[Boolean])(using Context): Boolean =
3837+
if myGround == 0 then myGround = if acc.foldOver(true, this) then 1 else -1
3838+
myGround > 0
38433839

38443840
override def underlying(using Context): Type = tycon
38453841

@@ -5640,7 +5636,7 @@ object Types {
56405636
foldOver(cs + tp.typeSymbol, tp)
56415637
case tp: TypeRef if tp.info.isTypeAlias =>
56425638
apply(cs, tp.superType)
5643-
case tp: TypeRef if tp.typeSymbol.isClass =>
5639+
case tp: TypeRef if tp.symbol.isClass =>
56445640
foldOver(cs + tp.typeSymbol, tp)
56455641
case tp: TermRef =>
56465642
val tsym = if (tp.termSymbol.is(Param)) tp.underlying.typeSymbol else tp.termSymbol

0 commit comments

Comments
 (0)