Skip to content

Commit e033e94

Browse files
committed
Fix isPureClass test
1 parent 759db09 commit e033e94

File tree

5 files changed

+17
-15
lines changed

5 files changed

+17
-15
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff 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

236240
extension (sym: Symbol)
237241

tests/neg-custom-args/captures/exception-definitions.check

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
-- Error: tests/neg-custom-args/captures/exception-definitions.scala:7:12 ----------------------------------------------
77
7 | 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 ----------------------------------------------
1111
8 | 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

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
14 | () => () => 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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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

tests/pos-special/stdlib/collection/mutable/ArraySeq.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ sealed abstract class ArraySeq[sealed T]
4141
with IndexedSeq[T]
4242
with IndexedSeqOps[T, ArraySeq, ArraySeq[T]]
4343
with StrictOptimizedSeqOps[T, ArraySeq, ArraySeq[T]]
44-
with Serializable {
44+
with Serializable
45+
with Pure {
4546

4647
override def iterableFactory: scala.collection.SeqFactory[ArraySeq] = ArraySeq.untagged
4748

0 commit comments

Comments
 (0)