@@ -2455,21 +2455,36 @@ object Types extends TypeUtils {
2455
2455
d
2456
2456
}
2457
2457
2458
- def fromDesignator = designator match {
2458
+ def fromDesignator ( lastdMaybe : Option [ SingleDenotation ]) = designator match {
2459
2459
case name : Name =>
2460
2460
val sym = lastSymbol
2461
2461
val allowPrivate = sym == null || (sym == NoSymbol ) || sym.lastKnownDenotation.flagsUNSAFE.is(Private )
2462
2462
finish(memberDenot(name, allowPrivate))
2463
2463
case sym : Symbol =>
2464
2464
val symd = sym.lastKnownDenotation
2465
- if (symd.validFor.runId != ctx.runId && ! stillValid(symd))
2466
- finish(memberDenot(symd.initial.name, allowPrivate = false ))
2467
- else if (prefix.isArgPrefixOf(symd))
2468
- finish(argDenot(sym.asType))
2469
- else if (infoDependsOnPrefix(symd, prefix))
2470
- finish(memberDenot(symd.initial.name, allowPrivate = symd.is(Private )))
2471
- else
2472
- finish(symd.current)
2465
+ if (symd.validFor.runId != ctx.runId && ! stillValid(symd))
2466
+ val res0 = memberDenot(symd.initial.name, allowPrivate = false )
2467
+ val res = lastdMaybe match
2468
+ case Some (lastd) if hasSkolems(lastd.info) =>
2469
+ // When updating denotation, changing types from skolem may cause issues
2470
+ // with other parts of the tree
2471
+ finish(lastd.derivedSingleDenotation(res0.symbol, lastd.info, prefix))
2472
+ case _ =>
2473
+ res0
2474
+ finish(res)
2475
+ else if (prefix.isArgPrefixOf(symd))
2476
+ finish(argDenot(sym.asType))
2477
+ else if (infoDependsOnPrefix(symd, prefix))
2478
+ val res = lastdMaybe match
2479
+ case Some (lastd) if hasSkolems(lastd.info) =>
2480
+ // When updating denotation, changing types from skolem may cause issues
2481
+ // with other parts of the tree
2482
+ finish(lastd.derivedSingleDenotation(sym, lastd.info, prefix))
2483
+ case _ =>
2484
+ memberDenot(symd.initial.name, allowPrivate = symd.is(Private ))
2485
+ finish(res)
2486
+ else
2487
+ finish(symd.current)
2473
2488
}
2474
2489
2475
2490
lastDenotation match {
@@ -2482,9 +2497,9 @@ object Types extends TypeUtils {
2482
2497
if stillValid(lastd) && checkedPeriod.code != NowhereCode then finish(lastd.current)
2483
2498
else finish(memberDenot(lastd.initial.name, allowPrivate = lastd.is(Private )))
2484
2499
case _ =>
2485
- fromDesignator
2500
+ fromDesignator( Some (lastd))
2486
2501
}
2487
- case _ => fromDesignator
2502
+ case _ => fromDesignator( None )
2488
2503
}
2489
2504
}
2490
2505
@@ -7024,6 +7039,16 @@ object Types extends TypeUtils {
7024
7039
def isStable = true
7025
7040
}
7026
7041
7042
+ def hasSkolems (tpe : Type )(using Context ) =
7043
+ object hasSkolemsAcc extends TypeAccumulator [Boolean ]:
7044
+ def apply (x : Boolean , tp : Type ): Boolean =
7045
+ x || {
7046
+ tp match
7047
+ case _ : SkolemType => true
7048
+ case _ => foldOver(false , tp)
7049
+ }
7050
+ hasSkolemsAcc(false , tpe)
7051
+
7027
7052
// ----- Debug ---------------------------------------------------------
7028
7053
7029
7054
@ sharable var debugTrace : Boolean = false
0 commit comments