File tree Expand file tree Collapse file tree 3 files changed +35
-2
lines changed
compiler/src/dotty/tools/dotc/cc
tests/neg-custom-args/captures Expand file tree Collapse file tree 3 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -639,8 +639,8 @@ object CapsOfApply:
639
639
class AnnotatedCapability (annot : Context ?=> ClassSymbol ):
640
640
def apply (tp : Type )(using Context ) =
641
641
AnnotatedType (tp, Annotation (annot, util.Spans .NoSpan ))
642
- def unapply (tree : AnnotatedType )(using Context ): Option [SingletonCaptureRef ] = tree match
643
- case AnnotatedType (parent : SingletonCaptureRef , ann) if ann.symbol == annot => Some (parent)
642
+ def unapply (tree : AnnotatedType )(using Context ): Option [CaptureRef ] = tree match
643
+ case AnnotatedType (parent : CaptureRef , ann) if ann.symbol == annot => Some (parent)
644
644
case _ => None
645
645
646
646
/** An extractor for `ref @annotation.internal.reachCapability`, which is used to express
Original file line number Diff line number Diff line change
1
+ import language .experimental .captureChecking
2
+ import caps .Capability
3
+
4
+ trait File extends Capability
5
+
6
+ class Resource [T <: Capability ](gen : T ):
7
+ def use [U ](f : T => U ): U =
8
+ f(gen) // error
9
+
10
+ @ main def run =
11
+ val myFile : File = ???
12
+ val r = Resource (myFile) // error
13
+ ()
Original file line number Diff line number Diff line change
1
+ class C
2
+ def test (x : C ^ , y : C ^ ) =
3
+ class D {
4
+ println(x)
5
+ def foo () = println(y)
6
+ }
7
+ val d = D ()
8
+ val _: D ^ {y} = d // error, should be ok
9
+ val _: D = d // error
10
+
11
+ val f = () => println(D ())
12
+ val _: () -> {x} Unit = f // ok
13
+ val _: () -> Unit = f // should be error
14
+
15
+ def g = () =>
16
+ println(x)
17
+ () => println(y)
18
+ val _: () -> {x} () -> {y} Unit = g // error, should be ok
19
+ val _: () -> () -> Unit = g // error
20
+
You can’t perform that action at this time.
0 commit comments