Skip to content

Commit 741587d

Browse files
authored
Merge pull request #15440 from dotty-staging/scaladoc/this-type
Fix rendering ThisType
2 parents 944f540 + 8f34b07 commit 741587d

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

scaladoc-testcases/src/tests/typesSignatures.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,9 @@ class Operators
5252

5353
import scala.compiletime.ops.boolean.*
5454
type Unary = ![true]
55-
}
55+
}
56+
57+
trait ThisTypeTest
58+
{
59+
def foo: this.type //expected: def foo: ThisTypeTest.this.type
60+
}

scaladoc/src/dotty/tools/scaladoc/tasty/ClassLikeSupport.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ trait ClassLikeSupport:
368368
val overriddenSyms = methodSymbol.allOverriddenSymbols.map(_.owner)
369369
Origin.Overrides(overriddenSyms.map(s => Overridden(s.name, s.dri)).toSeq)
370370

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

373373
def mkParameter(
374374
argument: ValDef,

scaladoc/src/dotty/tools/scaladoc/tasty/TypesSupport.scala

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ trait TypesSupport:
4242
import reflect._
4343
tpeTree match
4444
case TypeBoundsTree(low, high) => typeBoundsTreeOfHigherKindedType(low.tpe, high.tpe)
45-
case tpeTree: TypeTree => inner(tpeTree.tpe)
46-
case term: Term => inner(term.tpe)
45+
case tpeTree: TypeTree => topLevelProcess(tpeTree.tpe)
46+
case term: Term => topLevelProcess(term.tpe)
4747

4848
given TypeSyntax: AnyRef with
4949
extension (using Quotes)(tpe: reflect.TypeRepr)
50-
def asSignature: SSignature = inner(tpe)
50+
def asSignature: SSignature = topLevelProcess(tpe)
5151

5252

5353
private def plain(str: String): SignaturePart = Plain(str)
@@ -86,6 +86,12 @@ trait TypesSupport:
8686
case _ => false
8787
case _ => false
8888

89+
private def topLevelProcess(using Quotes)(tp: reflect.TypeRepr): SSignature =
90+
import reflect._
91+
tp match
92+
case ThisType(tpe) => inner(tpe) :+ plain(".this.type")
93+
case tpe => inner(tpe)
94+
8995
// TODO #23 add support for all types signatures that makes sense
9096
private def inner(using Quotes)(tp: reflect.TypeRepr)(using indent: Int = 0): SSignature =
9197
import reflect._

0 commit comments

Comments
 (0)