@@ -3687,22 +3687,24 @@ object Types extends TypeUtils {
3687
3687
}
3688
3688
3689
3689
private var myUnion : Type = uninitialized
3690
+ private var myUnionProvStatus : ProvisionalState | Null = null
3690
3691
private var myUnionPeriod : Period = Nowhere
3691
3692
3692
3693
override def widenUnionWithoutNull (using Context ): Type =
3693
- if myUnionPeriod != ctx.period then
3694
+ if myUnionPeriod != ctx.period
3695
+ || ! isCacheUpToDate(currentProvisionalState, myUnionProvStatus) then
3694
3696
val union = TypeComparer .lub(
3695
3697
tp1.widenUnionWithoutNull, tp2.widenUnionWithoutNull, canConstrain = isSoft, isSoft = isSoft)
3696
3698
myUnion = union match
3697
3699
case union : OrType if isSoft => union.join
3698
3700
case _ => union
3699
- if ! isProvisional then myUnionPeriod = ctx.period
3701
+ myUnionProvStatus = currentProvisionalState
3702
+ myUnionPeriod = ctx.period
3700
3703
myUnion
3701
3704
3702
- private var atomsRunId : RunId = NoRunId
3703
- private var widenedRunId : RunId = NoRunId
3704
3705
private var myAtoms : Atoms = uninitialized
3705
- private var myWidened : Type = uninitialized
3706
+ private var myAtomsProvStatus : ProvisionalState | Null = null
3707
+ private var myAtomsRunId : RunId = NoRunId
3706
3708
3707
3709
private def computeAtoms ()(using Context ): Atoms =
3708
3710
val tp1n = tp1.normalized
@@ -3711,23 +3713,31 @@ object Types extends TypeUtils {
3711
3713
else if tp2n.hasClassSymbol(defn.NothingClass ) then tp1.atoms
3712
3714
else tp1n.atoms | tp2n.atoms
3713
3715
3716
+ override def atoms (using Context ): Atoms =
3717
+ if myAtomsRunId != ctx.runId
3718
+ || ! isCacheUpToDate(currentProvisionalState, myAtomsProvStatus) then
3719
+ myAtoms = computeAtoms()
3720
+ myAtomsProvStatus = currentProvisionalState
3721
+ myAtomsRunId = ctx.runId
3722
+ myAtoms
3723
+
3724
+ private var myWidened : Type = uninitialized
3725
+ private var myWidenedProvStatus : ProvisionalState | Null = null
3726
+ private var myWidenedRunId : RunId = NoRunId
3727
+
3714
3728
private def computeWidenSingletons ()(using Context ): Type =
3715
3729
val tp1w = tp1.widenSingletons()
3716
3730
val tp2w = tp2.widenSingletons()
3717
3731
if ((tp1 eq tp1w) && (tp2 eq tp2w)) this else TypeComparer .lub(tp1w, tp2w, isSoft = isSoft)
3718
3732
3719
- override def atoms (using Context ): Atoms =
3720
- if atomsRunId != ctx.runId then
3721
- myAtoms = computeAtoms()
3722
- if ! isProvisional then atomsRunId = ctx.runId
3723
- myAtoms
3724
-
3725
3733
override def widenSingletons (skipSoftUnions : Boolean )(using Context ): Type =
3726
3734
if isSoft && skipSoftUnions then this
3727
3735
else
3728
- if widenedRunId != ctx.runId then
3736
+ if myWidenedRunId != ctx.runId
3737
+ || ! isCacheUpToDate(currentProvisionalState, myWidenedProvStatus) then
3729
3738
myWidened = computeWidenSingletons()
3730
- if ! isProvisional then widenedRunId = ctx.runId
3739
+ myWidenedProvStatus = currentProvisionalState
3740
+ myWidenedRunId = ctx.runId
3731
3741
myWidened
3732
3742
3733
3743
def derivedOrType (tp1 : Type , tp2 : Type , soft : Boolean = isSoft)(using Context ): Type =
0 commit comments