Skip to content

Commit 42a55e2

Browse files
committed
chore: render @consume at the consume modifier
1 parent 746ebc8 commit 42a55e2

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

scaladoc/src/dotty/tools/scaladoc/api.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ enum Modifier(val name: String, val prefix: Boolean):
4545
case Infix extends Modifier("infix", true)
4646
case AbsOverride extends Modifier("abstract override", true)
4747
case Update extends Modifier("update", true)
48+
case Consume extends Modifier("consume", true)
4849

4950
case class ExtensionTarget(name: String, typeParams: Seq[TypeParameter], argsLists: Seq[TermParameterList], signature: Signature, dri: DRI, position: Long)
5051
case class ImplicitConversion(from: DRI, to: DRI)

scaladoc/src/dotty/tools/scaladoc/tasty/BasicSupport.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ trait BasicSupport:
5757
)
5858
val fqNameAllowlist =
5959
if ccEnabled then
60-
fqNameAllowlist0 + CaptureDefs.useAnnotFullName + CaptureDefs.consumeAnnotFullName
60+
fqNameAllowlist0 + CaptureDefs.useAnnotFullName
6161
else fqNameAllowlist0
6262
val documentedSymbol = summon[Quotes].reflect.Symbol.requiredClass("java.lang.annotation.Documented")
6363
val annotations = sym.annotations.filter { a =>

scaladoc/src/dotty/tools/scaladoc/tasty/ClassLikeSupport.scala

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ trait ClassLikeSupport:
2323

2424
extension (symbol: Symbol) {
2525
def getExtraModifiers(): Seq[Modifier] =
26-
val mods = SymOps.getExtraModifiers(symbol)()
27-
if ccEnabled && symbol.flags.is(Flags.Mutable)then
28-
mods :+ Modifier.Update
29-
else
30-
mods
26+
var mods = SymOps.getExtraModifiers(symbol)()
27+
if ccEnabled && symbol.flags.is(Flags.Mutable) then
28+
mods :+= Modifier.Update
29+
if ccEnabled && symbol.hasAnnotation(cc.CaptureDefs.ConsumeAnnot) then
30+
mods :+= Modifier.Consume
31+
mods
3132
}
3233

3334
private def bareClasslikeKind(using Quotes)(symbol: reflect.Symbol): Kind =
@@ -452,12 +453,13 @@ trait ClassLikeSupport:
452453
) =
453454
val symbol = argument.symbol
454455
val inlinePrefix = if symbol.flags.is(Flags.Inline) then "inline " else ""
456+
val comsumePrefix = if self.ccEnabled && symbol.hasAnnotation(cc.CaptureDefs.ConsumeAnnot) then "consume " else ""
455457
val name = symbol.normalizedName
456458
val nameIfNotSynthetic = Option.when(!symbol.flags.is(Flags.Synthetic))(name)
457459
val defaultValue = Option.when(symbol.flags.is(Flags.HasDefault))(Plain(" = ..."))
458460
api.TermParameter(
459461
symbol.getAnnotations(),
460-
inlinePrefix + prefix(symbol),
462+
comsumePrefix + inlinePrefix + prefix(symbol),
461463
nameIfNotSynthetic,
462464
symbol.dri,
463465
argument.tpt.asSignature(classDef, symbol.owner) :++ defaultValue,

0 commit comments

Comments
 (0)