scala / scala3

The Scala 3 compiler, also known as Dotty.
https://dotty.epfl.ch
Apache License 2.0
5.88k stars 1.06k forks source link

ScalaDoc : type parameter in extension method is wrong #12813

Closed PaulCoral closed 3 years ago

PaulCoral commented 3 years ago

Compiler version

sbt 1.5.3 / scalaVersion 3.0.0 and 3.0.1-RC1

Minimized example

Start a new project sbt new scala/scala3.g8

/* src/main/scala/Main.scala */
@main def hello: Unit = 
  println(foo)

val foo: (Int,String) = 1.toTuple2("string")

extension [A](thiz:A)
  def toTuple2[B](that:B):(A,B) = thiz -> that /* <- HERE */

then run sbt doc, when finished open target/scala-3*/api/index.html in a browser and look for package <empty>.

Output

image

Expectation

Type parameter B is not present. Expecting the type paremeter of the method toTuple2 function to be [B]

nicolasstucki commented 3 years ago

In tasty, the extension

extension [A](thiz:A)
  def toTuple2[B](that:B):(A,B) = thiz -> that /* <- HERE */

Is represented as

def toTuple2[A](thiz:A)[B](that:B):(A,B) = thiz -> that /* <- HERE */

To get the type parameters we need to drop the parameters until the thiz parameter and then possibly drop contextual/implicit parameters, then it might be followed by the desired type parameters.

julienrf commented 3 years ago

Is anyone from the doctool team interested in taking this one?

romanowski commented 3 years ago

Yes, me :)