Skip to content

Commit 07e9bda

Browse files
bracevacnatsukagami
authored andcommitted
Fix rendering of capture members
1 parent c9a16b1 commit 07e9bda

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
@@ -495,7 +495,12 @@ trait ClassLikeSupport:
495495
case LambdaTypeTree(params, body) => (params.map(mkTypeArgument(_, classDef)), body)
496496
case tpe => (Nil, tpe)
497497

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

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)