@@ -3601,6 +3601,9 @@ object Types {
36013601 case tp : AppliedType => tp.fold(status, compute(_, _, theAcc))
36023602 case tp : TypeVar if ! tp.isInstantiated => combine(status, Provisional )
36033603 case tp : TermParamRef if tp.binder eq thisLambdaType => TrueDeps
3604+ case AnnotatedType (parent, ann) =>
3605+ if ann.refersToParamOf(thisLambdaType) then TrueDeps
3606+ else compute(status, parent, theAcc)
36043607 case _ : ThisType | _ : BoundType | NoPrefix => status
36053608 case _ =>
36063609 (if theAcc != null then theAcc else DepAcc ()).foldOver(status, tp)
@@ -3653,8 +3656,10 @@ object Types {
36533656 if (isResultDependent) {
36543657 val dropDependencies = new ApproximatingTypeMap {
36553658 def apply (tp : Type ) = tp match {
3656- case tp @ TermParamRef (thisLambdaType, _) =>
3659+ case tp @ TermParamRef (` thisLambdaType` , _) =>
36573660 range(defn.NothingType , atVariance(1 )(apply(tp.underlying)))
3661+ case AnnotatedType (parent, ann) if ann.refersToParamOf(thisLambdaType) =>
3662+ mapOver(parent)
36583663 case _ => mapOver(tp)
36593664 }
36603665 }
@@ -4104,18 +4109,17 @@ object Types {
41044109
41054110 override def underlying (using Context ): Type = tycon
41064111
4107- override def superType (using Context ): Type = {
4108- if (ctx.period != validSuper) {
4109- cachedSuper = tycon match {
4112+ override def superType (using Context ): Type =
4113+ if ctx.period != validSuper then
4114+ validSuper = if (tycon.isProvisional) Nowhere else ctx.period
4115+ cachedSuper = tycon match
41104116 case tycon : HKTypeLambda => defn.AnyType
41114117 case tycon : TypeRef if tycon.symbol.isClass => tycon
4112- case tycon : TypeProxy => tycon.superType.applyIfParameterized(args)
4118+ case tycon : TypeProxy =>
4119+ if isMatchAlias then validSuper = Nowhere
4120+ tycon.superType.applyIfParameterized(args).normalized
41134121 case _ => defn.AnyType
4114- }
4115- validSuper = if (tycon.isProvisional) Nowhere else ctx.period
4116- }
41174122 cachedSuper
4118- }
41194123
41204124 override def translucentSuperType (using Context ): Type = tycon match {
41214125 case tycon : TypeRef if tycon.symbol.isOpaqueAlias =>
@@ -5379,6 +5383,8 @@ object Types {
53795383 variance = saved
53805384 derivedLambdaType(tp)(ptypes1, this (restpe))
53815385
5386+ def isRange (tp : Type ): Boolean = tp.isInstanceOf [Range ]
5387+
53825388 /** Map this function over given type */
53835389 def mapOver (tp : Type ): Type = {
53845390 record(s " TypeMap mapOver ${getClass}" )
@@ -5422,8 +5428,9 @@ object Types {
54225428
54235429 case tp @ AnnotatedType (underlying, annot) =>
54245430 val underlying1 = this (underlying)
5425- if (underlying1 eq underlying) tp
5426- else derivedAnnotatedType(tp, underlying1, mapOver(annot))
5431+ val annot1 = annot.mapWith(this )
5432+ if annot1 eq EmptyAnnotation then underlying1
5433+ else derivedAnnotatedType(tp, underlying1, annot1)
54275434
54285435 case _ : ThisType
54295436 | _ : BoundType
@@ -5495,9 +5502,6 @@ object Types {
54955502 else newScopeWith(elems1 : _* )
54965503 }
54975504
5498- def mapOver (annot : Annotation ): Annotation =
5499- annot.derivedAnnotation(mapOver(annot.tree))
5500-
55015505 def mapOver (tree : Tree ): Tree = treeTypeMap(tree)
55025506
55035507 /** Can be overridden. By default, only the prefix is mapped. */
@@ -5544,8 +5548,6 @@ object Types {
55445548
55455549 protected def emptyRange = range(defn.NothingType , defn.AnyType )
55465550
5547- protected def isRange (tp : Type ): Boolean = tp.isInstanceOf [Range ]
5548-
55495551 protected def lower (tp : Type ): Type = tp match {
55505552 case tp : Range => tp.lo
55515553 case _ => tp
0 commit comments