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)
256
256
def pureBaseClass (using Context ): Option [Symbol ] =
257
257
cls.baseClasses.find: bc =>
258
258
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
263
264
264
265
extension (sym : Symbol )
265
266
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
3
3
| ^^
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:
8
8
9
9
def main (): Unit =
10
10
val leaked = withCap : (io : Cap ^ ) =>
11
- class Foo extends Box , Pure :
11
+ class Fuzz extends Box , Pure :
12
+ self =>
12
13
val get : () -> {} () -> {io} Cap ^ =
13
14
() => () => io // error
15
+ class Foo extends Box , Pure : // error
16
+ val get : () -> {} () -> {io} Cap ^ =
17
+ () => () => io
14
18
new Foo
15
19
val bad = leaked.get()().use() // using a leaked capability
Original file line number Diff line number Diff line change 36
36
16 | var finalizeActions = collection.mutable.ListBuffer[() => Unit]() // error
37
37
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
38
38
| Found: scala.collection.mutable.ListBuffer[box () => Unit]
39
- | Required: scala.collection.mutable.ListBuffer[box () ->? Unit]
39
+ | Required: scala.collection.mutable.ListBuffer[box () ->? Unit]^?
40
40
|
41
41
| Note that the universal capability `cap`
42
42
| cannot be included in capture set ? of variable finalizeActions
You can’t perform that action at this time.
0 commit comments