Skip to content

Scaladoc: fixes and improvements to context bounds and extension methods #22156

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
6 changes: 5 additions & 1 deletion scaladoc-testcases/src/tests/classSignatureTestSource.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@ abstract class Documentation[T, A <: Int, B >: String, -X, +Y](c1: String, val c
def this(x: T)
= this()

//expected: def toArray[B >: T : ClassTag]: Array[B]

class innerDocumentationClass
{

}

sealed trait CaseImplementThis(id: Int)

case class IAmACaseClass(x: T, id: Int) extends CaseImplementThis/*<-*/(id)/*->*/
case class IAmACaseClass(x: Documentation.this.T, id: Int) extends CaseImplementThis/*<-*/(id)/*->*/

case class IAmACaseClassWithParam[T](x: Documentation.this.T, id: T)

case object IAmACaseObject extends CaseImplementThis/*<-*/(0)/*->*/

Expand Down
14 changes: 12 additions & 2 deletions scaladoc-testcases/src/tests/contextBounds.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ package contextBounds
import scala.reflect.ClassTag

class A:
type :+:[X, Y] = [Z] =>> Map[Z, (X, Y)]

extension [T : ([X] =>> String) : ([X] =>> Int)](x: Int)
def foo[U : ([X] =>> String)](y: Int): Nothing
= ???
def bar[W : T match { case String => List case Int => Option } : Set]: Nothing
= ???
def baz[V : Int :+: String : Option]: Nothing
= ???

def basic[A : ClassTag]: A
= ???

Expand Down Expand Up @@ -35,5 +45,5 @@ class A:
// = 1

class Outer[A]:
def falsePositiveInner[T](implicit evidence$3: ClassTag[A]): Int
= 1
def falsePositiveInner[T](implicit evidence$3: ClassTag[A]): Int //expected: def falsePositiveInner[T]: Int
= 1
6 changes: 3 additions & 3 deletions scaladoc-testcases/src/tests/exports1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ class A: //unexpected
= 1
var aVar1: 1
= 1
type HKT[T[_], X] //expected: final type HKT = [T[_], X] =>> a.HKT[T, X]
type HKT[T[_], X] //expected: final type HKT = a.HKT
= T[X]
type SomeRandomType = (List[?] | Seq[?]) & String //expected: final type SomeRandomType = a.SomeRandomType
def x[T[_], X](x: X): HKT[T, X] //expected: def x[T[_], X](x: X): A.this.HKT[T, X]
def x[T[_], X](x: X): HKT[T, X]
= ???
def fn[T, U]: T => U
= ???
object Object //expected: val Obj: Object.type
val x: HKT[List, Int] //expected: val x: A.this.HKT[List, Int]
val x: HKT[List, Int]
= ???
class Class(val a: Int, val b: Int) extends Serializable //expected: final type Class = a.Class
enum Enum: //expected: final type Enum = a.Enum
Expand Down
21 changes: 20 additions & 1 deletion scaladoc-testcases/src/tests/extensionMethodSignatures.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,23 @@ case class ClassTwo(a: String, b: String)

}

class ClassOneTwo extends ClassOne
class ClassOneTwo extends ClassOne

trait C[T]
trait Equiv[T]:
extension [U : C](x: U)
def ><[V](y: V): Nothing
= ???

trait Monoid[T]:
extension (a: T)
def \:[U](b: U): Nothing
= ???
extension [U](a: T)
def \\:(b: U): Nothing
= ???

class Clazz[U]:
extension [T : ([X] =>> String) : ([X] =>> String)](x: Int)
def bar[U : ([X] =>> String) : List](y: Int): Nothing
= ???
25 changes: 25 additions & 0 deletions scaladoc-testcases/src/tests/innerClasses.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package tests
package innerClasses

trait A:
def baz: B
= baz2
def baz2: A.this.B //expected: def baz2: B
= baz
type B
class C extends A:
def foo: A.this.B
= ???
def foo2: B
= ???
def bar: B
= ???

class T1:
trait T
class T2:
trait T
class Impl extends T1.this.T //expected: class Impl extends T
// we get rid of the this-type above,
// as ambiguity created by removing this-types is alleviated by links
// (but this can be changed if needed)
29 changes: 28 additions & 1 deletion scaladoc-testcases/src/tests/thisType.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,35 @@
package tests
package thisType

// issue 16024

class X[Map[_, _[_]]]:
// issue 16024
inline def map[F[_]](f: [t] => t => F[t]): Map[this.type, F]
= ???

sealed trait Tuple[Y[_]]:
def ++[This >: this.type <: Tuple[Y]](that: Y[Tuple[Y]]): Any
= ???

sealed trait NonEmptyTuple extends Tuple[Option]
//expected: def ++[This >: this.type <: Tuple[Option]](that: Option[Tuple[Option]]): Any

trait Foo[X]:
def foo0[T <: Foo.this.type](x: X): Foo.this.type //expected: def foo0[T <: this.type](x: X): this.type
= bar0[T](x)
def bar0[T <: this.type](x: X): this.type
= foo0[T](x)

sealed abstract class Nested[+H, +T <: (Tuple), A <: Tuple[List]] extends NonEmptyTuple, Foo[Int]:
// ^^^^^^^ TODO fix
//expected: def ++[This >: this.type <: Tuple[Option]](that: Option[Tuple[Option]]): Any

//expected: def foo0[T <: this.type](x: Int): this.type

//expected: def bar0[T <: this.type](x: Int): this.type

def foo1[T <: Foo.this.type]: Nothing
= ???

def foo2[T <: this.type]: Nothing
= ???
Loading
Loading