Skip to content

Commit 7b50cf8

Browse files
committed
Fix rendering of capture members
1 parent 0af8460 commit 7b50cf8

File tree

5 files changed

+12
-4
lines changed

5 files changed

+12
-4
lines changed

local/project/dummy/capturevars.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ trait Test:
1414
type D^ >: {C} <: {a,b}
1515
type E^ <: C
1616
type F^ <: {D,E}
17+
type G^ = C
1718
def foo[C^ >: {a,b}](x: T[C]): Unit
1819
def bar(x: T[{a,b}]): Unit
1920
def baz(x: T[{a,b,caps.cap}]): Unit

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ enum Kind(val name: String):
7070
case Var extends Kind("var")
7171
case Val extends Kind("val")
7272
case Exported(base: Kind) extends Kind("export")
73-
case Type(concreate: Boolean, opaque: Boolean, typeParams: Seq[TypeParameter])
73+
case Type(concreate: Boolean, opaque: Boolean, typeParams: Seq[TypeParameter], isCaptureVar: Boolean = false)
7474
extends Kind("type") // should we handle opaque as modifier?
7575
case Given(kind: Def | Class | Val.type, as: Option[Signature], conversion: Option[ImplicitConversion])
7676
extends Kind("given") with ImplicitConversionProvider

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,12 @@ trait ClassLikeSupport:
492492
case LambdaTypeTree(params, body) => (params.map(mkTypeArgument(_, classDef)), body)
493493
case tpe => (Nil, tpe)
494494

495-
val defaultKind = Kind.Type(!isTreeAbstract(typeDef.rhs), typeDef.symbol.isOpaque, generics).asInstanceOf[Kind.Type]
495+
val isCaptureVar = ccEnabled && typeDef.rhs.match
496+
case t: TypeTree => t.tpe.derivesFrom(CaptureDefs.Caps_CapSet)
497+
case t: TypeBoundsTree => t.tpe.derivesFrom(CaptureDefs.Caps_CapSet)
498+
case _ => false
499+
500+
val defaultKind = Kind.Type(!isTreeAbstract(typeDef.rhs), typeDef.symbol.isOpaque, generics, isCaptureVar).asInstanceOf[Kind.Type]
496501
val kind = if typeDef.symbol.flags.is(Flags.Enum) then Kind.EnumCase(defaultKind)
497502
else defaultKind
498503

scaladoc/src/dotty/tools/scaladoc/translators/ScalaSignatureProvider.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class ScalaSignatureProvider:
149149
MemberSignature(
150150
builder.modifiersAndVisibility(typeDef),
151151
builder.kind(tpe),
152-
builder.name(typeDef.name, typeDef.dri),
152+
builder.name(typeDef.name, typeDef.dri, isCaptureVar = tpe.isCaptureVar),
153153
builder.typeParamList(tpe.typeParams).pipe { bdr =>
154154
if (!tpe.opaque) {
155155
(if tpe.concreate then bdr.plain(" = ") else bdr)

scaladoc/src/dotty/tools/scaladoc/translators/ScalaSignatureUtils.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ package translators
33

44
case class SignatureBuilder(content: Signature = Nil) extends ScalaSignatureUtils:
55
def plain(str: String): SignatureBuilder = copy(content = content :+ Plain(str))
6-
def name(str: String, dri: DRI): SignatureBuilder = copy(content = content :+ Name(str, dri))
6+
def name(str: String, dri: DRI, isCaptureVar: Boolean = false/*under CC*/): SignatureBuilder =
7+
val suffix = if isCaptureVar then List(Keyword("^")) else Nil
8+
copy(content = content ++ (Name(str, dri) :: suffix))
79
def tpe(text: String, dri: Option[DRI]): SignatureBuilder = copy(content = content :+ Type(text, dri))
810
def keyword(str: String): SignatureBuilder = copy(content = content :+ Keyword(str))
911
def tpe(text: String, dri: DRI): SignatureBuilder = copy(content = content :+ Type(text, Some(dri)))

0 commit comments

Comments
 (0)