File tree 1 file changed +14
-1
lines changed
compiler/src/dotty/tools/dotc/core
1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -161,7 +161,7 @@ object Types {
161
161
* Rationale: If an expression has a stable type, the expression must be idempotent, so stable types
162
162
* must be singleton types of stable expressions. */
163
163
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
165
165
case _ : SingletonType | NoPrefix => true
166
166
case tp : RefinedOrRecType => tp.parent.isStable
167
167
case tp : ExprType => tp.resultType.isStable
@@ -2665,6 +2665,19 @@ object Types {
2665
2665
override def designator : Designator = myDesignator
2666
2666
override protected def designator_= (d : Designator ): Unit = myDesignator = d
2667
2667
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
+
2668
2681
// assert(name.toString != "<local Coder>")
2669
2682
override def underlying (using Context ): Type = {
2670
2683
val d = denot
You can’t perform that action at this time.
0 commit comments