@@ -3579,13 +3579,15 @@ object Types {
3579
3579
private var myDependencyStatus : DependencyStatus = Unknown
3580
3580
private var myParamDependencyStatus : DependencyStatus = Unknown
3581
3581
3582
- private def refersToParam (tree : Tree )(using Context ): Boolean =
3583
- tree.existsSubTree {
3584
- case id : Ident => id.tpe match
3585
- case TermParamRef (`thisLambdaType`, _) => true
3582
+ private def refersToParam (ann : Annotation )(using Context ): Boolean = ann match
3583
+ case ConcreteAnnotation (tree) =>
3584
+ tree.existsSubTree {
3585
+ case id : Ident => id.tpe match
3586
+ case TermParamRef (`thisLambdaType`, _) => true
3587
+ case _ => false
3586
3588
case _ => false
3587
- case _ => false
3588
- }
3589
+ }
3590
+ case _ => false
3589
3591
3590
3592
private def depStatus (initial : DependencyStatus , tp : Type )(using Context ): DependencyStatus =
3591
3593
class DepAcc extends TypeAccumulator [DependencyStatus ]:
@@ -3612,7 +3614,7 @@ object Types {
3612
3614
case tp : AppliedType => tp.fold(status, compute(_, _, theAcc))
3613
3615
case tp : TypeVar if ! tp.isInstantiated => combine(status, Provisional )
3614
3616
case tp : TermParamRef if tp.binder eq thisLambdaType => TrueDeps
3615
- case AnnotatedType (parent, ConcreteAnnotation ( ann) ) =>
3617
+ case AnnotatedType (parent, ann) =>
3616
3618
if refersToParam(ann) then TrueDeps else compute(status, parent, theAcc)
3617
3619
case _ : ThisType | _ : BoundType | NoPrefix => status
3618
3620
case _ =>
@@ -3668,7 +3670,7 @@ object Types {
3668
3670
def apply (tp : Type ) = tp match {
3669
3671
case tp @ TermParamRef (`thisLambdaType`, _) =>
3670
3672
range(defn.NothingType , atVariance(1 )(apply(tp.underlying)))
3671
- case AnnotatedType (parent, ConcreteAnnotation ( ann) ) if refersToParam(ann) =>
3673
+ case AnnotatedType (parent, ann) if refersToParam(ann) =>
3672
3674
mapOver(parent)
3673
3675
case _ => mapOver(tp)
3674
3676
}
@@ -5392,16 +5394,7 @@ object Types {
5392
5394
variance = saved
5393
5395
derivedLambdaType(tp)(ptypes1, this (restpe))
5394
5396
5395
- protected def isRange (tp : Type ): Boolean = tp.isInstanceOf [Range ]
5396
-
5397
- private def diffType (ann : Tree ): Type =
5398
- val acc = new TreeAccumulator [Type ]:
5399
- def apply (x : Type , tree : Tree )(using Context ): Type =
5400
- if isRange(x) then x
5401
- else
5402
- val tp1 = thisMap(tree.tpe)
5403
- foldOver(if tp1 =:= tree.tpe then x else tp1, tree)
5404
- acc(NoType , ann)
5397
+ def isRange (tp : Type ): Boolean = tp.isInstanceOf [Range ]
5405
5398
5406
5399
/** Map this function over given type */
5407
5400
def mapOver (tp : Type ): Type = {
@@ -5446,16 +5439,12 @@ object Types {
5446
5439
5447
5440
case tp @ AnnotatedType (underlying, annot) =>
5448
5441
val underlying1 = this (underlying)
5449
- if (underlying1 ne underlying) || annot.isInstanceOf [ConcreteAnnotation ] then
5450
- val diff = diffType(annot.tree)
5451
- if isRange(diff) then
5452
- // Can't map a tree type to a Range, drop annotation instead
5453
- underlying1
5454
- else
5455
- val annot1 = if diff.exists then mapOver(annot) else annot
5456
- derivedAnnotatedType(tp, underlying1, annot1)
5457
- else
5458
- derivedAnnotatedType(tp, underlying1, annot)
5442
+ val annot1 =
5443
+ if (underlying1 ne underlying) || annot.isMappable
5444
+ then annot.mapWith(this )
5445
+ else annot
5446
+ if annot1 eq EmptyAnnotation then underlying1
5447
+ else derivedAnnotatedType(tp, underlying1, annot1)
5459
5448
5460
5449
case _ : ThisType
5461
5450
| _ : BoundType
@@ -5527,9 +5516,6 @@ object Types {
5527
5516
else newScopeWith(elems1 : _* )
5528
5517
}
5529
5518
5530
- def mapOver (annot : Annotation ): Annotation =
5531
- annot.derivedAnnotation(mapOver(annot.tree))
5532
-
5533
5519
def mapOver (tree : Tree ): Tree = treeTypeMap(tree)
5534
5520
5535
5521
/** Can be overridden. By default, only the prefix is mapped. */
0 commit comments