Skip to content

Commit effba5c

Browse files
committed
Use more RetainingAnnotation tests where it makes sense
1 parent e648b42 commit effba5c

File tree

4 files changed

+5
-9
lines changed

4 files changed

+5
-9
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ import config.Feature
1919
import NameKinds.TryOwnerName
2020
import typer.ProtoTypes.WildcardSelectionProto
2121

22-
/** Attachment key for capturing type trees */
23-
private val Captures: Key[CaptureSet] = Key()
24-
2522
/** Are we at checkCaptures phase? */
2623
def isCaptureChecking(using Context): Boolean =
2724
ctx.phaseId == Phases.checkCapturesPhaseId
@@ -661,7 +658,7 @@ class PathSelectionProto(val select: Select, val pt: Type) extends typer.ProtoTy
661658
*/
662659
class CleanupRetains(using Context) extends TypeMap:
663660
def apply(tp: Type): Type = tp match
664-
case AnnotatedType(parent, annot) if annot.symbol.isRetainsLike =>
661+
case AnnotatedType(parent, annot: RetainingAnnotation) =>
665662
if Feature.ccEnabled then
666663
if annot.symbol == defn.RetainsAnnot || annot.symbol == defn.RetainsByNameAnnot then
667664
RetainingType(parent, defn.NothingType, byName = annot.symbol == defn.RetainsByNameAnnot)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import collection.mutable
2424
import ProtoTypes.*
2525
import staging.StagingLevel
2626
import inlines.Inlines.inInlineMethod
27-
import cc.{isRetainsLike, CaptureAnnotation}
27+
import cc.RetainingAnnotation
2828

2929
import dotty.tools.backend.jvm.DottyBackendInterface.symExtensions
3030

@@ -187,7 +187,7 @@ object TreeChecker {
187187
case tp: TypeVar =>
188188
assert(tp.isInstantiated, s"Uninstantiated type variable: ${tp.show}, tree = ${tree.show}")
189189
apply(tp.underlying)
190-
case tp @ AnnotatedType(underlying, annot) if annot.symbol.isRetainsLike && !annot.isInstanceOf[CaptureAnnotation] =>
190+
case tp @ AnnotatedType(underlying, annot: RetainingAnnotation) =>
191191
val underlying1 = this(underlying)
192192
val annot1 = insideRetainingAnnot:
193193
annot.mapWith(this)

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ import annotation.threadUnsafe
3939

4040
import scala.annotation.tailrec
4141
import scala.util.control.NonFatal
42-
import dotty.tools.dotc.cc.isRetains
4342

4443
object Applications {
4544
import tpd.*

compiler/src/dotty/tools/dotc/typer/Checking.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import config.Feature, Feature.{sourceVersion, modularity}
3737
import config.SourceVersion.*
3838
import config.MigrationVersion
3939
import printing.Formatting.hlAsKeyword
40-
import cc.{isCaptureChecking, isRetainsLike}
40+
import cc.{isCaptureChecking, RetainingAnnotation}
4141
import cc.Mutability.isUpdateMethod
4242

4343
import collection.mutable
@@ -815,7 +815,7 @@ object Checking {
815815
declaredParents =
816816
tp.declaredParents.map(p => transformedParent(apply(p)))
817817
)
818-
case tp @ AnnotatedType(underlying, annot) if annot.symbol.isRetainsLike =>
818+
case tp @ AnnotatedType(underlying, annot: RetainingAnnotation) =>
819819
val underlying1 = this(underlying)
820820
val saved = inCaptureSet
821821
inCaptureSet = true

0 commit comments

Comments
 (0)