Skip to content

Commit 20eca21

Browse files
committed
Consider annotations when computing method type dependency information
1 parent efd39cc commit 20eca21

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3579,6 +3579,14 @@ object Types {
35793579
private var myDependencyStatus: DependencyStatus = Unknown
35803580
private var myParamDependencyStatus: DependencyStatus = Unknown
35813581

3582+
private def refersToParam(tree: Tree)(using Context): Boolean =
3583+
tree.existsSubTree {
3584+
case id: Ident => id.tpe match
3585+
case TermParamRef(`thisLambdaType`, _) => true
3586+
case _ => false
3587+
case _ => false
3588+
}
3589+
35823590
private def depStatus(initial: DependencyStatus, tp: Type)(using Context): DependencyStatus =
35833591
class DepAcc extends TypeAccumulator[DependencyStatus]:
35843592
def apply(status: DependencyStatus, tp: Type) = compute(status, tp, this)
@@ -3604,6 +3612,8 @@ object Types {
36043612
case tp: AppliedType => tp.fold(status, compute(_, _, theAcc))
36053613
case tp: TypeVar if !tp.isInstantiated => combine(status, Provisional)
36063614
case tp: TermParamRef if tp.binder eq thisLambdaType => TrueDeps
3615+
case AnnotatedType(parent, ConcreteAnnotation(ann)) =>
3616+
if refersToParam(ann) then TrueDeps else compute(status, parent, theAcc)
36073617
case _: ThisType | _: BoundType | NoPrefix => status
36083618
case _ =>
36093619
(if theAcc != null then theAcc else DepAcc()).foldOver(status, tp)
@@ -3656,8 +3666,10 @@ object Types {
36563666
if (isResultDependent) {
36573667
val dropDependencies = new ApproximatingTypeMap {
36583668
def apply(tp: Type) = tp match {
3659-
case tp @ TermParamRef(thisLambdaType, _) =>
3669+
case tp @ TermParamRef(`thisLambdaType`, _) =>
36603670
range(defn.NothingType, atVariance(1)(apply(tp.underlying)))
3671+
case AnnotatedType(parent, ConcreteAnnotation(ann)) if refersToParam(ann) =>
3672+
mapOver(parent)
36613673
case _ => mapOver(tp)
36623674
}
36633675
}

0 commit comments

Comments
 (0)