Skip to content

Scaladoc displays very incorrect type signatures for function type aliases #23456

Open
@katrinafyi

Description

@katrinafyi

Compiler version

3.7.1, nightly not checked.

also present in 3.3.4.

Minimized code

object MainObject {

  type Reader[T] = T => Int
  type Writer[T] = Int => T
  type Xah[T, U] = T => T => (U, U)
  type Xah3[T, U, V] = T => U => V

  /** Reader[Boolean] should be Boolean => Int */
  var a: Reader[Boolean] = null

  /** Writer[Boolean] be Int => Boolean */
  var b: Writer[Boolean] = null

  /** Xah[Boolean, Int] Should be Boolean => Boolean => (Int,  Int) */
  var c: Xah[Boolean, Int] = null

  /** Xah3[Boolean, Int, String] should be Boolean => Int => String */
  var d: Xah3[Boolean, Int, String] = null

  @main def hello(): Unit =
    println("Hello world!")
}

This can be pasted into a new sbt project (sbt new scala/scala3.g8), then run sbt doc to observe the incorrect output (next section).

Incorrect behaviour also seen with mill, so I have good reason to believe it's a scaladoc issue.

Output

We see that all of the type aliases for function types have incorrect type signatures.

It looks like the type alias's actual definition is thrown away, and every type alias is displayed as a function type with the last type being the return type and preceding types being the uncurried arguments

Image

Expectation

written in the doc comments included in the picture and code above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    itype:bugstat:needs triageEvery issue needs to have an "area" and "itype" label

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions