Skip to content

Commit 349e113

Browse files
committed
Consider annotations when computing method type dependency information
# Conflicts: # compiler/src/dotty/tools/dotc/core/Types.scala
1 parent 950bd90 commit 349e113

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
@@ -3669,6 +3669,14 @@ object Types {
36693669
private var myDependencyStatus: DependencyStatus = Unknown
36703670
private var myParamDependencyStatus: DependencyStatus = Unknown
36713671

3672+
private def refersToParam(tree: Tree)(using Context): Boolean =
3673+
tree.existsSubTree {
3674+
case id: Ident => id.tpe match
3675+
case TermParamRef(`thisLambdaType`, _) => true
3676+
case _ => false
3677+
case _ => false
3678+
}
3679+
36723680
private def depStatus(initial: DependencyStatus, tp: Type)(using Context): DependencyStatus =
36733681
class DepAcc extends TypeAccumulator[DependencyStatus]:
36743682
def apply(status: DependencyStatus, tp: Type) = compute(status, tp, this)
@@ -3700,6 +3708,8 @@ object Types {
37003708
case tp: TermParamRef if tp.binder eq thisLambdaType => combine(s, CaptureDeps)
37013709
case _ => s
37023710
}
3711+
case AnnotatedType(parent, ConcreteAnnotation(ann)) =>
3712+
if refersToParam(ann) then TrueDeps else compute(status, parent, theAcc)
37033713
case _: ThisType | _: BoundType | NoPrefix => status
37043714
case _ =>
37053715
(if theAcc != null then theAcc else DepAcc()).foldOver(status, tp)
@@ -3758,8 +3768,10 @@ object Types {
37583768
if isResultDependent then
37593769
val dropDependencies = new ApproximatingTypeMap {
37603770
def apply(tp: Type) = tp match {
3761-
case tp @ TermParamRef(thisLambdaType, _) =>
3771+
case tp @ TermParamRef(`thisLambdaType`, _) =>
37623772
range(defn.NothingType, atVariance(1)(apply(tp.underlying)))
3773+
case AnnotatedType(parent, ConcreteAnnotation(ann)) if refersToParam(ann) =>
3774+
mapOver(parent)
37633775
case _ => mapOver(tp)
37643776
}
37653777
}

0 commit comments

Comments
 (0)