@@ -2324,6 +2324,14 @@ object Types {
2324
2324
case _ => if (denotationIsCurrent) lastDenotation.nn.symbol else NoSymbol
2325
2325
}
2326
2326
2327
+ /** Like `currentSymbol`, but force the denotation if the symbol isn't valid.
2328
+ * Compared to `stableInRunSymbol`, this doesn't force the denotation for non-symbolic named types,
2329
+ * because currentSymbol returns NoSymbol, which is `Permanent`, so always "isValidInCurrentRun".
2330
+ * Forcing the denotation breaks tests/run/enrich-gentraversable.scala. */
2331
+ private def currentValidSymbol (using Context ): Symbol =
2332
+ val sym = currentSymbol
2333
+ if sym.isValidInCurrentRun then sym else denot.symbol
2334
+
2327
2335
/** Retrieves currently valid symbol without necessarily updating denotation.
2328
2336
* Assumes that symbols do not change between periods in the same run.
2329
2337
* Used to get the class underlying a ThisType.
@@ -2677,10 +2685,7 @@ object Types {
2677
2685
else {
2678
2686
if (isType) {
2679
2687
val res =
2680
- val sym =
2681
- if (currentSymbol.isValidInCurrentRun) currentSymbol
2682
- else computeSymbol
2683
- if (sym.isAllOf(ClassTypeParam )) argForParam(prefix)
2688
+ if (currentValidSymbol.isAllOf(ClassTypeParam )) argForParam(prefix)
2684
2689
else prefix.lookupRefined(name)
2685
2690
if (res.exists) return res
2686
2691
if (Config .splitProjections)
@@ -2754,9 +2759,7 @@ object Types {
2754
2759
/** A reference like this one, but with the given prefix. */
2755
2760
final def withPrefix (prefix : Type )(using Context ): Type = {
2756
2761
def reload (): NamedType = {
2757
- val sym =
2758
- if lastSymbol.nn.isValidInCurrentRun then lastSymbol.nn
2759
- else computeSymbol
2762
+ val sym = stableInRunSymbol
2760
2763
val allowPrivate = ! sym.exists || sym.is(Private )
2761
2764
var d = memberDenot(prefix, name, allowPrivate)
2762
2765
if (d.isOverloaded && sym.exists)
0 commit comments