File tree 3 files changed +25
-2
lines changed
compiler/src/dotty/tools/dotc/cc
tests/neg-custom-args/captures
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
19
19
20
20
object root :
21
21
22
- @ sharable private var rootId = 0
23
-
24
22
enum Kind :
25
23
case Result (binder : MethodType )
26
24
case Fresh (hidden : CaptureSet .HiddenSet )
@@ -35,6 +33,8 @@ object root:
35
33
case _ => false
36
34
end Kind
37
35
36
+ @ sharable private var rootId = 0
37
+
38
38
/** The annotation of a root instance */
39
39
case class Annot (kind : Kind ) extends Annotation :
40
40
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