Skip to content

Commit

Permalink
Handle reach capabilities correctly when computing whether a function…
Browse files Browse the repository at this point in the history
… is dependent
  • Loading branch information
odersky committed Apr 16, 2024
1 parent 4c2305d commit f0289a3
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 f0289a3

Please sign in to comment.