Skip to content

Commit 3cf8e37

Browse files
committed
Don't add to hidden sets in mightSubsume
This required another fix to subsumes, which fixed a bug that was undetected before.
1 parent a8a51c2 commit 3cf8e37

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,9 @@ trait CaptureRef extends TypeProxy, ValueType:
158158
case _ => false
159159
case _ => false
160160

161-
def viaInfo(info: Type)(test: Type => Boolean): Boolean = info.match
161+
def viaInfo(info: Type)(test: Type => Boolean): Boolean = info.dealias match
162162
case info: SingletonCaptureRef => test(info)
163+
case CapturingType(parent, _) => viaInfo(parent)(test)
163164
case info: AndType => viaInfo(info.tp1)(test) || viaInfo(info.tp2)(test)
164165
case info: OrType => viaInfo(info.tp1)(test) && viaInfo(info.tp2)(test)
165166
case _ => false

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ sealed abstract class CaptureSet extends Showable:
214214
*/
215215
def mightAccountFor(x: CaptureRef)(using Context): Boolean =
216216
reporting.trace(i"$this mightAccountFor $x, ${x.captureSetOfInfo}?", show = true):
217-
elems.exists(_.subsumes(x)(using ctx, FrozenVarState()))
217+
elems.exists(_.subsumes(x)(using ctx, FrozenUnrecordedHiddenState))
218218
|| !x.isMaxCapability
219219
&& {
220220
val elems = x.captureSetOfInfo.elems
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-- Error: tests/neg-custom-args/captures/filevar.scala:8:6 -------------------------------------------------------------
2+
8 | var file: File^ = uninitialized // error, was OK under unsealed
3+
| ^
4+
| Mutable variable file cannot have type File^ since
5+
| that type captures the root capability `cap`.
6+
-- Warning: tests/neg-custom-args/captures/filevar.scala:11:55 ---------------------------------------------------------
7+
11 |def withFile[T](op: (l: caps.Capability) ?-> (f: File^{l}) => T): T =
8+
| ^
9+
| redundant capture: File already accounts for l.type

0 commit comments

Comments
 (0)