Skip to content

Commit 80e6d50

Browse files
bracevacnatsukagami
authored andcommitted
Enable rendering of update methods
1 parent 23164bc commit 80e6d50

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

local/project/dummy/sep-pairs.scala

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package dummy
2+
import language.experimental.captureChecking
3+
import caps.Mutable
4+
import caps.{cap, consume, use}
5+
6+
class Ref extends Mutable:
7+
var x = 0
8+
def get: Int = x
9+
update def put(y: Int): Unit = x = y
10+
11+
case class Pair[+A, +B](fst: A, snd: B)
12+
13+
def mkPair: Pair[Ref^, Ref^] =
14+
val r1 = Ref()
15+
val r2 = Ref()
16+
val p_exact: Pair[Ref^{r1}, Ref^{r2}] = Pair(r1, r2)
17+
p_exact
18+
19+
def copyPair(@consume @use p: Pair[Ref^, Ref^]): Pair[Ref^, Ref^] =
20+
val x: Ref^{p.fst*} = p.fst
21+
val y: Ref^{p.snd*} = p.snd
22+
Pair(x, y)
23+

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ enum Modifier(val name: String, val prefix: Boolean):
4444
case Transparent extends Modifier("transparent", true)
4545
case Infix extends Modifier("infix", true)
4646
case AbsOverride extends Modifier("abstract override", true)
47-
case Mut extends Modifier("mut", true)
47+
case Update extends Modifier("update", true)
4848

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

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,8 +527,11 @@ trait ClassLikeSupport:
527527
.filterNot(m => m == Modifier.Lazy || m == Modifier.Final)
528528
case _ => symbol.getExtraModifiers()
529529

530-
mkMember(symbol, kind, sig)(
531-
modifiers = modifiers,
530+
mkMember(valDef.symbol, kind, sig)(
531+
// Due to how capture checking encodes update methods (recycling the mutable flag for methods),
532+
// we need to filter out the update modifier here. Otherwise, mutable fields will
533+
// be documented as having the update modifier, which is not correct.
534+
modifiers = modifiers.filterNot(_ == Modifier.Update),
532535
deprecated = symbol.isDeprecated(),
533536
experimental = symbol.isExperimental()
534537
)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ object SymOps:
100100
Flags.Case -> Modifier.Case,
101101
Flags.Opaque -> Modifier.Opaque,
102102
Flags.AbsOverride -> Modifier.AbsOverride,
103+
Flags.Mutable -> Modifier.Update, // under CC
103104
).collect {
104105
case (flag, mod) if sym.flags.is(flag) => mod
105106
}

0 commit comments

Comments
 (0)