Skip to content

Commit 58bc4da

Browse files
committed
Use explicit args in recursion
1 parent 83f2a61 commit 58bc4da

File tree

1 file changed

+29
-15
lines changed

1 file changed

+29
-15
lines changed

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

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ trait TypesSupport:
8181
case tpe => inner(tpe, skipThisTypePrefix)
8282

8383
// TODO #23 add support for all types signatures that make sense
84-
@nowarn("id=E219")
8584
private def inner(
8685
using Quotes,
8786
)(
@@ -158,24 +157,25 @@ trait TypesSupport:
158157
.reduceLeftOption((acc: SSignature, elem: SSignature) => acc ++ plain(", ").l ++ elem).getOrElse(List())
159158
++ plain(")").l
160159

161-
def parseRefinedElem(name: String, info: TypeRepr, polyTyped: SSignature = Nil): SSignature = ( info match {
160+
def parseRefinedElem(name: String, info: TypeRepr, polyTyped: SSignature = Nil): SSignature =
161+
val ssig = info match
162162
case m: MethodType => {
163163
val paramList = getParamList(m)
164164
keyword("def ").l ++ plain(name).l ++ polyTyped ++ paramList ++ plain(": ").l ++ inner(m.resType, skipThisTypePrefix)
165165
}
166-
case t: PolyType => {
166+
case t: PolyType =>
167167
val paramBounds = getParamBounds(t)
168-
val parsedMethod = parseRefinedElem(name, t.resType)
169-
if (!paramBounds.isEmpty){
168+
if !paramBounds.isEmpty then
170169
parseRefinedElem(name, t.resType, plain("[").l ++ paramBounds ++ plain("]").l)
171-
} else parseRefinedElem(name, t.resType)
172-
}
170+
else
171+
parseRefinedElem(name, t.resType, polyTyped = Nil)
173172
case ByNameType(tp) => keyword("def ").l ++ plain(s"$name: ").l ++ inner(tp, skipThisTypePrefix)
174173
case t: TypeBounds => keyword("type ").l ++ plain(name).l ++ inner(t, skipThisTypePrefix)
175174
case t: TypeRef => keyword("val ").l ++ plain(s"$name: ").l ++ inner(t, skipThisTypePrefix)
176175
case t: TermRef => keyword("val ").l ++ plain(s"$name: ").l ++ inner(t, skipThisTypePrefix)
177176
case other => noSupported(s"Not supported type in refinement $info")
178-
} ) ++ plain("; ").l
177+
178+
ssig ++ plain("; ").l
179179

180180
def parsePolyFunction(info: TypeRepr): SSignature = info match {
181181
case t: PolyType =>
@@ -256,6 +256,7 @@ trait TypesSupport:
256256
}) ++ plain("]").l
257257

258258
case tp @ TypeRef(qual, typeName) =>
259+
inline def wrapping = shouldWrapInParens(inner = qual, outer = tp, isLeft = true)
259260
qual match {
260261
case r: RecursiveThis => tpe(s"this.$typeName").l
261262
case ThisType(tr) =>
@@ -272,23 +273,28 @@ trait TypesSupport:
272273
if skipPrefix(qual, elideThis, originalOwner, skipThisTypePrefix) then
273274
tpe(tp.typeSymbol)
274275
else
275-
val sig = inParens(inner(qual, skipThisTypePrefix)(using skipTypeSuffix = true), shouldWrapInParens(qual, tp, true))
276-
sig ++ plain(".").l ++ tpe(tp.typeSymbol)
276+
val sig = inParens(
277+
inner(qual, skipThisTypePrefix)(using indent = indent, skipTypeSuffix = true), wrapping)
278+
sig
279+
++ plain(".").l
280+
++ tpe(tp.typeSymbol)
277281

278282
case t if skipPrefix(t, elideThis, originalOwner, skipThisTypePrefix) =>
279283
tpe(tp.typeSymbol)
280284
case _: TermRef | _: ParamRef =>
281285
val suffix = if tp.typeSymbol == Symbol.noSymbol then tpe(typeName).l else tpe(tp.typeSymbol)
282-
inner(qual, skipThisTypePrefix)(using skipTypeSuffix = true) ++ plain(".").l ++ suffix
286+
inner(qual, skipThisTypePrefix)(using indent = indent, skipTypeSuffix = true)
287+
++ plain(".").l
288+
++ suffix
283289
case _ =>
284-
val sig = inParens(inner(qual, skipThisTypePrefix), shouldWrapInParens(qual, tp, true))
290+
val sig = inParens(inner(qual, skipThisTypePrefix), wrapping)
285291
sig ++ keyword("#").l ++ tpe(tp.typeSymbol)
286292
}
287293

288294
case tr @ TermRef(qual, typeName) =>
289295
val prefix = qual match
290296
case t if skipPrefix(t, elideThis, originalOwner, skipThisTypePrefix) => Nil
291-
case tp => inner(tp, skipThisTypePrefix)(using skipTypeSuffix = true) ++ plain(".").l
297+
case tp => inner(tp, skipThisTypePrefix)(using indent = indent, skipTypeSuffix = true) ++ plain(".").l
292298
val suffix = if skipTypeSuffix then Nil else List(plain("."), keyword("type"))
293299
val typeSig = tr.termSymbol.tree match
294300
case vd: ValDef if tr.termSymbol.flags.is(Flags.Module) =>
@@ -307,9 +313,17 @@ trait TypesSupport:
307313
val spaces = " " * (indent)
308314
val casesTexts = cases.flatMap {
309315
case MatchCase(from, to) =>
310-
keyword(caseSpaces + "case ").l ++ inner(from, skipThisTypePrefix) ++ keyword(" => ").l ++ inner(to, skipThisTypePrefix)(using indent = indent + 2) ++ plain("\n").l
316+
keyword(caseSpaces + "case ").l
317+
++ inner(from, skipThisTypePrefix)
318+
++ keyword(" => ").l
319+
++ inner(to, skipThisTypePrefix)(using indent = indent + 2, skipTypeSuffix = skipTypeSuffix)
320+
++ plain("\n").l
311321
case TypeLambda(_, _, MatchCase(from, to)) =>
312-
keyword(caseSpaces + "case ").l ++ inner(from, skipThisTypePrefix) ++ keyword(" => ").l ++ inner(to, skipThisTypePrefix)(using indent = indent + 2) ++ plain("\n").l
322+
keyword(caseSpaces + "case ").l
323+
++ inner(from, skipThisTypePrefix)
324+
++ keyword(" => ").l
325+
++ inner(to, skipThisTypePrefix)(using indent = indent + 2, skipTypeSuffix = skipTypeSuffix)
326+
++ plain("\n").l
313327
}
314328
inner(sc, skipThisTypePrefix) ++ keyword(" match ").l ++ plain("{\n").l ++ casesTexts ++ plain(spaces + "}").l
315329

0 commit comments

Comments
 (0)