@@ -3601,6 +3601,9 @@ object Types {
3601
3601
case tp : AppliedType => tp.fold(status, compute(_, _, theAcc))
3602
3602
case tp : TypeVar if ! tp.isInstantiated => combine(status, Provisional )
3603
3603
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)
3604
3607
case _ : ThisType | _ : BoundType | NoPrefix => status
3605
3608
case _ =>
3606
3609
(if theAcc != null then theAcc else DepAcc ()).foldOver(status, tp)
@@ -3653,8 +3656,10 @@ object Types {
3653
3656
if (isResultDependent) {
3654
3657
val dropDependencies = new ApproximatingTypeMap {
3655
3658
def apply (tp : Type ) = tp match {
3656
- case tp @ TermParamRef (thisLambdaType, _) =>
3659
+ case tp @ TermParamRef (` thisLambdaType` , _) =>
3657
3660
range(defn.NothingType , atVariance(1 )(apply(tp.underlying)))
3661
+ case AnnotatedType (parent, ann) if ann.refersToParamOf(thisLambdaType) =>
3662
+ mapOver(parent)
3658
3663
case _ => mapOver(tp)
3659
3664
}
3660
3665
}
@@ -4104,18 +4109,17 @@ object Types {
4104
4109
4105
4110
override def underlying (using Context ): Type = tycon
4106
4111
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
4110
4116
case tycon : HKTypeLambda => defn.AnyType
4111
4117
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
4113
4121
case _ => defn.AnyType
4114
- }
4115
- validSuper = if (tycon.isProvisional) Nowhere else ctx.period
4116
- }
4117
4122
cachedSuper
4118
- }
4119
4123
4120
4124
override def translucentSuperType (using Context ): Type = tycon match {
4121
4125
case tycon : TypeRef if tycon.symbol.isOpaqueAlias =>
@@ -5379,6 +5383,8 @@ object Types {
5379
5383
variance = saved
5380
5384
derivedLambdaType(tp)(ptypes1, this (restpe))
5381
5385
5386
+ def isRange (tp : Type ): Boolean = tp.isInstanceOf [Range ]
5387
+
5382
5388
/** Map this function over given type */
5383
5389
def mapOver (tp : Type ): Type = {
5384
5390
record(s " TypeMap mapOver ${getClass}" )
@@ -5422,8 +5428,9 @@ object Types {
5422
5428
5423
5429
case tp @ AnnotatedType (underlying, annot) =>
5424
5430
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)
5427
5434
5428
5435
case _ : ThisType
5429
5436
| _ : BoundType
@@ -5495,9 +5502,6 @@ object Types {
5495
5502
else newScopeWith(elems1 : _* )
5496
5503
}
5497
5504
5498
- def mapOver (annot : Annotation ): Annotation =
5499
- annot.derivedAnnotation(mapOver(annot.tree))
5500
-
5501
5505
def mapOver (tree : Tree ): Tree = treeTypeMap(tree)
5502
5506
5503
5507
/** Can be overridden. By default, only the prefix is mapped. */
@@ -5544,8 +5548,6 @@ object Types {
5544
5548
5545
5549
protected def emptyRange = range(defn.NothingType , defn.AnyType )
5546
5550
5547
- protected def isRange (tp : Type ): Boolean = tp.isInstanceOf [Range ]
5548
-
5549
5551
protected def lower (tp : Type ): Type = tp match {
5550
5552
case tp : Range => tp.lo
5551
5553
case _ => tp
0 commit comments