Skip to content

Commit 91fdbdb

Browse files
committed
Apply requested changes
1 parent 594652f commit 91fdbdb

File tree

4 files changed

+29
-27
lines changed

4 files changed

+29
-27
lines changed

scala3doc-testcases/src/tests/hkts.scala

Lines changed: 0 additions & 6 deletions
This file was deleted.

scala3doc/src/dotty/dokka/tasty/ClassLikeSupport.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,9 @@ trait ClassLikeSupport:
337337
val memberInfo = unwrapMemberInfo(c, methodSymbol)
338338

339339
val basicKind: Kind.Def = Kind.Def(
340-
genericTypes.map(mkTypeArgument(_, Some(memberInfo.genericTypes))),
340+
genericTypes.map(mkTypeArgument(_, memberInfo.genericTypes)),
341341
paramLists.zipWithIndex.map { (pList, index) =>
342-
ParametersList(pList.map(mkParameter(_, paramPrefix, memberInfo = Some(memberInfo.paramLists(index)))), if isUsingModifier(pList) then "using " else "")
342+
ParametersList(pList.map(mkParameter(_, paramPrefix, memberInfo = memberInfo.paramLists(index))), if isUsingModifier(pList) then "using " else "")
343343
}
344344
)
345345

@@ -380,7 +380,7 @@ trait ClassLikeSupport:
380380
prefix: Symbol => String = _ => "",
381381
isExtendedSymbol: Boolean = false,
382382
isGrouped: Boolean = false,
383-
memberInfo: Option[Map[String, TypeRepr]] = None) =
383+
memberInfo: Map[String, TypeRepr] = Map.empty) =
384384
val inlinePrefix = if argument.symbol.flags.is(Flags.Inline) then "inline " else ""
385385
val nameIfNotSynthetic = Option.when(!argument.symbol.flags.is(Flags.Synthetic))(argument.symbol.normalizedName)
386386
val name = argument.symbol.normalizedName
@@ -389,12 +389,12 @@ trait ClassLikeSupport:
389389
inlinePrefix + prefix(argument.symbol),
390390
nameIfNotSynthetic,
391391
argument.symbol.dri,
392-
memberInfo.flatMap(_.get(name)).fold(argument.tpt.dokkaType.asSignature)(_.dokkaType.asSignature),
392+
memberInfo.get(name).fold(argument.tpt.dokkaType.asSignature)(_.dokkaType.asSignature),
393393
isExtendedSymbol,
394394
isGrouped
395395
)
396396

397-
def mkTypeArgument(argument: TypeDef, memberInfo: Option[Map[String, TypeBounds]] = None): TypeParameter =
397+
def mkTypeArgument(argument: TypeDef, memberInfo: Map[String, TypeBounds] = Map.empty): TypeParameter =
398398
val variancePrefix: "+" | "-" | "" =
399399
if argument.symbol.flags.is(Flags.Covariant) then "+"
400400
else if argument.symbol.flags.is(Flags.Contravariant) then "-"
@@ -405,7 +405,7 @@ trait ClassLikeSupport:
405405
variancePrefix,
406406
name,
407407
argument.symbol.dri,
408-
memberInfo.flatMap(_.get(name)).fold(argument.rhs.dokkaType.asSignature)(_.dokkaType.asSignature)
408+
memberInfo.get(name).fold(argument.rhs.dokkaType.asSignature)(_.dokkaType.asSignature)
409409
)
410410

411411
def parseTypeDef(typeDef: TypeDef): Member =

scala3doc/src/dotty/dokka/tasty/TypesSupport.scala

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,19 @@ trait TypesSupport:
6868
case List(single) => single
6969
case other => other.reduce((r, e) => r ++ texts(", ") ++ e)
7070

71-
// weird name fot type-erasure purposes
72-
private def isRepeatedTerm(term: Term) =
73-
// For some reason annotation.tpe.typeSymbol != defn.RepeatedParamClass
74-
// annotation.tpe.typeSymbol prints 'class Repeated' and defn.RepeatedParamClass prints 'class <repeated>'
75-
term.tpe.typeSymbol.toString == "class Repeated"
76-
77-
private def isRepeatedTypeRepr(typeRepr: TypeRepr) =
78-
typeRepr.typeSymbol.toString == "class <repeated>"
71+
private def isRepeatedAnnotation(term: Term) =
72+
term.tpe match
73+
case t: TypeRef => t.name == "Repeated" && t.qualifier.match
74+
case ThisType(tref: TypeRef) if tref.name == "internal" => true
75+
case _ => false
76+
case _ => false
77+
78+
private def isRepeated(typeRepr: TypeRepr) =
79+
typeRepr match
80+
case t: TypeRef => t.name == "<repeated>" && t.qualifier.match
81+
case ThisType(tref: TypeRef) if tref.name == "scala" => true
82+
case _ => false
83+
case _ => false
7984

8085
// TODO #23 add support for all types signatures that makes sense
8186
private def inner(tp: TypeRepr): List[JProjection] =
@@ -90,9 +95,9 @@ trait TypesSupport:
9095
case ConstantType(constant) =>
9196
texts(constant.show)
9297
case ThisType(tpe) => inner(tpe)
93-
case AnnotatedType(AppliedType(_, Seq(tpe)), annotation) if isRepeatedTerm(annotation) =>
98+
case AnnotatedType(AppliedType(_, Seq(tpe)), annotation) if isRepeatedAnnotation(annotation) =>
9499
inner(tpe) :+ text("*")
95-
case AppliedType(repeatedClass, Seq(tpe)) if isRepeatedTypeRepr(repeatedClass) =>
100+
case AppliedType(repeatedClass, Seq(tpe)) if isRepeated(repeatedClass) =>
96101
inner(tpe) :+ text("*")
97102
case AnnotatedType(tpe, _) =>
98103
inner(tpe)
@@ -174,10 +179,10 @@ trait TypesSupport:
174179
case Seq(rtpe) =>
175180
text("() => ") :: inner(rtpe)
176181
case Seq(arg, rtpe) =>
177-
val ar = arg match
178-
case a: ByNameType => texts("(") ++ inner(a) ++ texts(")")
179-
case o => inner(o)
180-
ar ++ texts(" => ") ++ inner(rtpe)
182+
val partOfSignature = arg match
183+
case byName: ByNameType => texts("(") ++ inner(byName) ++ texts(")")
184+
case _ => inner(arg)
185+
partOfSignature ++ texts(" => ") ++ inner(rtpe)
181186
case args =>
182187
texts("(") ++ commas(args.init.map(inner)) ++ texts(") => ") ++ inner(args.last)
183188
else if t.isTupleType then

scala3doc/test/dotty/dokka/SignatureTest.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ abstract class SignatureTest(
9898
case unexpectedRegex(signature) => findName(signature, kinds).map(Unexpected(_))
9999
case expectedRegex(signature) => findName(signature, kinds).map(Expected(_, signature))
100100
case signature =>
101-
findName(signature, kinds).map(Expected(_, commentRegex.replaceAllIn(signature, "").compactWhitespaces.reverse.dropWhile(List('{', ':').contains(_)).reverse))
101+
findName(signature, kinds).map(
102+
Expected(_, commentRegex.replaceAllIn(signature, "")
103+
.compactWhitespaces.reverse.dropWhile(List('{', ':').contains(_)).reverse)
104+
)
102105
}
103106

104107
private def signaturesFromDocumentation(root: PageNode)(using DocContext): Seq[String] =

0 commit comments

Comments
 (0)