File tree Expand file tree Collapse file tree 3 files changed +25
-2
lines changed
compiler/src/dotty/tools/dotc/cc
tests/neg-custom-args/captures Expand file tree Collapse file tree 3 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -19,8 +19,6 @@ import annotation.internal.sharable
1919
2020object root :
2121
22- @ sharable private var rootId = 0
23-
2422 enum Kind :
2523 case Result (binder : MethodType )
2624 case Fresh (hidden : CaptureSet .HiddenSet )
@@ -35,6 +33,8 @@ object root:
3533 case _ => false
3634 end Kind
3735
36+ @ sharable private var rootId = 0
37+
3838 /** The annotation of a root instance */
3939 case class Annot (kind : Kind ) extends Annotation :
4040
Original file line number Diff line number Diff line change 1+ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/contracap.scala:15:48 ------------------------------------
2+ 15 | val g: (Ref[Int]^{a}, Ref[Int]^{a}) -> Unit = f // error
3+ | ^
4+ | Found: (f : (Ref[Int]^, Ref[Int]^) -> Unit)
5+ | Required: (Ref[Int]^{a}, Ref[Int]^{a}) -> Unit
6+ |
7+ | longer explanation available when compiling with `-explain`
Original file line number Diff line number Diff line change 1+ import language .experimental .captureChecking
2+ import caps .*
3+
4+ class Ref [T ](init : T ) extends Mutable :
5+ private var value : T = init
6+ def get : T = value
7+ mut def set (newValue : T ): Unit = value = newValue
8+
9+ // a library function that assumes that a and b MUST BE separate
10+ def swap [T ](a : Ref [Int ]^ , b : Ref [Int ]^ ): Unit = ???
11+
12+ def test2 (): Unit =
13+ val a : Ref [Int ]^ = Ref (0 )
14+ val f : (Ref [Int ]^ , Ref [Int ]^ ) -> Unit = swap
15+ val g : (Ref [Int ]^ {a}, Ref [Int ]^ {a}) -> Unit = f // error
16+ g(a, a) // OH NO
You can’t perform that action at this time.
0 commit comments