Skip to content

Commit 11c5b92

Browse files
committed
Drop remaining references to use.
1 parent 8354768 commit 11c5b92

5 files changed

Lines changed: 16 additions & 23 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ extension (sym: Symbol) {
719719
sym.is(TypeParam) && sym.info.derivesFromCapSet
720720

721721
/** `sym` or its info is annotated with `@consume`. */
722-
def isConsumeParam(using Context): Boolean =
722+
def isConsume(using Context): Boolean =
723723
sym.hasAnnotation(defn.ConsumeAnnot)
724724
|| sym.info.hasAnnotation(defn.ConsumeAnnot)
725725

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

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -571,8 +571,7 @@ class CheckCaptures extends Recheck, SymTransformer:
571571
/** Type arguments come either from a TypeApply node or from an AppliedType
572572
* which represents a trait parent in a template.
573573
* - Disallow GlobalCaps and ResultCaps in such arguments.
574-
* - If a corresponding formal type parameter is declared or implied @use,
575-
* charge the deep capture set of the argument to the environent.
574+
* - Charge the deep capture sets of arguments to capset parameters.
576575
* @param fn the type application, of type TypeApply or TypeTree
577576
* @param sym the constructor symbol (could be a method or a val or a class)
578577
* @param args the type arguments
@@ -777,9 +776,7 @@ class CheckCaptures extends Recheck, SymTransformer:
777776
res
778777

779778
/** Recheck argument against an instantiated version of `formal` where toplevel `any`
780-
* occurrences are replaced by LocalCap instances. Also, if formal parameter carries a `@use`
781-
* or @consume, charge the deep capture set of the actual argument to the environment.
782-
* TODO: Maybe not charge deep capture sets for consume?
779+
* occurrences are replaced by LocalCap instances.
783780
*/
784781
protected override def recheckArg(arg: Tree, formal: Type, pref: ParamRef, app: Apply)(using Context): Type =
785782
val meth = app.fun.symbol
@@ -791,9 +788,10 @@ class CheckCaptures extends Recheck, SymTransformer:
791788
val argType = recheck(arg, instantiatedFormal)
792789
.showing(i"recheck arg $arg vs $instantiatedFormal = $result", capt)
793790
if formal.hasAnnotation(defn.ConsumeAnnot) then
794-
// The @use and/or @consume annotation is added to `formal` when creating methods types.
791+
// The @consume annotation is added to `formal` when creating methods types.
795792
// See [[MethodTypeCompanion.adaptParamInfo]].
796-
// TODO: Needed?
793+
// We need to charge the deep capture set because to inform SepCheck which set
794+
// is consumed.
797795
capt.println(i"charging deep capture set of $arg: ${argType} = ${argType.deepCaptureSet}")
798796
markFree(argType.deepCaptureSet, arg)
799797
if formal.containsGlobalAny then
@@ -809,8 +807,7 @@ class CheckCaptures extends Recheck, SymTransformer:
809807
* ---------------------
810808
* E |- f(a): Tr^C
811809
*
812-
* If the function `f` does not have an `@use` parameter, then
813-
* any unboxing it does would be charged to the environment of the function
810+
* Any unboxing of function `f` would be charged to the environment of the function
814811
* so they have to appear in Cq. Since any capabilities of the result of the
815812
* application must already be present in the application, an upper
816813
* approximation of the result capture set is Cq \union Ca, where `Ca`
@@ -2010,8 +2007,8 @@ class CheckCaptures extends Recheck, SymTransformer:
20102007
case _ =>
20112008
actual
20122009
else
2013-
// Compute the widened type. Drop `@use` and `@consume` annotations from the type,
2014-
// since they obscures the capturing type.
2010+
// Compute the widened type. Drop `@consume` annotations from the type,
2011+
// since they obscure the capturing type.
20152012
val widened = actual.widen.dealiasKeepAnnots.dropAnnot(defn.ConsumeAnnot)
20162013
val improvedVAR = improveCaptures(widened, actual)
20172014
val adaptedReadOnly = adaptReadOnly(improvedVAR, actual, expected, tree)
@@ -2090,7 +2087,7 @@ class CheckCaptures extends Recheck, SymTransformer:
20902087

20912088
override def checkInheritedTraitParameters: Boolean = false
20922089

2093-
/** Check that overrides don't change the @use, @consume, or @reserve status of their parameters */
2090+
/** Check that overrides don't change the @consume status of their parameters */
20942091
override def additionalChecks(member: Symbol, other: Symbol)(using Context): Unit =
20952092
for
20962093
(params1, params2) <- member.rawParamss.lazyZip(other.rawParamss)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ class SepCheck(checker: CheckCaptures.CheckerAPI) extends tpd.TreeTraverser:
695695
if currentOwner.enclosingMethodOrClassOrObject.isProperlyContainedIn(refSym.enclosingMethodOrClassOrObject) then
696696
report.error(em"""Separation failure: $descr non-local $refSym""", pos)
697697
else if refSym.is(TermParam)
698-
&& !refSym.isConsumeParam
698+
&& !refSym.isConsume
699699
&& currentOwner.isContainedIn(refSym.owner)
700700
then
701701
badParams += refSym
@@ -1052,7 +1052,7 @@ class SepCheck(checker: CheckCaptures.CheckerAPI) extends tpd.TreeTraverser:
10521052
if !isUnsafeAssumeSeparate(tree) then trace(i"checking separate $tree"):
10531053
checkUse(tree)
10541054
tree match
1055-
case tree @ Select(qual, _) if tree.symbol.is(Method) && tree.symbol.isConsumeParam =>
1055+
case tree @ Select(qual, _) if tree.symbol.is(Method) && tree.symbol.isConsume =>
10561056
traverseChildren(tree)
10571057
checkConsumedRefs(
10581058
spanCaptures(qual).directFootprint.nonPeaks, qual.nuType,

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -864,9 +864,8 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
864864
case _ =>
865865
end postProcess
866866

867-
/** Check that @use and @consume annotations only appear on parameters and not on
868-
* anonymous function parameters. Check that @use annotations don't appear
869-
* at all from 3.8 on.
867+
/** Check that @consume annotations only appear on parameters and not on
868+
* anonymous function parameters.
870869
*/
871870
def checkProperConsume(tree: Tree)(using Context): Unit = tree match
872871
case tree: MemberDef =>
@@ -884,6 +883,7 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
884883
|can have a consume modifier.""",
885884
tree.srcPos)
886885
case _ =>
886+
887887
end setupTraverser
888888

889889
// --------------- Adding capture set variables ----------------------------------

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import config.{Feature, SourceVersion}
77

88
object ccConfig:
99

10-
/** If enabled, cache capture sets of infos capabilities */
10+
/** If enabled, cache capture sets of infos of capabilities */
1111
inline val cacheCaptureSetOfInfo = false
1212

1313
/** If this and `preTypeClosureResults` are both enabled, disable `preTypeClosureResults`
@@ -50,10 +50,6 @@ object ccConfig:
5050
def newScheme(using ctx: Context): Boolean =
5151
Feature.sourceVersion.stable.isAtLeast(SourceVersion.`3.10`)
5252

53-
/** Allow @use annotations */
54-
def allowUse(using Context): Boolean =
55-
Feature.sourceVersion.stable.isAtMost(SourceVersion.`3.7`)
56-
5753
/** Treat arrays as mutable types and force all mutable fields to be in Stateful
5854
* classes, unless they are annotated with @untrackedCaptures.
5955
* Enabled under separation checking

0 commit comments

Comments
 (0)