File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ import language .experimental .captureChecking
2+ import caps .*
3+
4+ class Runner (val x : Int ) extends AnyVal :
5+ def runOps (@ use ops : List [() => Unit ]): Unit =
6+ ops.foreach(_()) // ok
7+
8+ class RunnerAlt (val x : Int ):
9+ def runOps (@ use ops : List [() => Unit ]): Unit =
10+ ops.foreach(_()) // ok, of course
11+
12+ class RunnerAltAlt (val x : Int ) extends AnyVal :
13+ def runOps (ops : List [() => Unit ]): Unit =
14+ ops.foreach(_()) // error, as expected
15+
16+ class RunnerAltAltAlt (val x : Int ):
17+ def runOps (ops : List [() => Unit ]): Unit =
18+ ops.foreach(_()) // error, as expected
Original file line number Diff line number Diff line change 1+ import language .experimental .captureChecking
2+ trait IterableOnce [+ T ]
3+ trait Iterable [+ T ] extends IterableOnce [T ]:
4+ def flatMap [U ](@ caps.use f : T => IterableOnce [U ]^ ): Iterable [U ]^ {this , f* }
5+
6+
7+ class IterableOnceExtensionMethods [T ](val it : IterableOnce [T ]) extends AnyVal :
8+ def flatMap [U ](@ caps.use f : T => IterableOnce [U ]^ ): IterableOnce [U ]^ {f* } = it match
9+ case it : Iterable [T ] => it.flatMap(f)
10+
You can’t perform that action at this time.
0 commit comments