File tree Expand file tree Collapse file tree 4 files changed +21
-9
lines changed
compiler/src/dotty/tools/dotc/cc
tests/neg-custom-args/captures Expand file tree Collapse file tree 4 files changed +21
-9
lines changed Original file line number Diff line number Diff line change @@ -256,10 +256,11 @@ 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
260- case CapturingType (_, refs) => refs.isAlwaysEmpty
261- case RetainingType (_, refs) => refs.isEmpty
262- case selfType => selfType.exists && selfType.captureSet.isAlwaysEmpty
259+ || bc.is(CaptureChecked )
260+ && bc.givenSelfType.dealiasKeepAnnots.match
261+ case CapturingType (_, refs) => refs.isAlwaysEmpty
262+ case RetainingType (_, refs) => refs.isEmpty
263+ case selfType => selfType.exists && selfType.captureSet.isAlwaysEmpty
263264
264265extension (sym : Symbol )
265266
Original file line number Diff line number Diff line change 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 Fuzz
5+ -- [E058] Type Mismatch Error: tests/neg-custom-args/captures/leaked-curried.scala:15:10 -------------------------------
6+ 15 | class Foo extends Box, Pure: // error
7+ | ^
8+ | illegal inheritance: self type Foo^{io} of class Foo does not conform to self type Pure
9+ | of parent trait Pure
10+ |
11+ | longer explanation available when compiling with `-explain`
Original file line number Diff line number Diff line change @@ -8,8 +8,12 @@ trait Box:
88
99def main (): Unit =
1010 val leaked = withCap : (io : Cap ^ ) =>
11- class Foo extends Box , Pure :
11+ class Fuzz extends Box , Pure :
12+ self =>
1213 val get : () -> {} () -> {io} Cap ^ =
1314 () => () => io // error
15+ class Foo extends Box , Pure : // error
16+ val get : () -> {} () -> {io} Cap ^ =
17+ () => () => io
1418 new Foo
1519 val bad = leaked.get()().use() // using a leaked capability
Original file line number Diff line number Diff line change 363616 | 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
You can’t perform that action at this time.
0 commit comments