Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scaladoc: Fix printing refined self-types in snippet-compiler #13436

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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