Skip to content

Commit d519682

Browse files
authored
Merge pull request #13436 from pikinier20/scaladoc/snippet-compiler-printer-fix
Scaladoc: Fix printing refined self-types in snippet-compiler
2 parents a82a1a6 + 42cbbf9 commit d519682

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

scaladoc/src/dotty/tools/scaladoc/snippets/SelfTypePrinter.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,19 @@ import dotty.tools.dotc.ast.untpd.{MemberDef, Modifiers, PackageDef, RefTree, Te
3131

3232
class SelfTypePrinter(using _ctx: Context) extends RefinedPrinter(_ctx):
3333

34+
private def refinementChain(tp: Type): List[Type] =
35+
tp :: (tp match {
36+
case tp: RefinedType => refinementChain(tp.parent.stripTypeVar)
37+
case _ => Nil
38+
})
39+
40+
override def toText(tp: Type): Text = tp match
41+
case tp: RefinedType =>
42+
val parent :: (refined: List[RefinedType @unchecked]) =
43+
refinementChain(tp).reverse
44+
toTextLocal(parent)
45+
case tp => super.toText(tp)
46+
3447
override def toTextSingleton(tp: SingletonType): Text =
3548
tp match
3649
case ConstantType(value) =>

0 commit comments

Comments
 (0)