Skip to content

Commit 6620605

Browse files
authored
Backport "Scaladoc: type rendering fixes and improvements" to LTS (#18971)
Backports #17213 to the LTS branch. PR submitted by the release tooling. [skip ci]
2 parents cb00fc2 + 597b495 commit 6620605

12 files changed

+443
-161
lines changed

scaladoc-testcases/src/tests/exports1.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@ class A: //unexpected
1414
= 1
1515
var aVar1: 1
1616
= 1
17-
type HKT[T[_], X] //expected: final type HKT = [T[_], X] =>> HKT[T, X]
17+
type HKT[T[_], X] //expected: final type HKT = [T[_], X] =>> a.HKT[T, X]
1818
= T[X]
19-
type SomeRandomType = (List[_] | Seq[_]) & String //expected: final type SomeRandomType = SomeRandomType
20-
def x[T[_], X](x: X): HKT[T, X]
19+
type SomeRandomType = (List[_] | Seq[_]) & String //expected: final type SomeRandomType = a.SomeRandomType
20+
def x[T[_], X](x: X): HKT[T, X] //expected: def x[T[_], X](x: X): A.this.HKT[T, X]
2121
= ???
2222
def fn[T, U]: T => U
2323
= ???
2424
object Object //expected: val Obj: Object.type
25-
val x: HKT[List, Int]
25+
val x: HKT[List, Int] //expected: val x: A.this.HKT[List, Int]
2626
= ???
27-
class Class(val a: Int, val b: Int) extends Serializable //expected: final type Class = Class
28-
enum Enum: //expected: final type Enum = Enum
27+
class Class(val a: Int, val b: Int) extends Serializable //expected: final type Class = a.Class
28+
enum Enum: //expected: final type Enum = a.Enum
2929
case A
3030
case B(i: Int)
3131
case C[T]() extends Enum

scaladoc-testcases/src/tests/functionTypeSignatures.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ type A = ((Int, Int)) => Int
44

55
type B = (Int | String) => Int
66

7+
type B1 = Int | String => Int //expected: type B1 = (Int | String) => Int
8+
79
type C = (Int & String) => Int
810

11+
type C1 = Int & String => Int //expected: type C1 = (Int & String) => Int
12+
13+
type D = Int | (String => Int)
14+
915
type E = (A => B) => B
1016

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
package tests
2+
package infixTypes
3+
4+
import annotation.showAsInfix
5+
6+
@showAsInfix
7+
trait SomeTrait[A, B]
8+
9+
trait SomeTrait2[A, B]
10+
11+
def someTrait1[C, D]: C SomeTrait D
12+
= ???
13+
14+
def someTrait2[E, F]: SomeTrait[E, F] //expected: def someTrait2[E, F]: E SomeTrait F
15+
= ???
16+
17+
def someTrait3[G, H]: G SomeTrait2 H //expected: def someTrait3[G, H]: SomeTrait2[G, H]
18+
= ???
19+
20+
trait +++[A, B]
21+
22+
trait ++*[A, B]
23+
24+
trait ++:[A, B]
25+
26+
trait +*:[A, B]
27+
28+
trait ***[A, B]
29+
30+
trait **:[A, B]
31+
32+
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]
33+
= ???
34+
35+
// left-associative, same precedence
36+
37+
def a0[X, Y, Z]: X +++ Y +++ Z
38+
= a1
39+
40+
def a1[X, Y, Z]: (X +++ Y) +++ Z //expected: def a1[X, Y, Z]: X +++ Y +++ Z
41+
= a0
42+
43+
def a2[X, Y, Z]: X +++ (Y +++ Z)
44+
= ???
45+
46+
def a0x[X, Y, Z]: X +++ Y ++* Z //expected: def a0x[X, Y, Z]: (X +++ Y) ++* Z
47+
= a1x
48+
49+
def a1x[X, Y, Z]: (X +++ Y) ++* Z
50+
= a0x
51+
52+
def a2x[X, Y, Z]: X +++ (Y ++* Z)
53+
= ???
54+
55+
// right-associative, same precedence
56+
57+
def a3[X, Y, Z]: X ++: Y ++: Z
58+
= a5
59+
60+
def a4[X, Y, Z]: (X ++: Y) ++: Z
61+
= ???
62+
63+
def a5[X, Y, Z]: X ++: (Y ++: Z) //expected: def a5[X, Y, Z]: X ++: Y ++: Z
64+
= a3
65+
66+
def a3x[X, Y, Z]: X ++: Y +*: Z //expected: def a3x[X, Y, Z]: X ++: (Y +*: Z)
67+
= a5x
68+
69+
def a4x[X, Y, Z]: (X ++: Y) +*: Z
70+
= ???
71+
72+
def a5x[X, Y, Z]: X ++: (Y +*: Z)
73+
= a3x
74+
75+
// left and right associative, same precedence
76+
77+
def a6[X, Y, Z]: (X +++ Y) ++: Z
78+
= ???
79+
80+
def a7[X, Y, Z]: X +++ (Y ++: Z)
81+
= ???
82+
83+
// left-associative, mixed precedence
84+
85+
def b0[X, Y, Z]: X +++ Y *** Z //expected: def b0[X, Y, Z]: X +++ (Y *** Z)
86+
= ???
87+
88+
def b1[X, Y, Z]: (X +++ Y) *** Z
89+
= ???
90+
91+
def b2[X, Y, Z]: X +++ (Y *** Z)
92+
= ???
93+
94+
def b3[X, Y, Z]: X *** Y +++ Z //expected: def b3[X, Y, Z]: (X *** Y) +++ Z
95+
= ???
96+
97+
def b4[X, Y, Z]: (X *** Y) +++ Z
98+
= ???
99+
100+
def b5[X, Y, Z]: X *** (Y +++ Z)
101+
= ???
102+
103+
// right-associative, mixed precedence
104+
105+
def c0[X, Y, Z]: X ++: Y **: Z //expected: def c0[X, Y, Z]: X ++: (Y **: Z)
106+
= ???
107+
108+
def c1[X, Y, Z]: (X ++: Y) **: Z
109+
= ???
110+
111+
def c2[X, Y, Z]: X ++: (Y **: Z)
112+
= ???
113+
114+
def c3[X, Y, Z]: X **: Y ++: Z //expected: def c3[X, Y, Z]: (X **: Y) ++: Z
115+
= ???
116+
117+
def c4[X, Y, Z]: (X **: Y) ++: Z
118+
= ???
119+
120+
def c5[X, Y, Z]: X **: (Y ++: Z)
121+
= ???
122+
123+
// left and right associative, mixed precedence
124+
125+
def d0[X, Y, Z]: X +++ Y **: Z //expected: def d0[X, Y, Z]: X +++ (Y **: Z)
126+
= ???
127+
128+
def d1[X, Y, Z]: (X +++ Y) **: Z
129+
= ???
130+
131+
def d2[X, Y, Z]: X +++ (Y **: Z)
132+
= ???
133+
134+
def d3[X, Y, Z]: X *** Y ++: Z //expected: def d3[X, Y, Z]: (X *** Y) ++: Z
135+
= ???
136+
137+
def d4[X, Y, Z]: (X *** Y) ++: Z
138+
= ???
139+
140+
def d5[X, Y, Z]: X *** (Y ++: Z)
141+
= ???
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package tests
2+
package matchTypeTuple
3+
4+
// issue 16084
5+
6+
sealed trait TupleTest[Take[_, _], Drop[_, _]]:
7+
type Split[T <: Tuple, N <: Int] = (Take[T, N], Drop[T, N])
8+
9+
inline def splitAt[This <: Tuple](n: Int): Split[This, n.type]
10+
= ???
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package tests
2+
package pathDependentTypes
3+
4+
import deriving.Mirror.ProductOf
5+
6+
// issue 16143
7+
8+
trait Foo[A]:
9+
type Out
10+
11+
trait Bar[A]:
12+
type Out
13+
14+
def foo[A](using f: Foo[A])(using b: Bar[f.Out]): b.Out
15+
= ???
16+
17+
// issue 16057
18+
19+
def fromProductTyped[P <: Product](p: P)(using m: ProductOf[P]): m.MirroredElemTypes
20+
= ???
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package tests
2+
package supertypeParamsSubstitution
3+
4+
class MyIter[A, CC[_], C]:
5+
def foo: A
6+
= ???
7+
def bar: CC[CC[A]]
8+
= ???
9+
def baz: C
10+
= ???
11+
12+
class MyList[T] extends MyIter[T, MyList, MyList[T]]
13+
//expected: def foo: T
14+
//expected: def bar: MyList[MyList[T]]
15+
//expected: def baz: MyList[T]
16+
17+
class MyListInt extends MyList[Int]
18+
//expected: def foo: Int
19+
//expected: def bar: MyList[MyList[Int]]
20+
//expected: def baz: MyList[Int]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package tests
2+
package thisType
3+
4+
// issue 16024
5+
6+
class X[Map[_, _[_]]]:
7+
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]
8+
???

0 commit comments

Comments
 (0)