-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Scaladoc: type rendering fixes and improvements #17213
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
Changes from all commits
fe0f685
ef97436
35ca2db
5e280e0
9baaddd
0c9d50b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
package tests | ||
package infixTypes | ||
|
||
import annotation.showAsInfix | ||
|
||
@showAsInfix | ||
trait SomeTrait[A, B] | ||
|
||
trait SomeTrait2[A, B] | ||
|
||
def someTrait1[C, D]: C SomeTrait D | ||
= ??? | ||
|
||
def someTrait2[E, F]: SomeTrait[E, F] //expected: def someTrait2[E, F]: E SomeTrait F | ||
= ??? | ||
|
||
def someTrait3[G, H]: G SomeTrait2 H //expected: def someTrait3[G, H]: SomeTrait2[G, H] | ||
= ??? | ||
|
||
trait +++[A, B] | ||
|
||
trait ++*[A, B] | ||
|
||
trait ++:[A, B] | ||
|
||
trait +*:[A, B] | ||
|
||
trait ***[A, B] | ||
|
||
trait **:[A, B] | ||
|
||
def foo[A, B, C, D]: (A SomeTrait B) +++ (C SomeTrait2 D) //expected: def foo[A, B, C, D]: (A SomeTrait B) +++ SomeTrait2[C, D] | ||
= ??? | ||
|
||
// left-associative, same precedence | ||
|
||
def a0[X, Y, Z]: X +++ Y +++ Z | ||
= a1 | ||
|
||
def a1[X, Y, Z]: (X +++ Y) +++ Z //expected: def a1[X, Y, Z]: X +++ Y +++ Z | ||
= a0 | ||
|
||
def a2[X, Y, Z]: X +++ (Y +++ Z) | ||
= ??? | ||
|
||
def a0x[X, Y, Z]: X +++ Y ++* Z //expected: def a0x[X, Y, Z]: (X +++ Y) ++* Z | ||
= a1x | ||
|
||
def a1x[X, Y, Z]: (X +++ Y) ++* Z | ||
= a0x | ||
|
||
def a2x[X, Y, Z]: X +++ (Y ++* Z) | ||
= ??? | ||
|
||
// right-associative, same precedence | ||
|
||
def a3[X, Y, Z]: X ++: Y ++: Z | ||
= a5 | ||
|
||
def a4[X, Y, Z]: (X ++: Y) ++: Z | ||
= ??? | ||
|
||
def a5[X, Y, Z]: X ++: (Y ++: Z) //expected: def a5[X, Y, Z]: X ++: Y ++: Z | ||
= a3 | ||
|
||
def a3x[X, Y, Z]: X ++: Y +*: Z //expected: def a3x[X, Y, Z]: X ++: (Y +*: Z) | ||
= a5x | ||
|
||
def a4x[X, Y, Z]: (X ++: Y) +*: Z | ||
= ??? | ||
|
||
def a5x[X, Y, Z]: X ++: (Y +*: Z) | ||
= a3x | ||
|
||
// left and right associative, same precedence | ||
|
||
def a6[X, Y, Z]: (X +++ Y) ++: Z | ||
= ??? | ||
|
||
def a7[X, Y, Z]: X +++ (Y ++: Z) | ||
= ??? | ||
|
||
// left-associative, mixed precedence | ||
|
||
def b0[X, Y, Z]: X +++ Y *** Z //expected: def b0[X, Y, Z]: X +++ (Y *** Z) | ||
= ??? | ||
|
||
def b1[X, Y, Z]: (X +++ Y) *** Z | ||
= ??? | ||
|
||
def b2[X, Y, Z]: X +++ (Y *** Z) | ||
= ??? | ||
|
||
def b3[X, Y, Z]: X *** Y +++ Z //expected: def b3[X, Y, Z]: (X *** Y) +++ Z | ||
= ??? | ||
|
||
def b4[X, Y, Z]: (X *** Y) +++ Z | ||
= ??? | ||
|
||
def b5[X, Y, Z]: X *** (Y +++ Z) | ||
= ??? | ||
|
||
// right-associative, mixed precedence | ||
|
||
def c0[X, Y, Z]: X ++: Y **: Z //expected: def c0[X, Y, Z]: X ++: (Y **: Z) | ||
= ??? | ||
|
||
def c1[X, Y, Z]: (X ++: Y) **: Z | ||
= ??? | ||
|
||
def c2[X, Y, Z]: X ++: (Y **: Z) | ||
= ??? | ||
|
||
def c3[X, Y, Z]: X **: Y ++: Z //expected: def c3[X, Y, Z]: (X **: Y) ++: Z | ||
= ??? | ||
|
||
def c4[X, Y, Z]: (X **: Y) ++: Z | ||
= ??? | ||
|
||
def c5[X, Y, Z]: X **: (Y ++: Z) | ||
= ??? | ||
|
||
// left and right associative, mixed precedence | ||
|
||
def d0[X, Y, Z]: X +++ Y **: Z //expected: def d0[X, Y, Z]: X +++ (Y **: Z) | ||
= ??? | ||
|
||
def d1[X, Y, Z]: (X +++ Y) **: Z | ||
= ??? | ||
|
||
def d2[X, Y, Z]: X +++ (Y **: Z) | ||
= ??? | ||
|
||
def d3[X, Y, Z]: X *** Y ++: Z //expected: def d3[X, Y, Z]: (X *** Y) ++: Z | ||
= ??? | ||
|
||
def d4[X, Y, Z]: (X *** Y) ++: Z | ||
= ??? | ||
|
||
def d5[X, Y, Z]: X *** (Y ++: Z) | ||
= ??? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package tests | ||
package matchTypeTuple | ||
|
||
// issue 16084 | ||
|
||
sealed trait TupleTest[Take[_, _], Drop[_, _]]: | ||
type Split[T <: Tuple, N <: Int] = (Take[T, N], Drop[T, N]) | ||
|
||
inline def splitAt[This <: Tuple](n: Int): Split[This, n.type] | ||
= ??? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package tests | ||
package pathDependentTypes | ||
|
||
import deriving.Mirror.ProductOf | ||
|
||
// issue 16143 | ||
|
||
trait Foo[A]: | ||
type Out | ||
|
||
trait Bar[A]: | ||
type Out | ||
|
||
def foo[A](using f: Foo[A])(using b: Bar[f.Out]): b.Out | ||
= ??? | ||
|
||
// issue 16057 | ||
|
||
def fromProductTyped[P <: Product](p: P)(using m: ProductOf[P]): m.MirroredElemTypes | ||
= ??? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package tests | ||
package supertypeParamsSubstitution | ||
|
||
class MyIter[A, CC[_], C]: | ||
def foo: A | ||
= ??? | ||
def bar: CC[CC[A]] | ||
= ??? | ||
def baz: C | ||
= ??? | ||
|
||
class MyList[T] extends MyIter[T, MyList, MyList[T]] | ||
//expected: def foo: T | ||
//expected: def bar: MyList[MyList[T]] | ||
//expected: def baz: MyList[T] | ||
|
||
class MyListInt extends MyList[Int] | ||
//expected: def foo: Int | ||
//expected: def bar: MyList[MyList[Int]] | ||
//expected: def baz: MyList[Int] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package tests | ||
package thisType | ||
|
||
// issue 16024 | ||
|
||
class X[Map[_, _[_]]]: | ||
inline def map[F[_]](f: [t] => t => F[t]): Map[this.type, F] = //expected: inline def map[F[_]](f: [t] => (x$1: t) => F[t]): Map[this.type, F] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More nitpicking: Ex: I see two ways of doing so:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll look into that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's leave that for future improvements. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you open an issue for it ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done: #17756 |
||
??? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand why we need the
a
/A
in theses, could you explain ?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is part of test consisting of 2 files:
exports1.scala
andexports2.scala
The test:
https://github.com/lampepfl/dotty/blob/ef974367932cb148bda152ed056183f319a9a2fc/scaladoc/test/dotty/tools/scaladoc/signatures/TranslatableSignaturesTestCases.scala#L96
exports2.scala
for reference:https://github.com/lampepfl/dotty/blob/ef974367932cb148bda152ed056183f319a9a2fc/scaladoc-testcases/src/tests/exports2.scala#L1-L12
So it's testing for exported member signatures in
class B
.Signatures are rendered based on
TypeRepr
from Tasty.For example
TypeRepr
forval x: HKT[List, Int]
rendered inclass B
looks like this (not valid scala, this is slightly formatted output from println):Based solely on this representation, signature that should be rendered is
A#HKT[List, Int]
To be honest, I'm not entirely sure whether this is correct way to render signatures of exported members.
If this is not correct, we may want to add some additional logic for checking if current signature is of an exported member and render it in a different way, but I'm probably gonna need some help with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sjrd or @bishabosha, you are very familiar with tasty, what do you think ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a.HKT[T, X]
seems absolutely correct to me. Otherwise you would be definingB.HKT
in terms of itself.The
A#HKT[List, Int]
seem a bit suspicious to me.this
prefix substitution (the so-calledasSeenFrom
operation) should be replacingthis.HKT[List, Int]
fromA
bya.HKT[List, Int]
when created by anexport a._
.In fact, the
TypeRef
seems even more suspicious. As is, it meansA.this.HKT
, not reallyA#HKT
. But that's quite bad if that's the type given to a member ofB
, since such a type is only valid when you're insideA
. It seems the compiler is doing something wrong here.From the point of view of Scaladoc, I think it should display
A.this.HKT
for theTypeRef(ThisType(A), type HKT)
.