Skip to content

Commit

Permalink
Merge pull request #13436 from pikinier20/scaladoc/snippet-compiler-p…
Browse files Browse the repository at this point in the history
…rinter-fix

Scaladoc: Fix printing refined self-types in snippet-compiler
  • Loading branch information
pikinier20 committed Sep 6, 2021
2 parents a82a1a6 + 42cbbf9 commit d519682
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions scaladoc/src/dotty/tools/scaladoc/snippets/SelfTypePrinter.scala
Expand Up @@ -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) =>
Expand Down

0 comments on commit d519682

Please sign in to comment.