Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle reach capabilities correctly in depedent functions #20203

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading