Skip to content

Commit 42c3676

Browse files
committed
Drop PostCapture
Instead narrow extractor for capturing types to yield results only at phase cc.
1 parent 22c1209 commit 42c3676

File tree

4 files changed

+25
-53
lines changed

4 files changed

+25
-53
lines changed

compiler/src/dotty/tools/dotc/Compiler.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ class Compiler {
8787
new StringInterpolatorOpt) :: // Optimizes raw and s string interpolators by rewriting them to string concatenations
8888
List(new PreRecheck) :: // Preparations for check captures phase, enabled under -Ycc
8989
List(new CheckCaptures) :: // Check captures, enabled under -Ycc
90-
List(new PostCapture) :: // Reset denotations transformed by CheckCaptures back to annotated types
9190
List(new PruneErasedDefs, // Drop erased definitions from scopes and simplify erased expressions
9291
new UninitializedDefs, // Replaces `compiletime.uninitialized` by `_`
9392
new InlinePatterns, // Remove placeholders of inlined patterns

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@ object CapturingType:
1111
if refs.isAlwaysEmpty then parent
1212
else AnnotatedType(parent, CaptureAnnotation(refs))
1313

14-
def unapply(tp: AnnotatedType)(using Context) = tp.annot match
15-
case ann: CaptureAnnotation =>
16-
Some((tp.parent, ann.refs))
17-
case ann =>
18-
if ann.symbol == defn.RetainsAnnot && ctx.phase == Phases.checkCapturesPhase
19-
then Some((tp.parent, ann.tree.toCaptureSet))
20-
else None
14+
def unapply(tp: AnnotatedType)(using Context) =
15+
if ctx.phase == Phases.checkCapturesPhase && tp.annot.symbol == defn.RetainsAnnot then
16+
tp.annot match
17+
case ann: CaptureAnnotation => Some((tp.parent, ann.refs))
18+
case ann => Some((tp.parent, ann.tree.toCaptureSet))
19+
else None
2120

2221
end CapturingType
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package dotty.tools.dotc
2+
package transform
3+
4+
import core.*
5+
import Contexts.Context
6+
import Phases.Phase
7+
8+
/** A phase that can be inserted directly after a phase that cannot
9+
* be checked, to enable a -Ycheck as soon as possible afterwards
10+
*/
11+
class EmptyPhase extends Phase:
12+
13+
def phaseName: String = "dummy"
14+
15+
override def isEnabled(using Context) = prev.isEnabled
16+
17+
override def run(using Context) = ()
18+
19+
end EmptyPhase

compiler/src/dotty/tools/dotc/transform/PostCapture.scala

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)