Skip to content

Commit 8d7a901

Browse files
committed
Patch pure base classes for FunctionN
1 parent 272d53c commit 8d7a901

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ extension (cls: ClassSymbol)
256256
def pureBaseClass(using Context): Option[Symbol] =
257257
cls.baseClasses.find: bc =>
258258
defn.pureBaseClasses.contains(bc)
259-
|| bc.givenSelfType.dealiasKeepAnnots.match
259+
|| bc.is(CaptureChecked)
260+
&& bc.givenSelfType.dealiasKeepAnnots.match
260261
case CapturingType(_, refs) => refs.isAlwaysEmpty
261262
case RetainingType(_, refs) => refs.isEmpty
262263
case selfType => selfType.exists && selfType.captureSet.isAlwaysEmpty
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
-- Error: tests/neg-custom-args/captures/leaked-curried.scala:13:20 ----------------------------------------------------
2-
13 | () => () => io // error
1+
-- Error: tests/neg-custom-args/captures/leaked-curried.scala:14:20 ----------------------------------------------------
2+
14 | () => () => io // error
33
| ^^
4-
|(io : Cap^) cannot be referenced here; it is not included in the allowed capture set {} of pure base class trait Pure
4+
|(io : Cap^) cannot be referenced here; it is not included in the allowed capture set {} of the self type of class Foo

tests/neg-custom-args/captures/leaked-curried.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ trait Box:
99
def main(): Unit =
1010
val leaked = withCap: (io: Cap^) =>
1111
class Foo extends Box, Pure:
12+
self =>
1213
val get: () ->{} () ->{io} Cap^ =
1314
() => () => io // error
1415
new Foo

tests/neg-custom-args/captures/outer-var.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
16 | var finalizeActions = collection.mutable.ListBuffer[() => Unit]() // error
3737
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3838
| Found: scala.collection.mutable.ListBuffer[box () => Unit]
39-
| Required: scala.collection.mutable.ListBuffer[box () ->? Unit]
39+
| Required: scala.collection.mutable.ListBuffer[box () ->? Unit]^?
4040
|
4141
| Note that the universal capability `cap`
4242
| cannot be included in capture set ? of variable finalizeActions

0 commit comments

Comments
 (0)