Skip to content

Commit

Permalink
Handle reach capabilities correctly in depedent functions (#20203)
Browse files Browse the repository at this point in the history
Handle reach capabilities correctly when computing whether a function is
dependent.
  • Loading branch information
odersky committed Apr 16, 2024
2 parents 5f3e1d7 + f0289a3 commit 63810dc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
21 changes: 21 additions & 0 deletions tests/pos-custom-args/captures/dep-reach.scala
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 63810dc

Please sign in to comment.