Skip to content
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/cc/CheckCaptures.scala
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ class CheckCaptures extends Recheck, SymTransformer:
if tree.isTerm then
if !ccConfig.useExistentials then
checkReachCapsIsolated(res.widen, tree.srcPos)
if !pt.isBoxedCapturing then
if !pt.isBoxedCapturing && pt != LhsProto then
markFree(res.boxedCaptureSet, tree.srcPos)
res

Expand Down
10 changes: 10 additions & 0 deletions tests/pos-custom-args/captures/i21507.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import language.experimental.captureChecking

trait Box[Cap^]:
def store(f: (() -> Unit)^{Cap^}): Unit

def run[Cap^](f: Box[Cap]^{Cap^} => Unit): Box[Cap]^{Cap^} =
new Box[Cap]:
private var item: () ->{Cap^} Unit = () => ()
def store(f: () ->{Cap^} Unit): Unit =
item = f // was error, now ok