Skip to content

Fix rendering ThisType #15440

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

Merged
merged 1 commit into from
Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion scaladoc-testcases/src/tests/typesSignatures.scala
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,9 @@ class Operators

import scala.compiletime.ops.boolean.*
type Unary = ![true]
}
}

trait ThisTypeTest
{
def foo: this.type //expected: def foo: ThisTypeTest.this.type
}
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ trait ClassLikeSupport:
val overriddenSyms = methodSymbol.allOverriddenSymbols.map(_.owner)
Origin.Overrides(overriddenSyms.map(s => Overridden(s.name, s.dri)).toSeq)

mkMember(methodSymbol, methodKind, memberInfo.res.asSignature)(origin = origin, deprecated = methodSymbol.isDeprecated())
mkMember(methodSymbol, methodKind, method.returnTpt.tpe.asSignature)(origin = origin, deprecated = methodSymbol.isDeprecated())

def mkParameter(
argument: ValDef,
Expand Down
12 changes: 9 additions & 3 deletions scaladoc/src/dotty/tools/scaladoc/tasty/TypesSupport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ trait TypesSupport:
import reflect._
tpeTree match
case TypeBoundsTree(low, high) => typeBoundsTreeOfHigherKindedType(low.tpe, high.tpe)
case tpeTree: TypeTree => inner(tpeTree.tpe)
case term: Term => inner(term.tpe)
case tpeTree: TypeTree => topLevelProcess(tpeTree.tpe)
case term: Term => topLevelProcess(term.tpe)

given TypeSyntax: AnyRef with
extension (using Quotes)(tpe: reflect.TypeRepr)
def asSignature: SSignature = inner(tpe)
def asSignature: SSignature = topLevelProcess(tpe)


private def plain(str: String): SignaturePart = Plain(str)
Expand Down Expand Up @@ -86,6 +86,12 @@ trait TypesSupport:
case _ => false
case _ => false

private def topLevelProcess(using Quotes)(tp: reflect.TypeRepr): SSignature =
import reflect._
tp match
case ThisType(tpe) => inner(tpe) :+ plain(".this.type")
case tpe => inner(tpe)

// TODO #23 add support for all types signatures that makes sense
private def inner(using Quotes)(tp: reflect.TypeRepr)(using indent: Int = 0): SSignature =
import reflect._
Expand Down