From 42cbbf9b3f8ba48ba7609246f56ec06c81e42145 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Zyba=C5=82a?= Date: Wed, 1 Sep 2021 10:13:11 +0200 Subject: [PATCH] Fix printing refined self-types --- .../tools/scaladoc/snippets/SelfTypePrinter.scala | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/scaladoc/src/dotty/tools/scaladoc/snippets/SelfTypePrinter.scala b/scaladoc/src/dotty/tools/scaladoc/snippets/SelfTypePrinter.scala index 1f51a29243a2..9a12a1e93dcc 100644 --- a/scaladoc/src/dotty/tools/scaladoc/snippets/SelfTypePrinter.scala +++ b/scaladoc/src/dotty/tools/scaladoc/snippets/SelfTypePrinter.scala @@ -31,6 +31,19 @@ import dotty.tools.dotc.ast.untpd.{MemberDef, Modifiers, PackageDef, RefTree, Te class SelfTypePrinter(using _ctx: Context) extends RefinedPrinter(_ctx): + private def refinementChain(tp: Type): List[Type] = + tp :: (tp match { + case tp: RefinedType => refinementChain(tp.parent.stripTypeVar) + case _ => Nil + }) + + override def toText(tp: Type): Text = tp match + case tp: RefinedType => + val parent :: (refined: List[RefinedType @unchecked]) = + refinementChain(tp).reverse + toTextLocal(parent) + case tp => super.toText(tp) + override def toTextSingleton(tp: SingletonType): Text = tp match case ConstantType(value) =>