@@ -1389,6 +1389,17 @@ object Types {
13891389 /** Like `dealiasKeepAnnots`, but keeps only refining annotations */
13901390 final def dealiasKeepRefiningAnnots (using Context ): Type = dealias1(keepIfRefining)
13911391
1392+ /** Approximate this type with a type that does not contain skolem types. */
1393+ final def deskolemized (using Context ): Type =
1394+ val deskolemizer = new ApproximatingTypeMap {
1395+ def apply (tp : Type ) = /* trace(i"deskolemize($tp) at $variance", show = true)*/
1396+ tp match {
1397+ case tp : SkolemType => range(defn.NothingType , atVariance(1 )(apply(tp.info)))
1398+ case _ => mapOver(tp)
1399+ }
1400+ }
1401+ deskolemizer(this )
1402+
13921403 /** The result of normalization using `tryNormalize`, or the type itself if
13931404 * tryNormlize yields NoType
13941405 */
@@ -3601,6 +3612,9 @@ object Types {
36013612 case tp : AppliedType => tp.fold(status, compute(_, _, theAcc))
36023613 case tp : TypeVar if ! tp.isInstantiated => combine(status, Provisional )
36033614 case tp : TermParamRef if tp.binder eq thisLambdaType => TrueDeps
3615+ case AnnotatedType (parent, ann) =>
3616+ if ann.refersToParamOf(thisLambdaType) then TrueDeps
3617+ else compute(status, parent, theAcc)
36043618 case _ : ThisType | _ : BoundType | NoPrefix => status
36053619 case _ =>
36063620 (if theAcc != null then theAcc else DepAcc ()).foldOver(status, tp)
@@ -3653,8 +3667,10 @@ object Types {
36533667 if (isResultDependent) {
36543668 val dropDependencies = new ApproximatingTypeMap {
36553669 def apply (tp : Type ) = tp match {
3656- case tp @ TermParamRef (thisLambdaType, _) =>
3670+ case tp @ TermParamRef (` thisLambdaType` , _) =>
36573671 range(defn.NothingType , atVariance(1 )(apply(tp.underlying)))
3672+ case AnnotatedType (parent, ann) if ann.refersToParamOf(thisLambdaType) =>
3673+ mapOver(parent)
36583674 case _ => mapOver(tp)
36593675 }
36603676 }
@@ -4104,18 +4120,17 @@ object Types {
41044120
41054121 override def underlying (using Context ): Type = tycon
41064122
4107- override def superType (using Context ): Type = {
4108- if (ctx.period != validSuper) {
4109- cachedSuper = tycon match {
4123+ override def superType (using Context ): Type =
4124+ if ctx.period != validSuper then
4125+ validSuper = if (tycon.isProvisional) Nowhere else ctx.period
4126+ cachedSuper = tycon match
41104127 case tycon : HKTypeLambda => defn.AnyType
41114128 case tycon : TypeRef if tycon.symbol.isClass => tycon
4112- case tycon : TypeProxy => tycon.superType.applyIfParameterized(args)
4129+ case tycon : TypeProxy =>
4130+ if isMatchAlias then validSuper = Nowhere
4131+ tycon.superType.applyIfParameterized(args).normalized
41134132 case _ => defn.AnyType
4114- }
4115- validSuper = if (tycon.isProvisional) Nowhere else ctx.period
4116- }
41174133 cachedSuper
4118- }
41194134
41204135 override def translucentSuperType (using Context ): Type = tycon match {
41214136 case tycon : TypeRef if tycon.symbol.isOpaqueAlias =>
@@ -5379,6 +5394,8 @@ object Types {
53795394 variance = saved
53805395 derivedLambdaType(tp)(ptypes1, this (restpe))
53815396
5397+ def isRange (tp : Type ): Boolean = tp.isInstanceOf [Range ]
5398+
53825399 /** Map this function over given type */
53835400 def mapOver (tp : Type ): Type = {
53845401 record(s " TypeMap mapOver ${getClass}" )
@@ -5422,8 +5439,9 @@ object Types {
54225439
54235440 case tp @ AnnotatedType (underlying, annot) =>
54245441 val underlying1 = this (underlying)
5425- if (underlying1 eq underlying) tp
5426- else derivedAnnotatedType(tp, underlying1, mapOver(annot))
5442+ val annot1 = annot.mapWith(this )
5443+ if annot1 eq EmptyAnnotation then underlying1
5444+ else derivedAnnotatedType(tp, underlying1, annot1)
54275445
54285446 case _ : ThisType
54295447 | _ : BoundType
@@ -5495,9 +5513,6 @@ object Types {
54955513 else newScopeWith(elems1 : _* )
54965514 }
54975515
5498- def mapOver (annot : Annotation ): Annotation =
5499- annot.derivedAnnotation(mapOver(annot.tree))
5500-
55015516 def mapOver (tree : Tree ): Tree = treeTypeMap(tree)
55025517
55035518 /** Can be overridden. By default, only the prefix is mapped. */
@@ -5544,8 +5559,6 @@ object Types {
55445559
55455560 protected def emptyRange = range(defn.NothingType , defn.AnyType )
55465561
5547- protected def isRange (tp : Type ): Boolean = tp.isInstanceOf [Range ]
5548-
55495562 protected def lower (tp : Type ): Type = tp match {
55505563 case tp : Range => tp.lo
55515564 case _ => tp
0 commit comments