File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -161,7 +161,7 @@ object Types {
161161 * Rationale: If an expression has a stable type, the expression must be idempotent, so stable types
162162 * must be singleton types of stable expressions. */
163163 final def isStable (using Context ): Boolean = stripTypeVar match {
164- case tp : TermRef => tp.symbol.isStableMember && tp.prefix.isStable || tp.info.isStable
164+ case tp : TermRef => tp.cachedIsStable
165165 case _ : SingletonType | NoPrefix => true
166166 case tp : RefinedOrRecType => tp.parent.isStable
167167 case tp : ExprType => tp.resultType.isStable
@@ -2665,6 +2665,19 @@ object Types {
26652665 override def designator : Designator = myDesignator
26662666 override protected def designator_= (d : Designator ): Unit = myDesignator = d
26672667
2668+ var myIsStablePeriod : Period = Nowhere
2669+ var myIsStable : Boolean = false
2670+
2671+ private [Types ] def cachedIsStable (using Context ): Boolean =
2672+ if myIsStablePeriod != ctx.period then
2673+ val isStable : Boolean = symbol.isStableMember && prefix.isStable || info.isStable
2674+ if ! isProvisional then
2675+ myIsStablePeriod = ctx.period
2676+ myIsStable = isStable
2677+ isStable
2678+ else
2679+ myIsStable
2680+
26682681 // assert(name.toString != "<local Coder>")
26692682 override def underlying (using Context ): Type = {
26702683 val d = denot
You can’t perform that action at this time.
0 commit comments