Scala Programming Language
  1. Scala Programming Language
  2. SI-3314

Descendant objects reference wrong type for inner classes in Scaladoc

    Details

      Description

      The scaladoc of enumerations only appear as "Value" and in the hover just show scala.Enumeration.Value and not the actual enumeration class. For this to be useful, it needs to show the specific enumeration object.

      Examples:

      scala.swing.ScrollBar has 'def orientation: Value' and users must guess about which enumeration is required. Should have a link to ScrollBar.Orientation in the docs. Compare this to how JavaDoc provides direct links to the specific enums: http://java.sun.com/javase/6/docs/api/javax/swing/JList.html#setDropMode%28javax.swing.DropMode%29

        Issue Links

          Activity

          Hide
          Trond Olsen added a comment - - edited

          An example in the interpreter shows that the compiler generates the correct type for inner classes in the outer object:

          scala> :paste
          // Entering paste mode (ctrl-D to finish)
          
          class Enum {
            abstract class Value
            class Val extends Value
            def Value(): Value = new Val
          }
          
          object Constants extends Enum {
            val a = Value
          }
          
          // Exiting paste mode, now interpreting.
          
          defined class Enum
          defined module Constants
          
          scala> Constants.a
          res23: Constants.Value = Enum$Val@d5454d
          

          While the generated Scaladoc reference the parent class, ignoring the outer object of the inner class:

          val a: Enum.Value
          
          Show
          Trond Olsen added a comment - - edited An example in the interpreter shows that the compiler generates the correct type for inner classes in the outer object: scala> :paste // Entering paste mode (ctrl-D to finish) class Enum { abstract class Value class Val extends Value def Value(): Value = new Val } object Constants extends Enum { val a = Value } // Exiting paste mode, now interpreting. defined class Enum defined module Constants scala> Constants.a res23: Constants.Value = Enum$Val@d5454d While the generated Scaladoc reference the parent class, ignoring the outer object of the inner class: val a: Enum.Value
          Hide
          Vlad Ureche added a comment -

          Indeed, type printing in Scaladoc has some missing cases (existentials, enums ...).
          I'm willing to help anyone interested in fixing it.

          Show
          Vlad Ureche added a comment - Indeed, type printing in Scaladoc has some missing cases (existentials, enums ...). I'm willing to help anyone interested in fixing it.
          Show
          Adriaan Moors added a comment - https://github.com/scala/scala/pull/925
          Hide
          Vlad Ureche added a comment -

          Interesting, how did this get assigned to Adriaan?

          Show
          Vlad Ureche added a comment - Interesting, how did this get assigned to Adriaan?
          Hide
          Vlad Ureche added a comment -

          Anyway, now it's fixed in trunk, take BoxPanel's constructor for example.

          Show
          Vlad Ureche added a comment - Anyway, now it's fixed in trunk, take BoxPanel's constructor for example.

            People

            • Assignee:
              Vlad Ureche
              Reporter:
              adrianp
              TracCC:
              Seth Tisue
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development