@@ -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)
0 commit comments