File tree Expand file tree Collapse file tree 4 files changed +15
-14
lines changed
compiler/src/dotty/tools/dotc/cc
tests/neg-custom-args/captures Expand file tree Collapse file tree 4 files changed +15
-14
lines changed Original file line number Diff line number Diff line change @@ -231,7 +231,11 @@ extension (cls: ClassSymbol)
231231 && bc.givenSelfType.dealiasKeepAnnots.match
232232 case CapturingType (_, refs) => refs.isAlwaysEmpty
233233 case RetainingType (_, refs) => refs.isEmpty
234- case selfType => selfType.exists && selfType.captureSet.isAlwaysEmpty
234+ case selfType =>
235+ isCaptureChecking // At Setup we have not processed self types yet, so
236+ // unless a self type is explicitly given, we can't tell
237+ // and err on the side of impure.
238+ && selfType.exists && selfType.captureSet.isAlwaysEmpty
235239
236240extension (sym : Symbol )
237241
Original file line number Diff line number Diff line change 66-- Error: tests/neg-custom-args/captures/exception-definitions.scala:7:12 ----------------------------------------------
777 | val x = c // error
88 | ^
9- |(c : Any^) cannot be referenced here; it is not included in the allowed capture set {} of pure base class class Throwable
10- -- Error: tests/neg-custom-args/captures/exception-definitions.scala:8:8 - ----------------------------------------------
9+ |(c : Any^) cannot be referenced here; it is not included in the allowed capture set {} of the self type of class Err2
10+ -- Error: tests/neg-custom-args/captures/exception-definitions.scala:8:13 ----------------------------------------------
11118 | class Err3(c: Any^) extends Exception // error
12- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^
13- | reference (Err3.this.c : Any^) is not included in the allowed capture set {} of pure base class class Throwable
12+ | ^
13+ | reference (Err3.this.c : Any^) is not included in the allowed capture set {} of the self type of class Err3
Original file line number Diff line number Diff line change 2214 | () => () => io // error
33 | ^^
44 |(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`
5+ -- Error: tests/neg-custom-args/captures/leaked-curried.scala:17:20 ----------------------------------------------------
6+ 17 | () => () => io // error
7+ | ^^
8+ |(io : Cap^) cannot be referenced here; it is not included in the allowed capture set {} of the self type of class Foo
Original file line number Diff line number Diff line change @@ -12,8 +12,8 @@ def main(): Unit =
1212 self =>
1313 val get : () -> {} () -> {io} Cap ^ =
1414 () => () => io // error
15- class Foo extends Box , Pure : // error
15+ class Foo extends Box , Pure :
1616 val get : () -> {} () -> {io} Cap ^ =
17- () => () => io
17+ () => () => io // error
1818 new Foo
1919 val bad = leaked.get()().use() // using a leaked capability
You can’t perform that action at this time.
0 commit comments