Skip to content

Commit 9af8000

Browse files
committed
Use more RetainingAnnotation tests where it makes sense
1 parent 5aecad7 commit 9af8000

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ class PathSelectionProto(val select: Select, val pt: Type) extends typer.ProtoTy
661661
*/
662662
class CleanupRetains(using Context) extends TypeMap:
663663
def apply(tp: Type): Type = tp match
664-
case AnnotatedType(parent, annot) if annot.symbol.isRetainsLike =>
664+
case AnnotatedType(parent, annot: RetainingAnnotation) =>
665665
if Feature.ccEnabled then
666666
if annot.symbol == defn.RetainsAnnot || annot.symbol == defn.RetainsByNameAnnot then
667667
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: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import Nullables.*, NullOpsDecorator.*
2626
import config.{Feature, MigrationVersion, SourceVersion}
2727
import util.Property
2828
import util.chaining.tap
29+
import inlines.Inlines
2930

3031
import collection.mutable
3132
import config.Printers.{overload, typr, unapp}
@@ -38,8 +39,6 @@ import annotation.threadUnsafe
3839

3940
import scala.annotation.tailrec
4041
import scala.util.control.NonFatal
41-
import dotty.tools.dotc.cc.isRetains
42-
import dotty.tools.dotc.inlines.Inlines
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)