diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index 47ba9833fc2f..7fb62583d9ef 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -4054,7 +4054,7 @@ object Types extends TypeUtils { tp match case CapturingType(parent, refs) => (compute(status, parent, theAcc) /: refs.elems) { - (s, ref) => ref match + (s, ref) => ref.stripReach match case tp: TermParamRef if tp.binder eq thisLambdaType => combine(s, CaptureDeps) case _ => s } diff --git a/tests/pos-custom-args/captures/dep-reach.scala b/tests/pos-custom-args/captures/dep-reach.scala new file mode 100644 index 000000000000..56343fbf8e53 --- /dev/null +++ b/tests/pos-custom-args/captures/dep-reach.scala @@ -0,0 +1,21 @@ +object Test: + class C + type Proc = () => Unit + + def f(c: C^, d: C^): () ->{c, d} Unit = + def foo(xs: Proc*): () ->{xs*} Unit = + xs.head + val a: () ->{c} Unit = () => () + val b: () ->{d} Unit = () => () + val xx = foo(a, b) + xx + + def g(c: C^, d: C^): () ->{c, d} Unit = + + def foo(xs: Seq[() => Unit]): () ->{xs*} Unit = + xs.head + + val a: () ->{c} Unit = () => () + val b: () ->{d} Unit = () => () + val xx = foo(Seq(a, b)) + xx