Skip to content

Commit 731c9aa

Browse files
committed
Test case showing that second soundness hole is filled
1 parent ec8d119 commit 731c9aa

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ import annotation.internal.sharable
1919

2020
object 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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
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`
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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

0 commit comments

Comments
 (0)