Skip to content

Commit 59862e3

Browse files
committed
Extend test
1 parent a2ed568 commit 59862e3

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

compiler/src/dotty/tools/dotc/cc/Setup.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,12 +376,13 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
376376

377377
/** 1. Check that parents of capturing types are not pure.
378378
* 2. Check that types extending caps.Sharable don't have a `cap` in their capture set.
379-
* TODO This is not enough.
379+
* TODO: Is this enough?
380380
* We need to also track that we cannot get exclusive capabilities in paths
381381
* where some prefix derives from Sharable. Also, can we just
382382
* exclude `cap`, or do we have to extend this to all exclusive capabilties?
383383
* The problem is that we know what is exclusive in general only after capture
384384
* checking, not before.
385+
* But maybe the rules for classification already cover these cases.
385386
*/
386387
def checkRetainsOK(tp: Type): tp.type =
387388
tp match
Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,29 @@
1-
import caps.{Capability, Control}
1+
import caps.{Capability, Control, Mutable}
22

33
class Try[+T]
44
case class Ok[T](x: T) extends Try[T]
55
case class Fail(ex: Exception) extends Try[Nothing]
66

7+
trait Matrix extends Mutable:
8+
update def update(): Unit
9+
10+
trait Label extends Control:
11+
def break(): Unit
12+
713
object Try:
8-
def apply[T](body: => T): Try[T]^{body.only[Control]} =
9-
try Ok(body)
14+
def apply[T](body: () => T): Try[T]^{body.only[Control]} =
15+
try Ok(body())
1016
catch case ex: Exception => Fail(ex)
17+
18+
def Test(m: Matrix^, l: Label) =
19+
val x =
20+
Try:
21+
val b = () =>
22+
m.update()
23+
l.break()
24+
val _: () ->{m, l} Unit = b
25+
b
26+
val y: Try[Unit]^{l} = x
27+
28+
29+

0 commit comments

Comments
 (0)