Skip to content

Commit 63810dc

Browse files
authored
Handle reach capabilities correctly in depedent functions (#20203)
Handle reach capabilities correctly when computing whether a function is dependent.
2 parents 5f3e1d7 + f0289a3 commit 63810dc

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -4054,7 +4054,7 @@ object Types extends TypeUtils {
40544054
tp match
40554055
case CapturingType(parent, refs) =>
40564056
(compute(status, parent, theAcc) /: refs.elems) {
4057-
(s, ref) => ref match
4057+
(s, ref) => ref.stripReach match
40584058
case tp: TermParamRef if tp.binder eq thisLambdaType => combine(s, CaptureDeps)
40594059
case _ => s
40604060
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
object Test:
2+
class C
3+
type Proc = () => Unit
4+
5+
def f(c: C^, d: C^): () ->{c, d} Unit =
6+
def foo(xs: Proc*): () ->{xs*} Unit =
7+
xs.head
8+
val a: () ->{c} Unit = () => ()
9+
val b: () ->{d} Unit = () => ()
10+
val xx = foo(a, b)
11+
xx
12+
13+
def g(c: C^, d: C^): () ->{c, d} Unit =
14+
15+
def foo(xs: Seq[() => Unit]): () ->{xs*} Unit =
16+
xs.head
17+
18+
val a: () ->{c} Unit = () => ()
19+
val b: () ->{d} Unit = () => ()
20+
val xx = foo(Seq(a, b))
21+
xx

0 commit comments

Comments
 (0)