File tree Expand file tree Collapse file tree 4 files changed +23
-6
lines changed
compiler/src/dotty/tools/dotc/cc
tests/neg-custom-args/captures Expand file tree Collapse file tree 4 files changed +23
-6
lines changed Original file line number Diff line number Diff line change @@ -138,8 +138,8 @@ object Capabilities:
138
138
* for diagnostics
139
139
*/
140
140
case class FreshCap private (owner : Symbol , origin : Origin )(using @ constructorOnly ctx : Context ) extends RootCapability :
141
- val hiddenSet = CaptureSet .HiddenSet (owner)
142
- hiddenSet.owningCap = this
141
+ val hiddenSet = CaptureSet .HiddenSet (owner, this : @ unchecked )
142
+ // fails initialization check without the @unchecked
143
143
144
144
override def equals (that : Any ) = that match
145
145
case that : FreshCap => this eq that
Original file line number Diff line number Diff line change @@ -950,16 +950,15 @@ object CaptureSet:
950
950
* which are already subject through snapshotting and rollbacks in VarState.
951
951
* It's advantageous if we don't need to deal with other pieces of state there.
952
952
*/
953
- class HiddenSet (initialOwner : Symbol )(using @ constructorOnly ictx : Context )
953
+ class HiddenSet (initialOwner : Symbol , val owningCap : FreshCap )(using @ constructorOnly ictx : Context )
954
954
extends Var (initialOwner):
955
- var owningCap : FreshCap = uninitialized // initialized when owning FreshCap is created
956
955
var givenOwner : Symbol = initialOwner
957
956
958
957
override def owner = givenOwner
959
958
960
- // assert(id != 4 )
959
+ // assert(id != 3 )
961
960
962
- description = i " elements subsumed by $owningCap "
961
+ description = i " of elements subsumed by a fresh cap in $initialOwner "
963
962
964
963
private def aliasRef : FreshCap | Null =
965
964
if myElems.size == 1 then
Original file line number Diff line number Diff line change
1
+ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scope-extrude-mut.scala:9:8 ------------------------------
2
+ 9 | a = a1 // error
3
+ | ^^
4
+ | Found: A^{a1.rd}
5
+ | Required: A^
6
+ |
7
+ | where: ^ refers to a fresh root capability in the type of variable a
8
+ |
9
+ | longer explanation available when compiling with `-explain`
Original file line number Diff line number Diff line change
1
+ import language .experimental .captureChecking
2
+
3
+ class A extends caps.Mutable
4
+
5
+ class B :
6
+ private var a : A ^ = A ()
7
+ def b () =
8
+ val a1 = A ()
9
+ a = a1 // error
You can’t perform that action at this time.
0 commit comments