File tree Expand file tree Collapse file tree 3 files changed +21
-3
lines changed
compiler/src/dotty/tools/dotc/cc
tests/neg-custom-args/captures Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -1031,7 +1031,13 @@ object Capabilities:
1031
1031
override def mapCapability (c : Capability , deep : Boolean ) = c match
1032
1032
case c @ ResultCap (binder) =>
1033
1033
if localBinders.contains(binder) then c // keep bound references
1034
- else seen.getOrElseUpdate(c, FreshCap (origin)) // map free references to FreshCap
1034
+ else
1035
+ // Create a fresh skolem that does not subsume anything
1036
+ def freshSkolem =
1037
+ val c = FreshCap (origin)
1038
+ c.hiddenSet.markSolved(provisional = false )
1039
+ c
1040
+ seen.getOrElseUpdate(c, freshSkolem) // map free references to FreshCap
1035
1041
case _ => super .mapCapability(c, deep)
1036
1042
end subst
1037
1043
Original file line number Diff line number Diff line change @@ -1206,6 +1206,7 @@ object CaptureSet:
1206
1206
if alias ne this then alias.add(elem)
1207
1207
else
1208
1208
def addToElems () =
1209
+ assert(! isConst)
1209
1210
includeElem(elem)
1210
1211
deps.foreach: dep =>
1211
1212
assert(dep != this )
@@ -1378,8 +1379,10 @@ object CaptureSet:
1378
1379
* but the special state VarState.Separate overrides this.
1379
1380
*/
1380
1381
def addHidden (hidden : HiddenSet , elem : Capability )(using Context ): Boolean =
1381
- hidden.add(elem)(using ctx, this )
1382
- true
1382
+ if hidden.isConst then false
1383
+ else
1384
+ hidden.add(elem)(using ctx, this )
1385
+ true
1383
1386
1384
1387
/** If root1 and root2 belong to the same binder but have different originalBinders
1385
1388
* it means that one of the roots was mapped to the binder of the other by a
Original file line number Diff line number Diff line change
1
+ class B
2
+
3
+ def Test (consume b1 : B ^ , consume b2 : B ^ ) =
4
+ def f (): B ^ = B ()
5
+ var x : B ^ = f()
6
+ x = b1 // error separation but should be OK, see #23889
7
+ var y = f()
8
+ y = b2 // error
9
+
You can’t perform that action at this time.
0 commit comments